Compare commits
8 commits
Author | SHA1 | Date | |
---|---|---|---|
06fab427aa | |||
e3c2627fc5 | |||
e4b93b94b1 | |||
6e235a28c1 | |||
e3457c1081 | |||
5576f8de39 | |||
de2c2af2bd | |||
501259b420 |
12 changed files with 245 additions and 58 deletions
|
@ -1,4 +1,4 @@
|
||||||
from typing import List
|
from typing import List, Literal, get_args, get_origin
|
||||||
|
|
||||||
from pydantic import BaseModel, model_validator
|
from pydantic import BaseModel, model_validator
|
||||||
from pydantic_core import PydanticUndefined
|
from pydantic_core import PydanticUndefined
|
||||||
|
@ -15,6 +15,18 @@ class ConfModel(BaseModel):
|
||||||
data[name] = expected_type
|
data[name] = expected_type
|
||||||
else:
|
else:
|
||||||
data[name] = field.default
|
data[name] = field.default
|
||||||
|
value = data[name]
|
||||||
|
|
||||||
|
# 检查 Literal 类型并修正
|
||||||
|
if get_origin(expected_type) is Literal:
|
||||||
|
valid_literals = get_args(expected_type)
|
||||||
|
if value not in valid_literals:
|
||||||
|
# 修正为默认值
|
||||||
|
data[name] = (
|
||||||
|
field.default
|
||||||
|
if field.default is not PydanticUndefined
|
||||||
|
else None
|
||||||
|
)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,9 +67,17 @@ class LaunchPart(ConfModel):
|
||||||
is_show_log: bool = False
|
is_show_log: bool = False
|
||||||
|
|
||||||
|
|
||||||
|
class OtherPart(ConfModel):
|
||||||
|
"""其他配置"""
|
||||||
|
|
||||||
|
# xx.zhaozuohong.vip镜像 (访问xx.zhaozuohong.vip url时,0=原路径 1=在.zhaozuohong.vip前添加-cf前缀)
|
||||||
|
base_mirror: Literal["0", "1"] = "0"
|
||||||
|
|
||||||
|
|
||||||
class Conf(
|
class Conf(
|
||||||
Total,
|
Total,
|
||||||
UpdatePart,
|
UpdatePart,
|
||||||
LaunchPart,
|
LaunchPart,
|
||||||
|
OtherPart,
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -8,18 +8,21 @@ constants.py
|
||||||
update_tmp_folder = "download_tmp"
|
update_tmp_folder = "download_tmp"
|
||||||
# 更新脚本名
|
# 更新脚本名
|
||||||
upgrade_script_name = "upgrade.bat"
|
upgrade_script_name = "upgrade.bat"
|
||||||
|
# 下载新版本压缩包名
|
||||||
|
file_name = "launcher.7z"
|
||||||
|
|
||||||
# 获取最新版本发布信息
|
# 获取最新版本发布信息
|
||||||
get_new_version_url = (
|
get_new_version_url = (
|
||||||
"https://git.zhaozuohong.vip/api/v1/repos/mower-ng/launcher/releases/latest"
|
"https://git.zhaozuohong.vip/api/v1/repos/mower-ng/launcher/releases/latest"
|
||||||
)
|
)
|
||||||
# 下载新版本压缩包名
|
|
||||||
file_name = "launcher.7z"
|
|
||||||
|
|
||||||
# 下载地址
|
# 下载地址
|
||||||
download_git_url = "https://list.zhaozuohong.vip/mower-ng/git.7z"
|
download_git_url = "https://list.zhaozuohong.vip/mower-ng/git.7z"
|
||||||
download_python_url = "https://list.zhaozuohong.vip/mower-ng/python.7z"
|
download_python_url = "https://list.zhaozuohong.vip/mower-ng/python.7z"
|
||||||
|
|
||||||
|
# mower-ng git链接
|
||||||
|
mower_ng_git_url = "https://git.zhaozuohong.vip/mower-ng/mower-ng.git"
|
||||||
|
|
||||||
# pip镜像地址
|
# pip镜像地址
|
||||||
mirror_list = {
|
mirror_list = {
|
||||||
"pypi": "https://pypi.org/simple",
|
"pypi": "https://pypi.org/simple",
|
||||||
|
@ -30,3 +33,15 @@ mirror_list = {
|
||||||
|
|
||||||
# 实例文件夹名
|
# 实例文件夹名
|
||||||
instances_folder_name = "instances"
|
instances_folder_name = "instances"
|
||||||
|
|
||||||
|
# cli命令
|
||||||
|
cli_command = {
|
||||||
|
"status": "获取mower-ng实例状态",
|
||||||
|
"launch": "启动mower-ng进程",
|
||||||
|
"exit": "停止mower-ng进程",
|
||||||
|
"kill": "强制退出mower-ng进程",
|
||||||
|
"start": "开始运行调度器",
|
||||||
|
"stop": "停止运行调度器",
|
||||||
|
"webui": "在浏览器中打开网页面板",
|
||||||
|
"log": "通过WebSocket获取日志",
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "v0.6",
|
"version": "v0.7.1",
|
||||||
"url": "ui/dist/index.html",
|
"url": "ui/dist/index.html",
|
||||||
"log_level": "INFO",
|
"log_level": "INFO",
|
||||||
"debug": false
|
"debug": false
|
||||||
|
|
12
launcher/utils.py
Normal file
12
launcher/utils.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
from launcher import config
|
||||||
|
|
||||||
|
|
||||||
|
def build_base_url(url: str) -> str:
|
||||||
|
"""
|
||||||
|
构建xx.zhaozuohong.vip,如果配置base_mirror是1,在.zhaozuohong.vip前添加-cf前缀
|
||||||
|
:param url: 带有xx.zhaozuohong.vip的url字符串
|
||||||
|
:return: 构建完成的url
|
||||||
|
"""
|
||||||
|
if config.conf.base_mirror == "1":
|
||||||
|
url = url.replace(".zhaozuohong.vip", "-cf.zhaozuohong.vip")
|
||||||
|
return url
|
|
@ -2,7 +2,7 @@ import io
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import threading
|
import time
|
||||||
from _winapi import CREATE_NO_WINDOW
|
from _winapi import CREATE_NO_WINDOW
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
|
@ -11,7 +11,6 @@ from subprocess import Popen
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from launcher import config
|
from launcher import config
|
||||||
from launcher.config.conf import LaunchPart
|
|
||||||
from launcher.constants import (
|
from launcher.constants import (
|
||||||
download_git_url,
|
download_git_url,
|
||||||
download_python_url,
|
download_python_url,
|
||||||
|
@ -20,6 +19,8 @@ from launcher.constants import (
|
||||||
mirror_list,
|
mirror_list,
|
||||||
file_name,
|
file_name,
|
||||||
instances_folder_name,
|
instances_folder_name,
|
||||||
|
mower_ng_git_url,
|
||||||
|
cli_command,
|
||||||
)
|
)
|
||||||
from launcher.file.download import init_download, download_file
|
from launcher.file.download import init_download, download_file
|
||||||
from launcher.file.extract import extract_7z_file
|
from launcher.file.extract import extract_7z_file
|
||||||
|
@ -27,22 +28,29 @@ from launcher.file.utils import ensure_directory_exists, check_command_path
|
||||||
from launcher.instances import manager
|
from launcher.instances import manager
|
||||||
from launcher.log import logger
|
from launcher.log import logger
|
||||||
from launcher.sys_config import sys_config
|
from launcher.sys_config import sys_config
|
||||||
|
from launcher.utils import build_base_url
|
||||||
from launcher.webview.events import custom_event, LogType
|
from launcher.webview.events import custom_event, LogType
|
||||||
|
|
||||||
command_list = {
|
command_list = {
|
||||||
"download_git": lambda: init_download("git", download_git_url, os.getcwd()),
|
"download_git": lambda: init_download(
|
||||||
|
"git", build_base_url(download_git_url), os.getcwd()
|
||||||
|
),
|
||||||
"download_python": lambda: init_download(
|
"download_python": lambda: init_download(
|
||||||
"python", download_python_url, os.getcwd()
|
"python", build_base_url(download_python_url), os.getcwd()
|
||||||
),
|
),
|
||||||
"lfs": "git\\bin\\git lfs install",
|
"lfs": "git\\bin\\git lfs install",
|
||||||
"ensurepip": "python\\python -m ensurepip --default-pip",
|
"ensurepip": "python\\python -m ensurepip --default-pip",
|
||||||
"clone": "git\\bin\\git -c lfs.concurrenttransfers=100 clone https://git.zhaozuohong.vip/mower-ng/mower-ng.git --branch slow",
|
"clone": lambda: f"git\\bin\\git -c lfs.concurrenttransfers=100 clone {build_base_url(mower_ng_git_url)} --branch slow",
|
||||||
|
"set_remote": lambda: f"..\\git\\bin\\git remote set-url origin {build_base_url(mower_ng_git_url)}",
|
||||||
|
"set_lfs": lambda: f"..\\git\\bin\\git config lfs.url {build_base_url(mower_ng_git_url)}/info/lfs",
|
||||||
"fetch": lambda: f"..\\git\\bin\\git fetch origin {config.conf.branch} --progress",
|
"fetch": lambda: f"..\\git\\bin\\git fetch origin {config.conf.branch} --progress",
|
||||||
"switch": lambda: f"..\\git\\bin\\git -c lfs.concurrenttransfers=100 switch -f {config.conf.branch} --progress",
|
"switch": lambda: f"..\\git\\bin\\git -c lfs.concurrenttransfers=100 switch -f {config.conf.branch} --progress",
|
||||||
"reset": lambda: f"..\\git\\bin\\git -c lfs.concurrenttransfers=200 reset --hard origin/{config.conf.branch}",
|
"reset": lambda: f"..\\git\\bin\\git -c lfs.concurrenttransfers=200 reset --hard origin/{config.conf.branch}",
|
||||||
"pip_tools_install": lambda: f"..\\python\\Scripts\\pip install --no-cache-dir -i {mirror_list[config.conf.mirror]} pip-tools --no-warn-script-location",
|
"pip_tools_install": lambda: f"..\\python\\Scripts\\pip install --no-cache-dir -i {mirror_list[config.conf.mirror]} pip-tools --no-warn-script-location",
|
||||||
"pip_sync": lambda: f"..\\python\\Scripts\\pip-sync -i {mirror_list[config.conf.mirror]} requirements.txt",
|
"pip_sync": lambda: f"..\\python\\Scripts\\pip-sync -i {mirror_list[config.conf.mirror]} requirements.txt",
|
||||||
"webview": lambda instance_path="": f'..\\python\\pythonw -X utf8 webview_ui.py "{instance_path}"',
|
"webview": lambda instance_path="": f'..\\python\\pythonw -X utf8 webview_ui.py "{instance_path}"',
|
||||||
|
"cli": lambda path,
|
||||||
|
command: f'..\\python\\pythonw -X utf8 cli.py -p "{path}" {command}',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,11 +94,12 @@ class Api:
|
||||||
|
|
||||||
def get_new_version(self):
|
def get_new_version(self):
|
||||||
logger.info("获取最新版本号")
|
logger.info("获取最新版本号")
|
||||||
response = requests.get(get_new_version_url)
|
response = requests.get(build_base_url(get_new_version_url))
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
# 更新启动器本身
|
# 更新启动器本身
|
||||||
def update_self(self, download_url):
|
def update_self(self, download_url):
|
||||||
|
download_url = build_base_url(download_url)
|
||||||
logger.info(f"开始更新启动器 {download_url}")
|
logger.info(f"开始更新启动器 {download_url}")
|
||||||
current_path = os.getcwd()
|
current_path = os.getcwd()
|
||||||
download_tmp_folder = os.path.join(current_path, "download_tmp")
|
download_tmp_folder = os.path.join(current_path, "download_tmp")
|
||||||
|
@ -221,28 +230,6 @@ class Api:
|
||||||
) == instances_dir and os.path.exists(abs_path):
|
) == instances_dir and os.path.exists(abs_path):
|
||||||
shutil.rmtree(abs_path)
|
shutil.rmtree(abs_path)
|
||||||
|
|
||||||
def start_checked_instance(self):
|
|
||||||
checked_instances = [
|
|
||||||
instance for instance in config.conf.instances if instance.checked
|
|
||||||
]
|
|
||||||
if not checked_instances:
|
|
||||||
custom_event(LogType.warning, "没有选中的实例")
|
|
||||||
return [{"status": False, "message": "No checked instances"}]
|
|
||||||
|
|
||||||
def _run_instance(instance: LaunchPart.Instance):
|
|
||||||
self.run(
|
|
||||||
"webview",
|
|
||||||
"mower-ng",
|
|
||||||
{"instance_path": instance.path},
|
|
||||||
)
|
|
||||||
|
|
||||||
# 创建并启动线程 目前进程依然有阻塞,待优化
|
|
||||||
for instance in checked_instances:
|
|
||||||
thread = threading.Thread(
|
|
||||||
target=_run_instance, args=(instance,), daemon=True
|
|
||||||
)
|
|
||||||
thread.start()
|
|
||||||
|
|
||||||
def migrate_default_instance(self):
|
def migrate_default_instance(self):
|
||||||
"""迁移默认实例文件到新实例"""
|
"""迁移默认实例文件到新实例"""
|
||||||
source_path = os.path.join(os.getcwd(), "mower-ng")
|
source_path = os.path.join(os.getcwd(), "mower-ng")
|
||||||
|
@ -258,3 +245,63 @@ class Api:
|
||||||
else:
|
else:
|
||||||
os.startfile(path)
|
os.startfile(path)
|
||||||
custom_event(LogType.info, f"成功打开文件夹:{path}")
|
custom_event(LogType.info, f"成功打开文件夹:{path}")
|
||||||
|
|
||||||
|
def test_base_url_connect(self):
|
||||||
|
url = build_base_url(get_new_version_url)
|
||||||
|
custom_event(LogType.info, f"开始测试URL连接:{url}")
|
||||||
|
try:
|
||||||
|
start_time = time.time()
|
||||||
|
response = requests.get(url)
|
||||||
|
end_time = time.time()
|
||||||
|
if response.status_code == 200:
|
||||||
|
elapsed_time_ms = (end_time - start_time) * 1000
|
||||||
|
custom_event(
|
||||||
|
LogType.info, f"测试成功,响应时间为 {elapsed_time_ms:.2f} 毫秒"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
custom_event(
|
||||||
|
LogType.error, f"测试失败: HTTP状态码 {response.status_code}"
|
||||||
|
)
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
custom_event(LogType.error, f"发生错误: {e}")
|
||||||
|
|
||||||
|
def cli_control(self, command: str, path: str):
|
||||||
|
"""
|
||||||
|
统一的CLI控制接口,用于执行指定命令并可选地指定工作目录。
|
||||||
|
|
||||||
|
:param command_str: 要执行的命令字符串或命令键(如 "status", "launch" 等)
|
||||||
|
:param path: 实例路径
|
||||||
|
"""
|
||||||
|
if command not in cli_command:
|
||||||
|
custom_event(
|
||||||
|
LogType.error,
|
||||||
|
f"无效的命令字符串或命令键:{command},请检查输入。",
|
||||||
|
)
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
ret = self.run("cli", "mower-ng", {"command": command, "path": path})
|
||||||
|
if command == "launch" and ret == "success":
|
||||||
|
self.run("cli", "mower-ng", {"command": "webui", "path": path})
|
||||||
|
except Exception as e:
|
||||||
|
custom_event(LogType.error, f"{cli_command[command]} 失败 {repr(e)}")
|
||||||
|
|
||||||
|
def batch_cli_control(self, command):
|
||||||
|
checked_instances = [
|
||||||
|
instance for instance in config.conf.instances if instance.checked
|
||||||
|
]
|
||||||
|
if not checked_instances:
|
||||||
|
custom_event(LogType.warning, "没有选中的实例")
|
||||||
|
return [{"status": False, "message": "No checked instances"}]
|
||||||
|
|
||||||
|
for instance in checked_instances:
|
||||||
|
try:
|
||||||
|
custom_event(LogType.info, f"{instance.name} {cli_command[command]}")
|
||||||
|
self.cli_control(command, instance.path)
|
||||||
|
custom_event(
|
||||||
|
LogType.info, f"{instance.name} {cli_command[command]} 完成"
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
custom_event(
|
||||||
|
LogType.error,
|
||||||
|
f"{instance.name} {cli_command[command]} 失败 {repr(e)}",
|
||||||
|
)
|
||||||
|
|
30
ui/src/components/BaseMirrorOption.vue
Normal file
30
ui/src/components/BaseMirrorOption.vue
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<script setup>
|
||||||
|
import { form_item_label_style } from '@/styles/styles.js'
|
||||||
|
import { useConfigStore } from '@/stores/config.js'
|
||||||
|
|
||||||
|
const conf = useConfigStore().config
|
||||||
|
|
||||||
|
const running = inject('running')
|
||||||
|
|
||||||
|
async function test_connect() {
|
||||||
|
running.value = true
|
||||||
|
await pywebview.api.test_base_url_connect()
|
||||||
|
running.value = false
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<n-form-item label="镜像模式" :label-style="form_item_label_style">
|
||||||
|
<n-radio-group v-model:value="conf.base_mirror" :disabled="running">
|
||||||
|
<n-flex>
|
||||||
|
<n-radio value="0">默认模式</n-radio>
|
||||||
|
<n-radio value="1">镜像模式(-cf后缀)</n-radio>
|
||||||
|
</n-flex>
|
||||||
|
</n-radio-group>
|
||||||
|
<n-button strong secondary type="primary" size="small" @click="test_connect" :disabled="running"
|
||||||
|
>测试连接</n-button
|
||||||
|
>
|
||||||
|
</n-form-item>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
|
@ -1,4 +1,3 @@
|
||||||
import 'vfonts/Lato.css'
|
|
||||||
import 'vfonts/FiraCode.css'
|
import 'vfonts/FiraCode.css'
|
||||||
import './styles/global.css'
|
import './styles/global.css'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import BaseMirrorOption from '@/components/BaseMirrorOption.vue'
|
||||||
|
|
||||||
const steps = ref([
|
const steps = ref([
|
||||||
{
|
{
|
||||||
title: '下载 git、python',
|
title: '下载 git、python',
|
||||||
|
@ -22,6 +24,9 @@ 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-form label-placement="left" :show-feedback="false" label-width="auto" label-align="left">
|
||||||
|
<base-mirror-option />
|
||||||
|
</n-form>
|
||||||
<n-alert title="以下步骤仅需运行一次" type="warning" />
|
<n-alert title="以下步骤仅需运行一次" type="warning" />
|
||||||
<n-steps :current="current_step" :status="current_state" size="small">
|
<n-steps :current="current_step" :status="current_state" size="small">
|
||||||
<n-step v-for="step in steps" :title="step.title" />
|
<n-step v-for="step in steps" :title="step.title" />
|
||||||
|
|
|
@ -1,7 +1,17 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useConfigStore } from '@/stores/config.js'
|
import { useConfigStore } from '@/stores/config.js'
|
||||||
import { NButton } from 'naive-ui'
|
import { NButton } from 'naive-ui'
|
||||||
import { Add, Pencil, Play, Folder, TrashOutline, Archive } from '@vicons/ionicons5'
|
import {
|
||||||
|
Add,
|
||||||
|
Pencil,
|
||||||
|
Play,
|
||||||
|
Folder,
|
||||||
|
TrashOutline,
|
||||||
|
Archive,
|
||||||
|
Browsers,
|
||||||
|
Stop,
|
||||||
|
Search
|
||||||
|
} from '@vicons/ionicons5'
|
||||||
|
|
||||||
const notification = useNotification()
|
const notification = useNotification()
|
||||||
|
|
||||||
|
@ -64,13 +74,11 @@ function end_update_instance_name() {
|
||||||
function open_folder(path) {
|
function open_folder(path) {
|
||||||
pywebview.api.open_folder(path)
|
pywebview.api.open_folder(path)
|
||||||
}
|
}
|
||||||
function start_instance(instance) {
|
function cli(command, instance) {
|
||||||
pywebview.api.run('webview', 'mower-ng', {
|
pywebview.api.cli_control(command, instance.path)
|
||||||
instance_path: instance.path
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
function start_checked_instance() {
|
function batch_cli_control(command) {
|
||||||
pywebview.api.start_checked_instance()
|
pywebview.api.batch_cli_control(command)
|
||||||
}
|
}
|
||||||
async function handle_migrate(key) {
|
async function handle_migrate(key) {
|
||||||
if (key == 'default') {
|
if (key == 'default') {
|
||||||
|
@ -132,7 +140,7 @@ async function handle_migrate(key) {
|
||||||
class="launch-btn"
|
class="launch-btn"
|
||||||
type="primary"
|
type="primary"
|
||||||
secondary
|
secondary
|
||||||
@click="start_checked_instance"
|
@click="batch_cli_control('launch')"
|
||||||
:disabled="!check_all && !check_part"
|
:disabled="!check_all && !check_part"
|
||||||
>
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
|
@ -140,6 +148,18 @@ async function handle_migrate(key) {
|
||||||
</template>
|
</template>
|
||||||
启动所选实例
|
启动所选实例
|
||||||
</n-button>
|
</n-button>
|
||||||
|
<n-button
|
||||||
|
class="launch-btn"
|
||||||
|
type="error"
|
||||||
|
secondary
|
||||||
|
@click="batch_cli_control('exit')"
|
||||||
|
:disabled="!check_all && !check_part"
|
||||||
|
>
|
||||||
|
<template #icon>
|
||||||
|
<n-icon :component="Stop"></n-icon>
|
||||||
|
</template>
|
||||||
|
停止所选实例
|
||||||
|
</n-button>
|
||||||
<n-dropdown trigger="click" :options="migrate_options" @select="handle_migrate">
|
<n-dropdown trigger="click" :options="migrate_options" @select="handle_migrate">
|
||||||
<n-button class="launch-btn" type="primary" secondary>
|
<n-button class="launch-btn" type="primary" secondary>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
|
@ -155,8 +175,8 @@ async function handle_migrate(key) {
|
||||||
显示日志
|
显示日志
|
||||||
</div>
|
</div>
|
||||||
</n-space>
|
</n-space>
|
||||||
<n-list class="instance-list" bordered>
|
<n-list class="instance_list" bordered>
|
||||||
<n-list-item>
|
<n-list-item class="instance_list_item">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<n-checkbox
|
<n-checkbox
|
||||||
v-model:checked="check_all"
|
v-model:checked="check_all"
|
||||||
|
@ -167,38 +187,55 @@ async function handle_migrate(key) {
|
||||||
>
|
>
|
||||||
</template>
|
</template>
|
||||||
</n-list-item>
|
</n-list-item>
|
||||||
<n-list-item v-for="(item, index) in conf.instances" :key="index">
|
<n-list-item class="instance_list_item" v-for="(item, index) in conf.instances" :key="index">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<n-checkbox v-model:checked="item.checked"></n-checkbox>
|
<n-checkbox v-model:checked="item.checked"></n-checkbox>
|
||||||
</template>
|
</template>
|
||||||
<n-space vertical>
|
<n-space vertical>
|
||||||
<n-space v-if="update_instance_name_index != index">
|
<n-space v-if="update_instance_name_index != index">
|
||||||
<n-text>{{ item.name }}</n-text>
|
<n-text class="instance_name">{{ item.name }}</n-text>
|
||||||
<n-button size="tiny" @click="start_update_instance_name(index)">
|
<n-button size="tiny" @click="start_update_instance_name(index)">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<n-icon :component="Pencil"></n-icon>
|
<n-icon :component="Pencil"></n-icon>
|
||||||
</template>
|
</template>
|
||||||
</n-button>
|
</n-button>
|
||||||
<n-button @click="open_folder(item.path)" size="tiny">
|
|
||||||
<template #icon>
|
|
||||||
<n-icon :component="Folder"></n-icon>
|
|
||||||
</template>
|
|
||||||
</n-button>
|
|
||||||
</n-space>
|
</n-space>
|
||||||
<n-input
|
<n-input
|
||||||
v-else
|
v-else
|
||||||
|
class="instance_name_input"
|
||||||
:ref="(el) => setInstanceNameInputRef(el, index)"
|
:ref="(el) => setInstanceNameInputRef(el, index)"
|
||||||
v-model:value="item.name"
|
v-model:value="item.name"
|
||||||
@blur="end_update_instance_name"
|
@blur="end_update_instance_name"
|
||||||
|
clearable
|
||||||
></n-input>
|
></n-input>
|
||||||
</n-space>
|
</n-space>
|
||||||
<template #suffix>
|
<template #suffix>
|
||||||
<n-space :wrap="false">
|
<n-space :wrap="false">
|
||||||
<n-button type="primary" size="small" @click="start_instance(item)">
|
<n-button type="primary" ghost size="small" @click="cli('status', item)">
|
||||||
|
<template #icon>
|
||||||
|
<n-icon :component="Search"></n-icon>
|
||||||
|
</template>
|
||||||
|
</n-button>
|
||||||
|
<n-button type="primary" size="small" @click="cli('launch', item)">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<n-icon :component="Play"></n-icon>
|
<n-icon :component="Play"></n-icon>
|
||||||
</template>
|
</template>
|
||||||
</n-button>
|
</n-button>
|
||||||
|
<n-button type="primary" ghost size="small" @click="cli('webui', item)">
|
||||||
|
<template #icon>
|
||||||
|
<n-icon :component="Browsers"></n-icon>
|
||||||
|
</template>
|
||||||
|
</n-button>
|
||||||
|
<n-button type="error" ghost size="small" @click="cli('exit', item)">
|
||||||
|
<template #icon>
|
||||||
|
<n-icon :component="Stop"></n-icon>
|
||||||
|
</template>
|
||||||
|
</n-button>
|
||||||
|
<n-button type="primary" ghost size="small" @click="open_folder(item.path)">
|
||||||
|
<template #icon>
|
||||||
|
<n-icon :component="Folder"></n-icon>
|
||||||
|
</template>
|
||||||
|
</n-button>
|
||||||
<n-popconfirm @positive-click="delete_instance(index, item.path)">
|
<n-popconfirm @positive-click="delete_instance(index, item.path)">
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<n-button type="error" ghost size="small">
|
<n-button type="error" ghost size="small">
|
||||||
|
@ -221,9 +258,18 @@ async function handle_migrate(key) {
|
||||||
.launch-btn {
|
.launch-btn {
|
||||||
height: 38px;
|
height: 38px;
|
||||||
}
|
}
|
||||||
.instance-list {
|
.instance_list {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
.instance_list_item {
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
.instance_name {
|
||||||
|
margin-left: 12px;
|
||||||
|
}
|
||||||
|
.instance_name_input {
|
||||||
|
height: 35px;
|
||||||
|
}
|
||||||
.log {
|
.log {
|
||||||
min-height: 40vh;
|
min-height: 40vh;
|
||||||
max-height: 40vh;
|
max-height: 40vh;
|
||||||
|
@ -234,5 +280,6 @@ async function handle_migrate(key) {
|
||||||
}
|
}
|
||||||
.is_show_log_switch {
|
.is_show_log_switch {
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { SyncCircle } from '@vicons/ionicons5'
|
import { Sync } from '@vicons/ionicons5'
|
||||||
import { form_item_label_style } from '@/styles/styles.js'
|
import { form_item_label_style } from '@/styles/styles.js'
|
||||||
|
import BaseMirrorOption from '@/components/BaseMirrorOption.vue'
|
||||||
|
|
||||||
const notification = useNotification()
|
const notification = useNotification()
|
||||||
|
|
||||||
|
@ -58,17 +59,20 @@ async function check_update() {
|
||||||
<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-form label-placement="left" :show-feedback="false" label-width="auto" label-align="left">
|
<n-form label-placement="left" :show-feedback="false" label-width="auto" label-align="left">
|
||||||
|
<base-mirror-option />
|
||||||
<n-form-item label="版本" :label-style="form_item_label_style">
|
<n-form-item label="版本" :label-style="form_item_label_style">
|
||||||
<n-space align="center">
|
<n-space align="center">
|
||||||
{{ version }}
|
{{ version }}
|
||||||
<n-button
|
<n-button
|
||||||
type="success"
|
type="success"
|
||||||
|
secondary
|
||||||
|
size="small"
|
||||||
:loading="check_running"
|
:loading="check_running"
|
||||||
:disabled="running"
|
:disabled="running"
|
||||||
@click="check_update"
|
@click="check_update"
|
||||||
>
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<n-icon :component="SyncCircle"></n-icon>
|
<n-icon :component="Sync"></n-icon>
|
||||||
</template>
|
</template>
|
||||||
检查更新
|
检查更新
|
||||||
</n-button>
|
</n-button>
|
||||||
|
@ -77,11 +81,14 @@ async function check_update() {
|
||||||
<n-alert style="margin: 8px 0" type="success" v-if="update_able">
|
<n-alert style="margin: 8px 0" type="success" v-if="update_able">
|
||||||
<template #header>
|
<template #header>
|
||||||
最新版本:{{ `${new_version.tag_name} ${new_version.name}` }}
|
最新版本:{{ `${new_version.tag_name} ${new_version.name}` }}
|
||||||
<n-button style="float: right" @click="open_new_version_html">了解此版本</n-button>
|
<n-button type="success" secondary style="float: right" @click="open_new_version_html">
|
||||||
|
了解此版本
|
||||||
|
</n-button>
|
||||||
</template>
|
</template>
|
||||||
<n-space>
|
<n-space>
|
||||||
<n-button
|
<n-button
|
||||||
type="success"
|
type="success"
|
||||||
|
secondary
|
||||||
:loading="update_self_running"
|
:loading="update_self_running"
|
||||||
:disabled="running"
|
:disabled="running"
|
||||||
@click="update_self"
|
@click="update_self"
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useConfigStore } from '@/stores/config.js'
|
import { useConfigStore } from '@/stores/config.js'
|
||||||
import { form_item_label_style } from '@/styles/styles.js'
|
import { form_item_label_style } from '@/styles/styles.js'
|
||||||
|
import BaseMirrorOption from '@/components/BaseMirrorOption.vue'
|
||||||
|
|
||||||
const conf = useConfigStore().config
|
const conf = useConfigStore().config
|
||||||
const branch = ref(null)
|
const branch = ref(null)
|
||||||
const mirror = ref(null)
|
const mirror = ref(null)
|
||||||
|
const running = inject('running')
|
||||||
|
|
||||||
const steps = computed(() => [
|
const steps = computed(() => [
|
||||||
{
|
{
|
||||||
title: '更新源码',
|
title: '更新源码',
|
||||||
command: ['fetch', 'switch', 'reset'],
|
command: ['set_remote', 'set_lfs', 'fetch', 'switch', 'reset'],
|
||||||
cwd: 'mower-ng'
|
cwd: 'mower-ng'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -28,8 +30,9 @@ 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-form label-placement="left" :show-feedback="false" label-width="auto" label-align="left">
|
<n-form label-placement="left" :show-feedback="false" label-width="auto" label-align="left">
|
||||||
|
<base-mirror-option />
|
||||||
<n-form-item label="mower-ng 代码分支" :label-style="form_item_label_style">
|
<n-form-item label="mower-ng 代码分支" :label-style="form_item_label_style">
|
||||||
<n-radio-group v-model:value="conf.branch">
|
<n-radio-group v-model:value="conf.branch" :disabled="running">
|
||||||
<n-flex>
|
<n-flex>
|
||||||
<n-radio value="fast">测试版</n-radio>
|
<n-radio value="fast">测试版</n-radio>
|
||||||
<n-radio value="slow">稳定版</n-radio>
|
<n-radio value="slow">稳定版</n-radio>
|
||||||
|
@ -37,7 +40,7 @@ provide('current_state', current_state)
|
||||||
</n-radio-group>
|
</n-radio-group>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
<n-form-item label="PyPI 仓库镜像" :label-style="form_item_label_style">
|
<n-form-item label="PyPI 仓库镜像" :label-style="form_item_label_style">
|
||||||
<n-radio-group v-model:value="conf.mirror">
|
<n-radio-group v-model:value="conf.mirror" :disabled="running">
|
||||||
<n-flex>
|
<n-flex>
|
||||||
<n-radio value="pypi">PyPI</n-radio>
|
<n-radio value="pypi">PyPI</n-radio>
|
||||||
<n-radio value="aliyun">阿里云镜像站</n-radio>
|
<n-radio value="aliyun">阿里云镜像站</n-radio>
|
||||||
|
|
|
@ -20,6 +20,8 @@ export const useConfigStore = defineStore('config', () => {
|
||||||
// 启动程序 LaunchPart
|
// 启动程序 LaunchPart
|
||||||
this.instances = []
|
this.instances = []
|
||||||
this.is_show_log = conf.is_show_log
|
this.is_show_log = conf.is_show_log
|
||||||
|
// 其他部分 OtherPart
|
||||||
|
this.base_mirror = conf.base_mirror
|
||||||
Object.assign(this, conf)
|
Object.assign(this, conf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue