From 585f777832130a5ba6d971c4fd492cdf358932e3 Mon Sep 17 00:00:00 2001 From: zhbaor Date: Thu, 10 Oct 2024 10:15:20 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4site-packages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 15 ++++++++++++++- ui/src/App.vue | 2 ++ ui/src/pages/Fix.vue | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 ui/src/pages/Fix.vue diff --git a/main.py b/main.py index 2764457..8f28c13 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,6 @@ import json from pathlib import Path +from shutil import rmtree from subprocess import PIPE, STDOUT, Popen import webview @@ -20,6 +21,7 @@ try: except Exception: pass + def custom_event(data): data = json.dumps({"log": data}) js = f"var event = new CustomEvent('log', {{detail: {data}}}); window.dispatchEvent(event);" @@ -65,6 +67,13 @@ class Api: def set_mirror(self, mirror): config["mirror"] = mirror + def rm_site_packages(self): + site_packages_path = Path("./python/Lib/site-packages") + if site_packages_path.exists(): + rmtree(site_packages_path) + return "移除成功" + return "python\\Lib\\site-packages目录不存在" + def run(self, command, cwd=None): command = command_list[command] if callable(command): @@ -84,7 +93,11 @@ class Api: custom_event(line) -window = webview.create_window(f"mower-ng launcher {version}", "ui/dist/index.html", js_api=Api()) +window = webview.create_window( + f"mower-ng launcher {version}", + "ui/dist/index.html", + js_api=Api(), +) webview.start() with config_path.open("w") as f: diff --git a/ui/src/App.vue b/ui/src/App.vue index fff8953..5d09561 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -2,6 +2,7 @@ import Init from '@/pages/Init.vue' import Launch from '@/pages/Launch.vue' import Update from '@/pages/Update.vue' +import Fix from '@/pages/Fix.vue' import { dateZhCN, zhCN } from 'naive-ui' const loading = ref(true) @@ -63,6 +64,7 @@ provide('steps', steps) + diff --git a/ui/src/pages/Fix.vue b/ui/src/pages/Fix.vue new file mode 100644 index 0000000..019c9d5 --- /dev/null +++ b/ui/src/pages/Fix.vue @@ -0,0 +1,41 @@ + + + + +