将命令移至main.py中

This commit is contained in:
zhbaor 2024-09-23 19:14:57 +08:00
parent d9f1aae27c
commit 32496af392
4 changed files with 19 additions and 10 deletions

15
main.py
View file

@ -22,6 +22,19 @@ def custom_event(name, data):
window.evaluate_js(js) 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: class Api:
def get_branch(self): def get_branch(self):
return config["branch"] return config["branch"]
@ -37,7 +50,7 @@ class Api:
def run(self, command, cwd=None): def run(self, command, cwd=None):
with Popen( with Popen(
command, command_list[command],
stdout=PIPE, stdout=PIPE,
stderr=STDOUT, stderr=STDOUT,
shell=True, shell=True,

View file

@ -3,11 +3,11 @@ const steps = ref([
{ title: '设置Git LFS', command: ['git\\bin\\git lfs install'] }, { title: '设置Git LFS', command: ['git\\bin\\git lfs install'] },
{ {
title: '安装pip', title: '安装pip',
command: ['python\\python -m ensurepip --default-pip --no-warn-script-location'] command: ['ensurepip']
}, },
{ {
title: '下载代码', title: '下载代码',
command: ['git\\bin\\git clone https://git.zhaozuohong.vip/mower-ng/mower-ng.git --branch slow'] command: ['clone']
} }
]) ])
provide('steps', steps) provide('steps', steps)

View file

@ -1,10 +1,10 @@
<script setup> <script setup>
function webview() { function webview() {
pywebview.api.run('start ..\\python\\pythonw webview_ui.py', 'mower-ng') pywebview.api.run('webview', 'mower-ng')
} }
function manager() { function manager() {
pywebview.api.run('start ..\\python\\pythonw manager.py', 'mower-ng') pywebview.api.run('manager', 'mower-ng')
} }
</script> </script>

View file

@ -14,11 +14,7 @@ watch(branch, () => {
const steps = computed(() => [ const steps = computed(() => [
{ {
title: '下载源码', title: '下载源码',
command: [ command: ['fetch', `switch_${branch.value}`, `reset_${branch.value}`],
'..\\git\\bin\\git fetch',
`..\\git\\bin\\git switch -f ${branch.value}`,
`..\\git\\bin\\git reset --hard origin/${branch.value}`
],
cwd: 'mower-ng' cwd: 'mower-ng'
}, },
{ {