mirror of
https://github.com/TDSCDMAA/AutoMihoyoBBS.git
synced 2026-06-10 14:12:31 +08:00
fix
This commit is contained in:
parent
ba913488f0
commit
a10355276e
13
config.py
13
config.py
@ -44,13 +44,16 @@ config = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
path = os.path.dirname(os.path.realpath(__file__)) + "/config"
|
path = os.path.dirname(os.path.realpath(__file__)) + "/config"
|
||||||
if os.getenv("AutoMihoyoBBS_config_path") != "":
|
if os.getenv("AutoMihoyoBBS_config_path") is not None:
|
||||||
path = os.getenv("AutoMihoyoBBS_config_path")
|
path = os.getenv("AutoMihoyoBBS_config_path")
|
||||||
config_Path_json = f"{path}/config.json"
|
config_Path_json = f"{path}/config.json"
|
||||||
config_Path = f"{path}/config.yaml"
|
config_Path = f"{path}/config.yaml"
|
||||||
|
|
||||||
|
|
||||||
def copy_config():
|
def copy_config():
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
def load_config_json():
|
def load_config_json():
|
||||||
with open(config_Path_json, "r") as f:
|
with open(config_Path_json, "r") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
@ -109,7 +112,7 @@ def config_v7_update(data: dict):
|
|||||||
def load_config(p_path=None):
|
def load_config(p_path=None):
|
||||||
global config
|
global config
|
||||||
if not p_path:
|
if not p_path:
|
||||||
p_path=config_Path
|
p_path = config_Path
|
||||||
with open(p_path, "r", encoding='utf-8') as f:
|
with open(p_path, "r", encoding='utf-8') as f:
|
||||||
data = yaml.load(f, Loader=yaml.FullLoader)
|
data = yaml.load(f, Loader=yaml.FullLoader)
|
||||||
if data['version'] == 7:
|
if data['version'] == 7:
|
||||||
@ -121,14 +124,14 @@ def load_config(p_path=None):
|
|||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
def save_config(p_path=None,p_config=None):
|
def save_config(p_path=None, p_config=None):
|
||||||
global serverless
|
global serverless
|
||||||
if serverless:
|
if serverless:
|
||||||
log.info("云函数执行,无法保存")
|
log.info("云函数执行,无法保存")
|
||||||
return None
|
return None
|
||||||
if not p_path:
|
if not p_path:
|
||||||
p_path=config_Path
|
p_path = config_Path
|
||||||
p_config=config
|
p_config = config
|
||||||
with open(p_path, "w+") as f:
|
with open(p_path, "w+") as f:
|
||||||
try:
|
try:
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user