美化+命令修复
This commit is contained in:
parent
32496af392
commit
ec44c5c9ad
8 changed files with 35 additions and 24 deletions
17
main.py
17
main.py
|
@ -16,13 +16,14 @@ except Exception:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def custom_event(name, data):
|
def custom_event(data):
|
||||||
data = json.dumps({name: data})
|
data = json.dumps({"log": data})
|
||||||
js = f"var event = new CustomEvent('log', {{detail: {data}}}); window.dispatchEvent(event);"
|
js = f"var event = new CustomEvent('log', {{detail: {data}}}); window.dispatchEvent(event);"
|
||||||
window.evaluate_js(js)
|
window.evaluate_js(js)
|
||||||
|
|
||||||
|
|
||||||
command_list = {
|
command_list = {
|
||||||
|
"lfs": "git\\bin\\git lfs install",
|
||||||
"ensurepip": "python\\python -m ensurepip --default-pip --no-warn-script-location",
|
"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",
|
"clone": "git\\bin\\git clone https://git.zhaozuohong.vip/mower-ng/mower-ng.git --branch slow",
|
||||||
"fetch": "..\\git\\bin\\git fetch",
|
"fetch": "..\\git\\bin\\git fetch",
|
||||||
|
@ -30,6 +31,7 @@ command_list = {
|
||||||
"switch_slow": "..\\git\\bin\\git switch -f slow",
|
"switch_slow": "..\\git\\bin\\git switch -f slow",
|
||||||
"reset_fast": "..\\git\\bin\\git reset --hard origin/fast",
|
"reset_fast": "..\\git\\bin\\git reset --hard origin/fast",
|
||||||
"reset_slow": "..\\git\\bin\\git reset --hard origin/slow",
|
"reset_slow": "..\\git\\bin\\git reset --hard origin/slow",
|
||||||
|
"pip_install": "..\\python\\Scripts\\pip install -i https://mirror.sjtu.edu.cn/pypi/web/simple -r requirements.txt --no-warn-script-location",
|
||||||
"webview": "start ..\\python\\pythonw webview_ui.py",
|
"webview": "start ..\\python\\pythonw webview_ui.py",
|
||||||
"manager": "start ..\\python\\pythonw manager.py",
|
"manager": "start ..\\python\\pythonw manager.py",
|
||||||
}
|
}
|
||||||
|
@ -49,8 +51,10 @@ class Api:
|
||||||
config["page"] = page
|
config["page"] = page
|
||||||
|
|
||||||
def run(self, command, cwd=None):
|
def run(self, command, cwd=None):
|
||||||
|
command = command_list[command]
|
||||||
|
custom_event(command + "\n")
|
||||||
with Popen(
|
with Popen(
|
||||||
command_list[command],
|
command,
|
||||||
stdout=PIPE,
|
stdout=PIPE,
|
||||||
stderr=STDOUT,
|
stderr=STDOUT,
|
||||||
shell=True,
|
shell=True,
|
||||||
|
@ -59,11 +63,12 @@ class Api:
|
||||||
cwd=cwd,
|
cwd=cwd,
|
||||||
) as p:
|
) as p:
|
||||||
for line in p.stdout:
|
for line in p.stdout:
|
||||||
custom_event("log", line)
|
custom_event(line)
|
||||||
|
|
||||||
|
|
||||||
window = webview.create_window("mower-ng launcher", "dist/index.html", js_api=Api())
|
# window = webview.create_window("mower-ng launcher", "dist/index.html", js_api=Api())
|
||||||
webview.start()
|
window = webview.create_window("mower-ng launcher", "http://localhost:5173/", js_api=Api())
|
||||||
|
webview.start(debug=True)
|
||||||
|
|
||||||
with config_path.open("w") as f:
|
with config_path.open("w") as f:
|
||||||
json.dump(config, f)
|
json.dump(config, f)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Vite App</title>
|
<title>Vite App</title>
|
||||||
</head>
|
</head>
|
||||||
<body style="background-color: black">
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="module" src="/src/main.js"></script>
|
<script type="module" src="/src/main.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -8,8 +8,6 @@ const loading = ref(true)
|
||||||
const page = ref(null)
|
const page = ref(null)
|
||||||
|
|
||||||
function load_config() {
|
function load_config() {
|
||||||
console.log('load_config')
|
|
||||||
console.log(pywebview)
|
|
||||||
pywebview.api.get_page().then((value) => {
|
pywebview.api.get_page().then((value) => {
|
||||||
page.value = value
|
page.value = value
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
@ -50,7 +48,7 @@ provide('steps', steps)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<n-config-provider :theme="darkTheme" :locale="zhCN" :dateLocale="dateZhCN">
|
<n-config-provider :locale="zhCN" :dateLocale="dateZhCN">
|
||||||
<n-spin v-if="loading" class="container">
|
<n-spin v-if="loading" class="container">
|
||||||
<template #description>加载中</template>
|
<template #description>加载中</template>
|
||||||
</n-spin>
|
</n-spin>
|
||||||
|
|
|
@ -37,8 +37,8 @@ async function start() {
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.float {
|
.float {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 25px;
|
right: 28px;
|
||||||
bottom: 25px;
|
bottom: 28px;
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { darkTheme } from 'naive-ui'
|
||||||
|
|
||||||
const log = inject('log')
|
const log = inject('log')
|
||||||
const log_ele = inject('log_ele')
|
const log_ele = inject('log_ele')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<n-log :log="log" style="flex-grow: 1" ref="log_ele" />
|
<n-config-provider :theme="darkTheme" style="flex-grow: 1">
|
||||||
|
<n-card style="height: 100%">
|
||||||
|
<n-log :log="log" style="height: 100%" ref="log_ele" />
|
||||||
|
</n-card>
|
||||||
|
</n-config-provider>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
const steps = ref([
|
const steps = ref([
|
||||||
{ title: '设置Git LFS', command: ['git\\bin\\git lfs install'] },
|
{ title: '设置 Git LFS', command: ['lfs'] },
|
||||||
{
|
{
|
||||||
title: '安装pip',
|
title: '安装 pip',
|
||||||
command: ['ensurepip']
|
command: ['ensurepip']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '下载代码',
|
title: '下载 mower-ng 代码',
|
||||||
command: ['clone']
|
command: ['clone']
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
|
@ -20,14 +20,18 @@ function manager() {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<n-button class="launch-btn" @click="webview">单开运行</n-button>
|
<n-button class="launch-btn" type="primary" secondary size="large" @click="webview">
|
||||||
<n-button class="launch-btn" @click="manager">多开器</n-button>
|
单开运行
|
||||||
|
</n-button>
|
||||||
|
<n-button class="launch-btn" type="primary" secondary size="large" @click="manager">
|
||||||
|
多开器
|
||||||
|
</n-button>
|
||||||
</n-flex>
|
</n-flex>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.launch-btn {
|
.launch-btn {
|
||||||
width: 160px;
|
width: 120px;
|
||||||
height: 48px;
|
height: 48px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -13,15 +13,13 @@ watch(branch, () => {
|
||||||
|
|
||||||
const steps = computed(() => [
|
const steps = computed(() => [
|
||||||
{
|
{
|
||||||
title: '下载源码',
|
title: '更新源码',
|
||||||
command: ['fetch', `switch_${branch.value}`, `reset_${branch.value}`],
|
command: ['fetch', `switch_${branch.value}`, `reset_${branch.value}`],
|
||||||
cwd: 'mower-ng'
|
cwd: 'mower-ng'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '安装依赖',
|
title: '安装依赖',
|
||||||
command: [
|
command: ['pip_install'],
|
||||||
'..\\python\\Scripts\\pip install -i https://mirror.sjtu.edu.cn/pypi/web/simple -r requirements.txt --no-warn-script-location'
|
|
||||||
],
|
|
||||||
cwd: 'mower-ng'
|
cwd: 'mower-ng'
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
@ -35,7 +33,7 @@ provide('current_state', current_state)
|
||||||
<template>
|
<template>
|
||||||
<n-flex vertical style="gap: 16px; height: 100%; padding: 16px; box-sizing: border-box">
|
<n-flex vertical style="gap: 16px; height: 100%; padding: 16px; box-sizing: border-box">
|
||||||
<n-flex>
|
<n-flex>
|
||||||
<div>代码分支:</div>
|
<div>mower-ng 代码分支:</div>
|
||||||
<n-radio-group v-model:value="branch">
|
<n-radio-group v-model:value="branch">
|
||||||
<n-flex>
|
<n-flex>
|
||||||
<n-radio value="fast">fast</n-radio>
|
<n-radio value="fast">fast</n-radio>
|
||||||
|
|
Loading…
Reference in a new issue