mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 00:16:57 +08:00
refactor: unify env path
This commit is contained in:
@@ -123,7 +123,7 @@ def set_env_setting(env: dict,
|
|||||||
v = ''
|
v = ''
|
||||||
else:
|
else:
|
||||||
v = str(v)
|
v = str(v)
|
||||||
set_key(settings.CONFIG_PATH / "app.env", k, v)
|
set_key(SystemUtils.get_env_path(), k, v)
|
||||||
return schemas.Response(success=True)
|
return schemas.Response(success=True)
|
||||||
|
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ def set_setting(key: str, value: Union[list, dict, bool, int, str] = None,
|
|||||||
value = ''
|
value = ''
|
||||||
else:
|
else:
|
||||||
value = str(value)
|
value = str(value)
|
||||||
set_key(settings.CONFIG_PATH / "app.env", key, value)
|
set_key(SystemUtils.get_env_path(), key, value)
|
||||||
else:
|
else:
|
||||||
SystemConfigOper().set(key, value)
|
SystemConfigOper().set(key, value)
|
||||||
return schemas.Response(success=True)
|
return schemas.Response(success=True)
|
||||||
|
|||||||
+3
-4
@@ -414,6 +414,8 @@ class Settings(BaseSettings):
|
|||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
case_sensitive = True
|
case_sensitive = True
|
||||||
|
env_file = SystemUtils.get_env_path()
|
||||||
|
env_file_encoding = "utf-8"
|
||||||
|
|
||||||
|
|
||||||
class GlobalVar(object):
|
class GlobalVar(object):
|
||||||
@@ -451,10 +453,7 @@ class GlobalVar(object):
|
|||||||
|
|
||||||
|
|
||||||
# 实例化配置
|
# 实例化配置
|
||||||
settings = Settings(
|
settings = Settings()
|
||||||
_env_file=Settings().CONFIG_PATH / "app.env",
|
|
||||||
_env_file_encoding="utf-8"
|
|
||||||
)
|
|
||||||
|
|
||||||
# 全局标识
|
# 全局标识
|
||||||
global_vars = GlobalVar()
|
global_vars = GlobalVar()
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ class LogSettings(BaseSettings):
|
|||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
case_sensitive = True
|
case_sensitive = True
|
||||||
env_file = SystemUtils.get_config_path() / "app.env"
|
env_file = SystemUtils.get_env_path()
|
||||||
env_file_encoding = "utf-8"
|
env_file_encoding = "utf-8"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -487,3 +487,10 @@ class SystemUtils:
|
|||||||
return Path(sys.executable).parent / "config"
|
return Path(sys.executable).parent / "config"
|
||||||
else:
|
else:
|
||||||
return Path(__file__).parents[2] / "config"
|
return Path(__file__).parents[2] / "config"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_env_path() -> Path:
|
||||||
|
"""
|
||||||
|
获取配置路径
|
||||||
|
"""
|
||||||
|
return SystemUtils.get_config_path() / "app.env"
|
||||||
|
|||||||
Reference in New Issue
Block a user