diff --git a/main.py b/launcher.py
similarity index 86%
rename from main.py
rename to launcher.py
index bea2394..b0ab98e 100644
--- a/main.py
+++ b/launcher.py
@@ -3,14 +3,13 @@ import mimetypes
from pathlib import Path
from shutil import rmtree
from subprocess import PIPE, STDOUT, Popen
-
import webview
mimetypes.add_type("text/html", ".html")
mimetypes.add_type("text/css", ".css")
mimetypes.add_type("application/javascript", ".js")
-version = "2024-10-10"
+version = "2024-11-28"
config = {
"page": "init",
@@ -34,6 +33,7 @@ def custom_event(data):
mirror_list = {
+ "aliyun": "https://mirrors.aliyun.com/pypi/simple/",
"pypi": "https://pypi.org/simple",
"tuna": "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple",
"sjtu": "https://mirror.sjtu.edu.cn/pypi/web/simple",
@@ -72,6 +72,10 @@ class Api:
def set_mirror(self, mirror):
config["mirror"] = mirror
+ def update_self(self):
+ # 更新启动器本身
+ pass
+
def rm_site_packages(self):
site_packages_path = Path("./python/Lib/site-packages")
if site_packages_path.exists():
@@ -79,6 +83,13 @@ class Api:
return "移除成功"
return "python\\Lib\\site-packages目录不存在"
+ def rm_python_script(self):
+ python_script_path = Path("./python/Scripts")
+ if python_script_path.exists():
+ rmtree(python_script_path)
+ return "移除成功"
+ return "python\\Scripts目录不存在"
+
def run(self, command, cwd=None):
command = command_list[command]
if callable(command):
@@ -101,9 +112,7 @@ class Api:
return "failed"
-window = webview.create_window(
- f"mower-ng launcher {version}", "ui/dist/index.html", js_api=Api()
-)
+window = webview.create_window("mower-ng launcher", "ui/dist/index.html", js_api=Api())
webview.start()
with config_path.open("w") as f:
diff --git a/log.py b/log.py
new file mode 100644
index 0000000..686d527
--- /dev/null
+++ b/log.py
@@ -0,0 +1,33 @@
+import logging
+from logging.handlers import RotatingFileHandler
+
+
+# 配置日志
+def setup_logger():
+ logger = logging.getLogger("launcher.log")
+ logger.setLevel(logging.DEBUG)
+
+ # 控制台输出
+ console_handler = logging.StreamHandler()
+ console_handler.setLevel(logging.DEBUG)
+
+ # 文件输出
+ file_handler = RotatingFileHandler(
+ "launcher.log", maxBytes=5 * 1024 * 1024, backupCount=3
+ )
+ file_handler.setLevel(logging.INFO)
+
+ # 设置格式化器
+ formatter = logging.Formatter("%(asctime)s [%(levelname)s] - %(message)s")
+ console_handler.setFormatter(formatter)
+ file_handler.setFormatter(formatter)
+
+ # 添加 Handler
+ logger.addHandler(console_handler)
+ logger.addHandler(file_handler)
+
+ return logger
+
+
+# 创建全局 Logger 实例
+logger = setup_logger()
diff --git a/ui/src/pages/Fix.vue b/ui/src/pages/Fix.vue
index 1f97086..89e1148 100644
--- a/ui/src/pages/Fix.vue
+++ b/ui/src/pages/Fix.vue
@@ -16,23 +16,40 @@ async function rm_site_packages() {
})
running.value = false
}
+
+
+async function rm_python_script() {
+ running.value = true
+ notification['info']({
+ content: '提示',
+ meta: '开始移除python/Script',
+ duration: 3000
+ })
+ const response = await pywebview.api.rm_python_script()
+ notification['info']({
+ content: '提示',
+ meta: response,
+ duration: 3000
+ })
+ running.value = false
+}
-
+ ">
移除 site-packages
+
+ 移除 python/Script
+
diff --git a/ui/src/pages/Update.vue b/ui/src/pages/Update.vue
index 567b794..99dc1bc 100644
--- a/ui/src/pages/Update.vue
+++ b/ui/src/pages/Update.vue
@@ -43,14 +43,15 @@ provide('current_state', current_state)
- fast
- slow
+ 测试版
+ 稳定版
+ 阿里云镜像站
PyPI
上海交通大学镜像站
清华大学镜像站