mirror of
https://github.com/xfgryujk/blivechat.git
synced 2024-12-25 20:30:28 +08:00
加载器改成本地文件
This commit is contained in:
parent
b00ae596ef
commit
6d7c7b78d9
@ -20,6 +20,7 @@ plugins/
|
||||
# runtime data
|
||||
data/*
|
||||
!data/config.example.ini
|
||||
!data/loader.html
|
||||
!data/custom_public/
|
||||
data/custom_public/*
|
||||
!data/custom_public/README.txt
|
||||
|
11
config.py
11
config.py
@ -113,6 +113,8 @@ class AppConfig:
|
||||
self.database_url = app_section.get('database_url', self.database_url)
|
||||
self.tornado_xheaders = app_section.getboolean('tornado_xheaders', self.tornado_xheaders)
|
||||
self.loader_url = app_section.get('loader_url', self.loader_url)
|
||||
if self.loader_url == '{local_loader}':
|
||||
self.loader_url = self._get_local_loader_url()
|
||||
self.open_browser_at_startup = app_section.getboolean('open_browser_at_startup', self.open_browser_at_startup)
|
||||
self.enable_upload_file = app_section.getboolean('enable_upload_file', self.enable_upload_file)
|
||||
self.enable_admin_plugins = app_section.getboolean('enable_admin_plugins', self.enable_admin_plugins)
|
||||
@ -133,6 +135,15 @@ class AppConfig:
|
||||
self.translate_max_queue_size = app_section.getint('translate_max_queue_size', self.translate_max_queue_size)
|
||||
self.translation_cache_size = app_section.getint('translation_cache_size', self.translation_cache_size)
|
||||
|
||||
@staticmethod
|
||||
def _get_local_loader_url():
|
||||
url = os.path.abspath(os.path.join(DATA_PATH, 'loader.html'))
|
||||
url = url.replace('\\', '/')
|
||||
if not url.startswith('/'): # Windows
|
||||
url = '/' + url
|
||||
url = 'file://' + url
|
||||
return url
|
||||
|
||||
def _load_translator_configs(self, config: configparser.ConfigParser):
|
||||
app_section = config['app']
|
||||
section_names = _str_to_list(app_section.get('translator_configs', ''))
|
||||
|
@ -17,8 +17,9 @@ tornado_xheaders = false
|
||||
|
||||
# 加载器URL,本地使用时加载器可以让你先运行OBS再运行blivechat。如果为空,不使用加载器
|
||||
# **自建服务器时强烈建议不使用加载器**,否则可能因为混合HTTP和HTTPS等原因加载不出来
|
||||
# “{local_loader}”表示使用本地加载器文件URL
|
||||
# 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
|
||||
loader_url = {local_loader}
|
||||
|
||||
# 启动时打开浏览器
|
||||
# Open browser at startup
|
||||
|
39
data/loader.html
Normal file
39
data/loader.html
Normal file
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>blivechat</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>Loading... Please run blivechat</p>
|
||||
|
||||
<script>
|
||||
function main() {
|
||||
let params = new URLSearchParams(window.location.search)
|
||||
let url = params.get('url')
|
||||
if (!url) {
|
||||
let element = document.createElement('p')
|
||||
element.innerText = 'No url specified'
|
||||
document.body.appendChild(element)
|
||||
return
|
||||
}
|
||||
|
||||
let timerId = null
|
||||
function poll() {
|
||||
window.fetch(url, {mode: 'no-cors'}).then(
|
||||
() => {
|
||||
window.clearInterval(timerId)
|
||||
window.location.href = url
|
||||
},
|
||||
() => {}
|
||||
)
|
||||
}
|
||||
timerId = window.setInterval(poll, 1000)
|
||||
poll()
|
||||
}
|
||||
|
||||
main()
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user