diff --git a/README.md b/README.md index bfd89e0..1cd6865 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ 前端运行 `npm run build` 生成 `ui/dist`,之后安装 PyInstaller,运行 ```bash -pyinstaller -w --add-data "ui/dist:ui/dist" --add-data "launcher/sys_config/config_dist.yaml:launcher/sys_config" launcher.py +pyinstaller -w --add-data "ui/dist:ui/dist" --add-data "launcher/sys_config/config_dist.json:launcher/sys_config" launcher.py ``` 在dist文件夹生成launcher文件夹 diff --git a/launcher/config/__init__.py b/launcher/config/__init__.py index 972e9a5..01d7c22 100644 --- a/launcher/config/__init__.py +++ b/launcher/config/__init__.py @@ -2,9 +2,6 @@ import json import os from pathlib import Path -import yaml -from yamlcore import CoreLoader - from launcher.config.conf import Conf conf_path = Path(os.path.join(os.getcwd(), "conf.json")) @@ -22,8 +19,8 @@ def load_conf(): conf = Conf() save_conf() return - with conf_path.open("r", encoding="utf-8") as f: - data = yaml.load(f, Loader=CoreLoader) + with conf_path.open("r", encoding="utf-8") as file: + data = json.load(file) if data is None: data = {} conf = Conf(**data) diff --git a/launcher/sys_config/__init__.py b/launcher/sys_config/__init__.py index f0a93bf..78115eb 100644 --- a/launcher/sys_config/__init__.py +++ b/launcher/sys_config/__init__.py @@ -1,8 +1,7 @@ +import json import os import sys -import yaml - class SysConfig: """ @@ -26,13 +25,13 @@ class SysConfig: # 如果是打包后的可执行文件 base_path = sys._MEIPASS config_subdir = 'launcher/sys_config' # 添加子目录 - config_filename = 'config_dist.yaml' + config_filename = 'config_dist.json' else: # logger.error("本地配置") # 如果是本地开发环境 base_path = os.path.dirname(__file__) config_subdir = '' # 本地开发环境不需要子目录 - config_filename = 'config_local.yaml' + config_filename = 'config_local.json' config_path = os.path.join(base_path, config_subdir, config_filename) return config_path @@ -40,7 +39,7 @@ class SysConfig: def load_config(self): try: with open(self.config_path, 'r', encoding='utf-8') as file: - self.config = yaml.safe_load(file) + self.config = json.load(file) except FileNotFoundError: pass # logger.error(f"配置文件未找到: {self.config_path}") diff --git a/launcher/sys_config/config_dist.json b/launcher/sys_config/config_dist.json new file mode 100644 index 0000000..01d4337 --- /dev/null +++ b/launcher/sys_config/config_dist.json @@ -0,0 +1,5 @@ +{ + "version": "v0.4", + "url": "ui/dist/index.html", + "log_level": "ERROR" +} \ No newline at end of file diff --git a/launcher/sys_config/config_dist.yaml b/launcher/sys_config/config_dist.yaml deleted file mode 100644 index def4021..0000000 --- a/launcher/sys_config/config_dist.yaml +++ /dev/null @@ -1,3 +0,0 @@ -version: "v0.4" -url: "ui/dist/index.html" -log_level: "ERROR" \ No newline at end of file diff --git a/launcher/sys_config/config_local.json b/launcher/sys_config/config_local.json new file mode 100644 index 0000000..8b1423e --- /dev/null +++ b/launcher/sys_config/config_local.json @@ -0,0 +1,5 @@ +{ + "version": "dev", + "url": "http://localhost:5173/", + "log_level": "INFO" +} \ No newline at end of file diff --git a/launcher/sys_config/config_local.yaml b/launcher/sys_config/config_local.yaml deleted file mode 100644 index a556984..0000000 --- a/launcher/sys_config/config_local.yaml +++ /dev/null @@ -1,3 +0,0 @@ -version: "dev" -url: "http://localhost:5173/" -log_level: "INFO" \ No newline at end of file