From 32496af3924eb5f6e1049cf1dc480094a8820961 Mon Sep 17 00:00:00 2001 From: Zhao Zuohong Date: Mon, 23 Sep 2024 19:14:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=91=BD=E4=BB=A4=E7=A7=BB=E8=87=B3ma?= =?UTF-8?q?in.py=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 15 ++++++++++++++- ui/src/pages/Init.vue | 4 ++-- ui/src/pages/Launch.vue | 4 ++-- ui/src/pages/Update.vue | 6 +----- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/main.py b/main.py index 07e0e1d..9889397 100644 --- a/main.py +++ b/main.py @@ -22,6 +22,19 @@ def custom_event(name, data): window.evaluate_js(js) +command_list = { + "ensurepip": "python\\python -m ensurepip --default-pip --no-warn-script-location", + "clone": "git\\bin\\git clone https://git.zhaozuohong.vip/mower-ng/mower-ng.git --branch slow", + "fetch": "..\\git\\bin\\git fetch", + "switch_fast": "..\\git\\bin\\git switch -f fast", + "switch_slow": "..\\git\\bin\\git switch -f slow", + "reset_fast": "..\\git\\bin\\git reset --hard origin/fast", + "reset_slow": "..\\git\\bin\\git reset --hard origin/slow", + "webview": "start ..\\python\\pythonw webview_ui.py", + "manager": "start ..\\python\\pythonw manager.py", +} + + class Api: def get_branch(self): return config["branch"] @@ -37,7 +50,7 @@ class Api: def run(self, command, cwd=None): with Popen( - command, + command_list[command], stdout=PIPE, stderr=STDOUT, shell=True, diff --git a/ui/src/pages/Init.vue b/ui/src/pages/Init.vue index a6aa830..f04bcfb 100644 --- a/ui/src/pages/Init.vue +++ b/ui/src/pages/Init.vue @@ -3,11 +3,11 @@ const steps = ref([ { title: '设置Git LFS', command: ['git\\bin\\git lfs install'] }, { title: '安装pip', - command: ['python\\python -m ensurepip --default-pip --no-warn-script-location'] + command: ['ensurepip'] }, { title: '下载代码', - command: ['git\\bin\\git clone https://git.zhaozuohong.vip/mower-ng/mower-ng.git --branch slow'] + command: ['clone'] } ]) provide('steps', steps) diff --git a/ui/src/pages/Launch.vue b/ui/src/pages/Launch.vue index d1919f1..aa01d19 100644 --- a/ui/src/pages/Launch.vue +++ b/ui/src/pages/Launch.vue @@ -1,10 +1,10 @@ diff --git a/ui/src/pages/Update.vue b/ui/src/pages/Update.vue index 4d60e5c..fefa31f 100644 --- a/ui/src/pages/Update.vue +++ b/ui/src/pages/Update.vue @@ -14,11 +14,7 @@ watch(branch, () => { const steps = computed(() => [ { title: '下载源码', - command: [ - '..\\git\\bin\\git fetch', - `..\\git\\bin\\git switch -f ${branch.value}`, - `..\\git\\bin\\git reset --hard origin/${branch.value}` - ], + command: ['fetch', `switch_${branch.value}`, `reset_${branch.value}`], cwd: 'mower-ng' }, {