Skip to content

Commit

Permalink
添加加载器URL配置
Browse files Browse the repository at this point in the history
  • Loading branch information
xfgryujk committed Aug 30, 2020
1 parent 28b04f2 commit 4d58245
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ async def get(self):
self.write({
'version': update.VERSION,
'config': {
'enableTranslate': cfg.enable_translate
'enableTranslate': cfg.enable_translate,
'loaderUrl': cfg.loader_url
}
})
4 changes: 3 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self):
self.enable_translate = True
self.allow_translate_rooms = {}
self.tornado_xheaders = False
self.loader_url = ''

def load(self, path):
try:
Expand All @@ -49,14 +50,15 @@ def load(self, path):
self.database_url = app_section['database_url']
self.enable_translate = app_section.getboolean('enable_translate')

allow_translate_rooms = app_section['allow_translate_rooms'].strip()
allow_translate_rooms = app_section['allow_translate_rooms']
if allow_translate_rooms == '':
self.allow_translate_rooms = {}
else:
allow_translate_rooms = allow_translate_rooms.split(',')
self.allow_translate_rooms = set(map(lambda id_: int(id_.strip()), allow_translate_rooms))

self.tornado_xheaders = app_section.getboolean('tornado_xheaders')
self.loader_url = app_section['loader_url']

except (KeyError, ValueError):
logger.exception('Failed to load config:')
Expand Down
4 changes: 4 additions & 0 deletions data/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ allow_translate_rooms =
# Set to true if you are using a reverse proxy server such as nginx
tornado_xheaders = false

# Use a loader so that you can run OBS before blivechat. If empty, no loader is used
loader_url = https://xfgryujk.sinacloud.net/blivechat/loader.html


# DON'T modify this section
[DEFAULT]
database_url = sqlite:///data/database.db
enable_translate = true
allow_translate_rooms =
tornado_xheaders = false
loader_url =
12 changes: 8 additions & 4 deletions frontend/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

<el-divider></el-divider>
<el-form-item :label="$t('home.roomUrl')">
<el-input ref="roomUrlInput" readonly :value="loaderUrl" style="width: calc(100% - 8em); margin-right: 1em;"></el-input>
<el-input ref="roomUrlInput" readonly :value="obsRoomUrl" 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>
Expand All @@ -90,7 +90,8 @@ export default {
data() {
return {
serverConfig: {
enableTranslate: true
enableTranslate: true,
loaderUrl: ''
},
form: {
roomId: parseInt(window.localStorage.roomId || '1'),
Expand All @@ -108,11 +109,14 @@ export default {
let resolved = this.$router.resolve({name: 'room', params: {roomId: this.form.roomId}, query})
return `${window.location.protocol}//${window.location.host}${resolved.href}`
},
loaderUrl() {
obsRoomUrl() {
if (this.roomUrl === '') {
return ''
}
let url = new URL('https://xfgryujk.sinacloud.net/blivechat/loader.html')
if (this.serverConfig.loaderUrl === '') {
return this.roomUrl
}
let url = new URL(this.serverConfig.loaderUrl)
url.searchParams.append('url', this.roomUrl)
return url.href
}
Expand Down

0 comments on commit 4d58245

Please sign in to comment.