Compare commits
3 commits
b6f5abb338
...
2f33c3185b
Author | SHA1 | Date | |
---|---|---|---|
2f33c3185b | |||
20613844db | |||
faeeffe34d |
6 changed files with 397 additions and 368 deletions
|
@ -9,5 +9,5 @@
|
|||
前端运行 `npm run build` 生成 `ui/dist`,之后安装 PyInstaller,运行
|
||||
|
||||
```bash
|
||||
pyinstaller -w -F --add-data ui/dist:dist main.py
|
||||
pyinstaller -w -F --add-data ui/dist:ui/dist main.py
|
||||
```
|
||||
|
|
41
main.py
41
main.py
|
@ -4,17 +4,21 @@ from subprocess import PIPE, STDOUT, Popen
|
|||
|
||||
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})
|
||||
|
@ -22,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",
|
||||
}
|
||||
|
@ -48,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,
|
||||
|
@ -65,7 +84,7 @@ class Api:
|
|||
custom_event(line)
|
||||
|
||||
|
||||
window = webview.create_window("mower-ng launcher", "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:
|
||||
|
|
660
ui/package-lock.json
generated
660
ui/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -11,20 +11,20 @@
|
|||
"format": "prettier --write src/"
|
||||
},
|
||||
"dependencies": {
|
||||
"vue": "^3.4.29"
|
||||
"vue": "^3.5.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rushstack/eslint-patch": "^1.8.0",
|
||||
"@rushstack/eslint-patch": "^1.10.4",
|
||||
"@vicons/ionicons5": "^0.12.0",
|
||||
"@vitejs/plugin-vue": "^5.0.5",
|
||||
"@vue/eslint-config-prettier": "^9.0.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-vue": "^9.23.0",
|
||||
"naive-ui": "^2.39.0",
|
||||
"prettier": "^3.2.5",
|
||||
"@vitejs/plugin-vue": "^5.1.4",
|
||||
"@vue/eslint-config-prettier": "^10.0.0",
|
||||
"eslint": "^9.12.0",
|
||||
"eslint-plugin-vue": "^9.28.0",
|
||||
"naive-ui": "^2.40.1",
|
||||
"prettier": "^3.3.3",
|
||||
"unplugin-auto-import": "^0.18.3",
|
||||
"unplugin-vue-components": "^0.27.4",
|
||||
"vfonts": "^0.0.3",
|
||||
"vite": "^5.3.1"
|
||||
"vite": "^5.4.8"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
>
|
||||
<n-tab-pane name="init" tab="初始化"><init /></n-tab-pane>
|
||||
<n-tab-pane name="update" tab="更新代码"><update /></n-tab-pane>
|
||||
<n-tab-pane name="launch" tab="启动程序"><launch /></n-tab-pane>
|
||||
<n-tab-pane :disabled="running" name="init" tab="初始化"><init /></n-tab-pane>
|
||||
<n-tab-pane :disabled="running" name="update" tab="更新代码"><update /></n-tab-pane>
|
||||
<n-tab-pane :disabled="running" name="launch" tab="启动程序"><launch /></n-tab-pane>
|
||||
</n-tabs>
|
||||
</n-notification-provider>
|
||||
<n-global-style />
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
<script setup>
|
||||
const branch = ref(null)
|
||||
const mirror = ref(null)
|
||||
|
||||
onMounted(() => {
|
||||
pywebview.api.get_branch().then((value) => {
|
||||
branch.value = value
|
||||
})
|
||||
pywebview.api.get_mirror().then((value) => {
|
||||
mirror.value = value
|
||||
})
|
||||
})
|
||||
|
||||
watch(branch, () => {
|
||||
pywebview.api.set_branch(branch.value)
|
||||
})
|
||||
watch(mirror, () => {
|
||||
pywebview.api.set_mirror(mirror.value)
|
||||
})
|
||||
|
||||
const steps = computed(() => [
|
||||
{
|
||||
|
@ -32,15 +39,25 @@ provide('current_state', current_state)
|
|||
|
||||
<template>
|
||||
<n-flex vertical style="gap: 16px; height: 100%; padding: 16px; box-sizing: border-box">
|
||||
<n-flex>
|
||||
<div>mower-ng 代码分支:</div>
|
||||
<n-radio-group v-model:value="branch">
|
||||
<n-flex>
|
||||
<n-radio value="fast">fast</n-radio>
|
||||
<n-radio value="slow">slow</n-radio>
|
||||
</n-flex>
|
||||
</n-radio-group>
|
||||
</n-flex>
|
||||
<n-form label-placement="left" :show-feedback="false" label-width="auto" label-align="left">
|
||||
<n-form-item label="mower-ng 代码分支">
|
||||
<n-radio-group v-model:value="branch">
|
||||
<n-flex>
|
||||
<n-radio value="fast">fast</n-radio>
|
||||
<n-radio value="slow">slow</n-radio>
|
||||
</n-flex>
|
||||
</n-radio-group>
|
||||
</n-form-item>
|
||||
<n-form-item label="PyPI 仓库镜像">
|
||||
<n-radio-group v-model:value="mirror">
|
||||
<n-flex>
|
||||
<n-radio value="pypi">PyPI</n-radio>
|
||||
<n-radio value="sjtu">上海交通大学镜像站</n-radio>
|
||||
<n-radio value="tuna">清华大学镜像站</n-radio>
|
||||
</n-flex>
|
||||
</n-radio-group>
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
<n-steps :current="current_step" :status="current_state" size="small">
|
||||
<n-step v-for="step in steps" :title="step.title" />
|
||||
</n-steps>
|
||||
|
|
Loading…
Add table
Reference in a new issue