移除site-packages

This commit is contained in:
zhbaor 2024-10-10 10:15:20 +08:00
parent 9c73b64423
commit 585f777832
3 changed files with 57 additions and 1 deletions

15
main.py
View file

@ -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: