显示的房间URL改成加载器URL

This commit is contained in:
John Smith 2020-08-18 21:48:33 +08:00
parent d25a32beaf
commit bfa6054899
3 changed files with 19 additions and 7 deletions

View File

@ -8,9 +8,15 @@ import update
class MainHandler(tornado.web.StaticFileHandler):
"""为了使用Vue Router的history模式把所有请求转发到index.html"""
async def get(self, *args, **kwargs):
await super().get('index.html', *args, **kwargs)
"""为了使用Vue Router的history模式把不存在的文件请求转发到index.html"""
async def get(self, path, include_body=True):
try:
await super().get(path, include_body)
except tornado.web.HTTPError as e:
if e.status_code != 404:
raise
# 不存在的文件请求转发到index.html交给前端路由
await super().get('index.html', include_body)
# noinspection PyAbstractClass

View File

@ -66,7 +66,7 @@
<el-divider></el-divider>
<el-form-item :label="$t('home.roomUrl')">
<el-input ref="roomUrlInput" readonly :value="roomUrl" style="width: calc(100% - 8em); margin-right: 1em;"></el-input>
<el-input ref="roomUrlInput" readonly :value="loaderUrl" style="width: calc(100% - 8em); margin-right: 1em;"></el-input>
<el-button type="primary" @click="copyUrl">{{$t('home.copy')}}</el-button>
</el-form-item>
<el-form-item>
@ -107,6 +107,14 @@ export default {
delete query.roomId
let resolved = this.$router.resolve({name: 'room', params: {roomId: this.form.roomId}, query})
return `${window.location.protocol}//${window.location.host}${resolved.href}`
},
loaderUrl() {
if (this.roomUrl === '') {
return ''
}
let url = new URL('https://xfgryujk.sinacloud.net/blivechat/loader.html')
url.searchParams.append('url', this.roomUrl)
return url.href
}
},
watch: {

View File

@ -24,9 +24,7 @@ routes = [
(r'/server_info', api.main.ServerInfoHandler),
(r'/chat', api.chat.ChatHandler),
(r'/((css|fonts|img|js|static)/.*)', tornado.web.StaticFileHandler, {'path': WEB_ROOT}),
(r'/(favicon\.ico)', tornado.web.StaticFileHandler, {'path': WEB_ROOT}),
(r'/.*', api.main.MainHandler, {'path': WEB_ROOT})
(r'/(.*)', api.main.MainHandler, {'path': WEB_ROOT, 'default_filename': 'index.html'})
]