修复开机自启时目录错误

This commit is contained in:
DLmaster
2025-01-07 11:32:06 +08:00
parent 04fd2b10fa
commit 1ea9d10bb4
5 changed files with 31 additions and 42 deletions

View File

@@ -49,9 +49,8 @@ class AppConfig:
def __init__(self) -> None:
self.app_path = Path.cwd() # 获取软件根目录
self.app_path_sys = os.path.realpath(sys.argv[0]) # 获取软件自身的路径
self.app_name = os.path.basename(self.app_path) # 获取软件自身的名称
self.app_path = Path(sys.argv[0]).resolve().parent # 获取软件根目录
self.app_path_sys = str(Path(sys.argv[0]).resolve()) # 获取软件自身的路径
self.database_path = self.app_path / "data/data.db"
self.config_path = self.app_path / "config/config.json"
@@ -70,6 +69,7 @@ class AppConfig:
# 检查目录
(self.app_path / "config").mkdir(parents=True, exist_ok=True)
(self.app_path / "data").mkdir(parents=True, exist_ok=True)
# (self.app_path / "data/MAAconfig/simple").mkdir(parents=True, exist_ok=True)
# (self.app_path / "data/MAAconfig/beta").mkdir(parents=True, exist_ok=True)
# (self.app_path / "data/MAAconfig/Default").mkdir(parents=True, exist_ok=True)
@@ -195,9 +195,7 @@ class AppConfig:
def open_database(self, mode: str, index: str = None) -> None:
"""打开数据库"""
if self.if_database_opened:
self.close_database()
if mode == "Maa":
self.db = sqlite3.connect(
self.app_path / f"config/{mode}Config/{index}/user_date.db"
@@ -208,6 +206,7 @@ class AppConfig:
def close_database(self) -> None:
"""关闭数据库"""
if self.if_database_opened:
self.cur.close()
self.db.close()
self.if_database_opened = False

View File

@@ -74,7 +74,7 @@ class SystemHandler:
winreg.KEY_ALL_ACCESS | winreg.KEY_WRITE | winreg.KEY_CREATE_SUB_KEY,
)
winreg.SetValueEx(
key, self.config.app_name, 0, winreg.REG_SZ, self.config.app_path_sys
key, "AUTO_MAA主程序", 0, winreg.REG_SZ, self.config.app_path_sys
)
winreg.CloseKey(key)
elif (
@@ -89,7 +89,7 @@ class SystemHandler:
winreg.KEY_SET_VALUE,
winreg.KEY_ALL_ACCESS | winreg.KEY_WRITE | winreg.KEY_CREATE_SUB_KEY,
)
winreg.DeleteValue(key, self.config.app_name)
winreg.DeleteValue(key, "AUTO_MAA主程序")
winreg.CloseKey(key)
def is_startup(self):
@@ -103,7 +103,7 @@ class SystemHandler:
)
try:
value, _ = winreg.QueryValueEx(key, self.config.app_name)
value, _ = winreg.QueryValueEx(key, "AUTO_MAA主程序")
winreg.CloseKey(key)
return True
except FileNotFoundError:

View File

@@ -198,7 +198,6 @@ class AUTO_MAA(MSFluentWindow):
)
self.splashScreen.finish()
self.show_main()
if self.config.global_config.get(self.config.global_config.update_IfAutoUpdate):
result = self.setting.check_update()

View File

@@ -46,25 +46,20 @@ if __name__ == "__main__":
print("Packaging AUTO_MAA main program ...")
result = subprocess.run(
f"powershell -Command nuitka --standalone --onefile --mingw64"
f" --enable-plugins=pyside6 --windows-console-mode=disable"
f" --onefile-tempdir-spec=%TEMP%\\AUTO_MAA"
f" --windows-icon-from-ico=resources\\icons\\AUTO_MAA.ico"
f" --company-name='AUTO_MAA Team' --product-name=AUTO_MAA"
os.system(
"powershell -Command python -m nuitka --standalone --onefile --mingw64"
" --enable-plugins=pyside6 --windows-console-mode=disable"
" --onefile-tempdir-spec='{TEMP}\\AUTO_MAA'"
" --windows-icon-from-ico=resources\\icons\\AUTO_MAA.ico"
" --company-name='AUTO_MAA Team' --product-name=AUTO_MAA"
f" --file-version={version["main_version"]}"
f" --product-version={version["main_version"]}"
f" --file-description='AUTO_MAA Component'"
f" --copyright='Copyright © 2024 DLmaster361'"
f" --assume-yes-for-downloads --output-filename=AUTO_MAA"
f" --remove-output main.py",
shell=True,
capture_output=True,
text=True,
" --file-description='AUTO_MAA Component'"
" --copyright='Copyright © 2024 DLmaster361'"
" --assume-yes-for-downloads --output-filename=AUTO_MAA"
" --remove-output main.py"
)
print(result.stdout)
print(result.stderr)
print("AUTO_MAA main program packaging completed !")
shutil.copy(root_path / "app/utils/Updater.py", root_path)
@@ -80,25 +75,20 @@ if __name__ == "__main__":
print("Packaging AUTO_MAA update program ...")
result = subprocess.run(
f"powershell -Command nuitka --standalone --onefile --mingw64"
f" --enable-plugins=pyside6 --windows-console-mode=disable"
f" --onefile-tempdir-spec=%TEMP%\\AUTO_MAA_Updater"
f" --windows-icon-from-ico=resources\\icons\\AUTO_MAA_Updater.ico"
f" --company-name='AUTO_MAA Team' --product-name=AUTO_MAA"
os.system(
"powershell -Command python -m nuitka --standalone --onefile --mingw64"
" --enable-plugins=pyside6 --windows-console-mode=disable"
" --onefile-tempdir-spec='{TEMP}\\AUTO_MAA_Updater'"
" --windows-icon-from-ico=resources\\icons\\AUTO_MAA_Updater.ico"
" --company-name='AUTO_MAA Team' --product-name=AUTO_MAA"
f" --file-version={version["updater_version"]}"
f" --product-version={version["main_version"]}"
f" --file-description='AUTO_MAA Component'"
f" --copyright='Copyright © 2024 DLmaster361'"
f" --assume-yes-for-downloads --output-filename=Updater"
f" --remove-output Updater.py",
shell=True,
capture_output=True,
text=True,
" --file-description='AUTO_MAA Component'"
" --copyright='Copyright © 2024 DLmaster361'"
" --assume-yes-for-downloads --output-filename=Updater"
" --remove-output Updater.py"
)
print(result.stdout)
print(result.stderr)
print("AUTO_MAA update program packaging completed !")
(root_path / "Updater.py").unlink()

View File

@@ -48,5 +48,6 @@ if __name__ == "__main__":
application.installTranslator(translator)
window = AUTO_MAA(config=config, notify=notify, crypto=crypto, system=system)
window.show_main()
window.setting.check_PASSWORD()
sys.exit(application.exec())