mirror of
https://github.com/ikunshare/Onekey.git
synced 2026-01-13 00:27:32 +08:00
chore: 代码优化
This commit is contained in:
@@ -7,16 +7,23 @@ import aiofiles
|
||||
from .stack_error import stack_error
|
||||
from .log import log
|
||||
|
||||
|
||||
async def gen_config_file():
|
||||
qa1 = "温馨提示:Github_Personal_Token可在Github设置的最底下开发者选项找到,详情看教程"
|
||||
tutorial = "https://ikunshare.com/Onekey_tutorial"
|
||||
default_config ={
|
||||
"Github_Personal_Token": "",
|
||||
"Custom_Steam_Path": "",
|
||||
"QA1": "温馨提示:Github_Personal_Token可在Github设置的最底下开发者选项找到,详情看教程",
|
||||
"教程": "https://lyvx-my.sharepoint.com/:w:/g/personal/ikun_ikunshare_com/EWqIqyCElLNLo_CKfLbqix0BWU_O03HLzEHQKHdJYrUz-Q?e=79MZjw"
|
||||
"QA1": qa1,
|
||||
"教程": tutorial
|
||||
}
|
||||
async with aiofiles.open("./config.json", mode="w", encoding="utf-8") as f:
|
||||
await f.write(json.dumps(default_config, indent=2, ensure_ascii=False,
|
||||
escape_forward_slashes=False))
|
||||
async with aiofiles.open("./config.json",
|
||||
mode="w",
|
||||
encoding="utf-8") as f:
|
||||
await f.write(json.dumps(default_config,
|
||||
indent=2,
|
||||
ensure_ascii=False,
|
||||
escape_forward_slashes=False))
|
||||
await f.close()
|
||||
log.info(' 🖱️ 程序可能为第一次启动,请填写配置文件后重新启动程序')
|
||||
|
||||
@@ -28,7 +35,9 @@ async def load_config():
|
||||
sys.exit()
|
||||
else:
|
||||
try:
|
||||
async with aiofiles.open("./config.json", mode="r", encoding="utf-8") as f:
|
||||
async with aiofiles.open("./config.json",
|
||||
mode="r",
|
||||
encoding="utf-8") as f:
|
||||
config = json.loads(await f.read())
|
||||
return config
|
||||
except Exception as e:
|
||||
@@ -37,4 +46,4 @@ async def load_config():
|
||||
os.system('pause')
|
||||
|
||||
|
||||
config = asyncio.run(load_config())
|
||||
config = asyncio.run(load_config())
|
||||
|
||||
@@ -6,6 +6,7 @@ from .log import log
|
||||
|
||||
lock = asyncio.Lock()
|
||||
|
||||
|
||||
async def depotkey_merge(config_path, depots_config):
|
||||
if not config_path.exists():
|
||||
async with lock:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import logging
|
||||
import colorlog
|
||||
|
||||
|
||||
def init_log():
|
||||
logger = logging.getLogger('Onekey')
|
||||
logger.setLevel(logging.DEBUG)
|
||||
@@ -18,4 +19,5 @@ def init_log():
|
||||
logger.addHandler(stream_handler)
|
||||
return logger
|
||||
|
||||
log = init_log()
|
||||
|
||||
log = init_log()
|
||||
|
||||
Reference in New Issue
Block a user