From 6d7c7b78d9beaa917b124518238e8d5a3993cc9a Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 29 Jul 2024 23:21:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=99=A8=E6=94=B9=E6=88=90?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 1 + config.py | 11 +++++++++++ data/config.example.ini | 3 ++- data/loader.html | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 data/loader.html diff --git a/.dockerignore b/.dockerignore index 2c57889..2fc3c4e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -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 diff --git a/config.py b/config.py index 9f7b4c5..3fe8a78 100644 --- a/config.py +++ b/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', '')) diff --git a/data/config.example.ini b/data/config.example.ini index 9e9cd46..2ce2320 100644 --- a/data/config.example.ini +++ b/data/config.example.ini @@ -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 diff --git a/data/loader.html b/data/loader.html new file mode 100644 index 0000000..66690d2 --- /dev/null +++ b/data/loader.html @@ -0,0 +1,39 @@ + + + + + blivechat + + + +

Loading... Please run blivechat

+ + + +