diff --git a/main.py b/main.py
index 3374ddc..2764457 100644
--- a/main.py
+++ b/main.py
@@ -6,17 +6,19 @@ import webview
version = "2024-10-10"
+config = {
+ "page": "init",
+ "branch": "slow",
+ "mirror": "tuna",
+}
config_path = Path("launcher.json")
try:
with config_path.open("r") as f:
- config = json.load(f)
+ user_config = json.load(f)
+ config.update(user_config)
except Exception:
- config = {
- "page": "init",
- "branch": "slow",
- }
-
+ pass
def custom_event(data):
data = json.dumps({"log": data})
@@ -24,14 +26,21 @@ def custom_event(data):
window.evaluate_js(js)
+mirror_list = {
+ "pypi": "https://pypi.org/simple",
+ "tuna": "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple",
+ "sjtu": "https://mirror.sjtu.edu.cn/pypi/web/simple",
+}
+
+
command_list = {
"lfs": "git\\bin\\git lfs install",
"ensurepip": "python\\python -m ensurepip --default-pip",
"clone": "git\\bin\\git clone https://git.zhaozuohong.vip/mower-ng/mower-ng.git --branch slow",
- "fetch": f"..\\git\\bin\\git fetch origin {config['branch']}",
- "switch": f"..\\git\\bin\\git switch -f {config['branch']}",
- "reset": f"..\\git\\bin\\git reset --hard origin/{config['branch']}",
- "pip_install": "..\\python\\Scripts\\pip install --no-cache-dir -i https://mirror.sjtu.edu.cn/pypi/web/simple -r requirements.txt --no-warn-script-location",
+ "fetch": lambda: f"..\\git\\bin\\git fetch origin {config['branch']}",
+ "switch": lambda: f"..\\git\\bin\\git switch -f {config['branch']}",
+ "reset": lambda: f"..\\git\\bin\\git reset --hard origin/{config['branch']}",
+ "pip_install": lambda: f"..\\python\\Scripts\\pip install --no-cache-dir -i {mirror_list[config['mirror']]} -r requirements.txt --no-warn-script-location",
"webview": "start ..\\python\\pythonw webview_ui.py",
"manager": "start ..\\python\\pythonw manager.py",
}
@@ -50,8 +59,16 @@ class Api:
def set_page(self, page):
config["page"] = page
+ def get_mirror(self):
+ return config["mirror"]
+
+ def set_mirror(self, mirror):
+ config["mirror"] = mirror
+
def run(self, command, cwd=None):
command = command_list[command]
+ if callable(command):
+ command = command()
custom_event(command + "\n")
with Popen(
command,
diff --git a/ui/src/App.vue b/ui/src/App.vue
index 0d52415..fff8953 100644
--- a/ui/src/App.vue
+++ b/ui/src/App.vue
@@ -2,7 +2,7 @@
import Init from '@/pages/Init.vue'
import Launch from '@/pages/Launch.vue'
import Update from '@/pages/Update.vue'
-import { darkTheme, dateZhCN, zhCN } from 'naive-ui'
+import { dateZhCN, zhCN } from 'naive-ui'
const loading = ref(true)
const page = ref(null)
@@ -58,12 +58,11 @@ provide('steps', steps)
placement="left"
class="container"
:default-value="page"
- @before-leave="!running"
@update:value="set_page"
>
-
-
-
+
+
+
diff --git a/ui/src/pages/Update.vue b/ui/src/pages/Update.vue
index 7492097..567b794 100644
--- a/ui/src/pages/Update.vue
+++ b/ui/src/pages/Update.vue
@@ -1,15 +1,22 @@