Compare commits
4 commits
Author | SHA1 | Date | |
---|---|---|---|
fcdaa529cd | |||
717df6588a | |||
fb8ab18fc5 | |||
06fab427aa |
9 changed files with 152 additions and 113 deletions
|
@ -29,6 +29,7 @@ mirror_list = {
|
||||||
"aliyun": "https://mirrors.aliyun.com/pypi/simple/",
|
"aliyun": "https://mirrors.aliyun.com/pypi/simple/",
|
||||||
"tuna": "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple",
|
"tuna": "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple",
|
||||||
"sjtu": "https://mirror.sjtu.edu.cn/pypi/web/simple",
|
"sjtu": "https://mirror.sjtu.edu.cn/pypi/web/simple",
|
||||||
|
"ustc": "https://mirrors.ustc.edu.cn/pypi/simple",
|
||||||
}
|
}
|
||||||
|
|
||||||
# 实例文件夹名
|
# 实例文件夹名
|
||||||
|
|
|
@ -89,7 +89,6 @@ provide('new_version', new_version)
|
||||||
<n-spin v-if="loading" class="container">
|
<n-spin v-if="loading" class="container">
|
||||||
<template #description>加载中</template>
|
<template #description>加载中</template>
|
||||||
</n-spin>
|
</n-spin>
|
||||||
<n-notification-provider v-else>
|
|
||||||
<n-tabs
|
<n-tabs
|
||||||
type="card"
|
type="card"
|
||||||
placement="left"
|
placement="left"
|
||||||
|
@ -97,6 +96,7 @@ provide('new_version', new_version)
|
||||||
v-model:value="conf.page"
|
v-model:value="conf.page"
|
||||||
@update:value="set_page"
|
@update:value="set_page"
|
||||||
justify-content="center"
|
justify-content="center"
|
||||||
|
v-else
|
||||||
>
|
>
|
||||||
<n-tab-pane :disabled="running" name="init" tab="初始化"><init /></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="update" tab="更新代码"><update /></n-tab-pane>
|
||||||
|
@ -117,7 +117,6 @@ provide('new_version', new_version)
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</n-tabs>
|
</n-tabs>
|
||||||
</n-notification-provider>
|
|
||||||
<n-global-style />
|
<n-global-style />
|
||||||
</n-config-provider>
|
</n-config-provider>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import PlayIcon from '@vicons/ionicons5/Play'
|
import PlayIcon from '@vicons/ionicons5/Play'
|
||||||
import { inject } from 'vue'
|
import { inject } from 'vue'
|
||||||
|
import { notify } from '@/utils/naiveDiscrete.js'
|
||||||
|
|
||||||
const running = inject('running')
|
const running = inject('running')
|
||||||
const log = inject('log')
|
const log = inject('log')
|
||||||
|
@ -8,8 +9,6 @@ const steps = inject('steps')
|
||||||
const current_step = inject('current_step')
|
const current_step = inject('current_step')
|
||||||
const current_state = inject('current_state')
|
const current_state = inject('current_state')
|
||||||
|
|
||||||
const notification = useNotification()
|
|
||||||
|
|
||||||
async function start() {
|
async function start() {
|
||||||
log.value = []
|
log.value = []
|
||||||
running.value = true
|
running.value = true
|
||||||
|
@ -20,22 +19,14 @@ async function start() {
|
||||||
if ((await pywebview.api.run(cmd, step.cwd)) == 'failed') {
|
if ((await pywebview.api.run(cmd, step.cwd)) == 'failed') {
|
||||||
current_state.value = 'error'
|
current_state.value = 'error'
|
||||||
running.value = false
|
running.value = false
|
||||||
notification['error']({
|
notify.error('命令运行失败')
|
||||||
content: '错误',
|
|
||||||
meta: '命令运行失败',
|
|
||||||
duration: 3000
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
current_state.value = 'finish'
|
current_state.value = 'finish'
|
||||||
running.value = false
|
running.value = false
|
||||||
notification['info']({
|
notify.info('命令运行完成')
|
||||||
content: '提示',
|
|
||||||
meta: '命令运行完成',
|
|
||||||
duration: 3000
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -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,26 +1,15 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { notify } from '@/utils/naiveDiscrete.js'
|
||||||
|
|
||||||
const running = inject('running')
|
const running = inject('running')
|
||||||
const notification = useNotification()
|
|
||||||
|
|
||||||
async function rm_site_packages_and_python_scripts() {
|
async function rm_site_packages_and_python_scripts() {
|
||||||
running.value = true
|
running.value = true
|
||||||
notification['info']({
|
notify.info('开始移除site-packages和python/Script目录')
|
||||||
content: '提示',
|
|
||||||
meta: '开始移除site-packages和python/Script目录',
|
|
||||||
duration: 3000
|
|
||||||
})
|
|
||||||
const response = await pywebview.api.rm_site_packages()
|
const response = await pywebview.api.rm_site_packages()
|
||||||
notification['info']({
|
notify.info(response)
|
||||||
content: '提示',
|
|
||||||
meta: response,
|
|
||||||
duration: 3000
|
|
||||||
})
|
|
||||||
const response2 = await pywebview.api.rm_python_scripts()
|
const response2 = await pywebview.api.rm_python_scripts()
|
||||||
notification['info']({
|
notify.info(response2)
|
||||||
content: '提示',
|
|
||||||
meta: response2,
|
|
||||||
duration: 3000
|
|
||||||
})
|
|
||||||
running.value = false
|
running.value = false
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -12,8 +12,7 @@ import {
|
||||||
Stop,
|
Stop,
|
||||||
Search
|
Search
|
||||||
} from '@vicons/ionicons5'
|
} from '@vicons/ionicons5'
|
||||||
|
import { notify } from '@/utils/naiveDiscrete.js'
|
||||||
const notification = useNotification()
|
|
||||||
|
|
||||||
const config_store = useConfigStore()
|
const config_store = useConfigStore()
|
||||||
const conf = config_store.config
|
const conf = config_store.config
|
||||||
|
@ -90,17 +89,9 @@ async function handle_migrate(key) {
|
||||||
name: '默认实例',
|
name: '默认实例',
|
||||||
path: response.data
|
path: response.data
|
||||||
})
|
})
|
||||||
notification['success']({
|
notify.success(response.message)
|
||||||
content: '信息',
|
|
||||||
meta: response.message,
|
|
||||||
duration: 3000
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
notification['error']({
|
notify.error(response.message)
|
||||||
content: '错误',
|
|
||||||
meta: response.message,
|
|
||||||
duration: 3000
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const response = await pywebview.api.migrate_instances_config()
|
const response = await pywebview.api.migrate_instances_config()
|
||||||
|
@ -110,17 +101,9 @@ async function handle_migrate(key) {
|
||||||
conf.instances = [...config_store.config.instances]
|
conf.instances = [...config_store.config.instances]
|
||||||
}
|
}
|
||||||
if (response.status) {
|
if (response.status) {
|
||||||
notification['info']({
|
notify.info(response.message)
|
||||||
title: '信息',
|
|
||||||
content: response.message,
|
|
||||||
duration: 3000
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
notification['error']({
|
notify.error(response.message)
|
||||||
title: '错误',
|
|
||||||
content: response.message,
|
|
||||||
duration: 3000
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,8 +158,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"
|
||||||
|
@ -187,29 +170,26 @@ 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>
|
||||||
|
@ -234,6 +214,11 @@ async function handle_migrate(key) {
|
||||||
<n-icon :component="Stop"></n-icon>
|
<n-icon :component="Stop"></n-icon>
|
||||||
</template>
|
</template>
|
||||||
</n-button>
|
</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">
|
||||||
|
@ -256,9 +241,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;
|
||||||
|
@ -269,5 +263,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>
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
import { Sync } 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'
|
import BaseMirrorOption from '@/components/BaseMirrorOption.vue'
|
||||||
|
import { notify } from '@/utils/naiveDiscrete.js'
|
||||||
const notification = useNotification()
|
|
||||||
|
|
||||||
const update_able = inject('update_able')
|
const update_able = inject('update_able')
|
||||||
const running = inject('running')
|
const running = inject('running')
|
||||||
|
@ -19,11 +18,7 @@ async function update_self() {
|
||||||
const response = await pywebview.api.update_self(
|
const response = await pywebview.api.update_self(
|
||||||
new_version.value['assets'][0]['browser_download_url']
|
new_version.value['assets'][0]['browser_download_url']
|
||||||
)
|
)
|
||||||
notification['error']({
|
notify.error(response)
|
||||||
content: '错误',
|
|
||||||
meta: response,
|
|
||||||
duration: 3000
|
|
||||||
})
|
|
||||||
update_self_running.value = false
|
update_self_running.value = false
|
||||||
running.value = false
|
running.value = false
|
||||||
}
|
}
|
||||||
|
@ -38,18 +33,10 @@ async function check_update() {
|
||||||
new_version.value = await pywebview.api.get_new_version()
|
new_version.value = await pywebview.api.get_new_version()
|
||||||
if (new_version.value.tag_name > version.value) {
|
if (new_version.value.tag_name > version.value) {
|
||||||
update_able.value = true
|
update_able.value = true
|
||||||
notification['info']({
|
notify.info('有新版本可更新')
|
||||||
content: '提示',
|
|
||||||
meta: '有新版本可更新',
|
|
||||||
duration: 3000
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
update_able.value = false
|
update_able.value = false
|
||||||
notification['info']({
|
notify.info('当前已是最新版本')
|
||||||
content: '提示',
|
|
||||||
meta: '当前已是最新版本',
|
|
||||||
duration: 3000
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
check_running.value = false
|
check_running.value = false
|
||||||
running.value = false
|
running.value = false
|
||||||
|
|
|
@ -20,6 +20,28 @@ const steps = computed(() => [
|
||||||
cwd: 'mower-ng'
|
cwd: 'mower-ng'
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
const mirror_options = [
|
||||||
|
{
|
||||||
|
label: 'PyPI',
|
||||||
|
value: 'pypi'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '阿里云镜像源',
|
||||||
|
value: 'aliyun'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '上海交通大学镜像源',
|
||||||
|
value: 'sjtu'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '清华大学镜像源',
|
||||||
|
value: 'tuna'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '中国科学技术大学镜像源',
|
||||||
|
value: 'ustc'
|
||||||
|
}
|
||||||
|
]
|
||||||
provide('steps', steps)
|
provide('steps', steps)
|
||||||
const current_step = ref(1)
|
const current_step = ref(1)
|
||||||
provide('current_step', current_step)
|
provide('current_step', current_step)
|
||||||
|
@ -40,14 +62,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" :disabled="running">
|
<n-select v-model:value="conf.mirror" :options="mirror_options" :disabled="running" />
|
||||||
<n-flex>
|
|
||||||
<n-radio value="pypi">PyPI</n-radio>
|
|
||||||
<n-radio value="aliyun">阿里云镜像站</n-radio>
|
|
||||||
<n-radio value="sjtu">上海交通大学镜像站</n-radio>
|
|
||||||
<n-radio value="tuna">清华大学镜像站</n-radio>
|
|
||||||
</n-flex>
|
|
||||||
</n-radio-group>
|
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
</n-form>
|
</n-form>
|
||||||
<n-steps :current="current_step" :status="current_state" size="small">
|
<n-steps :current="current_step" :status="current_state" size="small">
|
||||||
|
|
63
ui/src/utils/naiveDiscrete.js
Normal file
63
ui/src/utils/naiveDiscrete.js
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
import { createDiscreteApi, darkTheme, lightTheme } from 'naive-ui'
|
||||||
|
|
||||||
|
// 创建全局单例
|
||||||
|
const { message, dialog, notification, loadingBar } = createDiscreteApi(
|
||||||
|
['message', 'dialog', 'notification', 'loadingBar'],
|
||||||
|
{
|
||||||
|
configProviderProps: {
|
||||||
|
// 全局主题配置(示例使用系统主题)
|
||||||
|
theme: window.matchMedia('(prefers-color-scheme: dark)').matches ? darkTheme : lightTheme
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// 创建统一的工厂函数
|
||||||
|
const createMessager =
|
||||||
|
(handler, defaults) =>
|
||||||
|
(content, options = {}) => {
|
||||||
|
const mergedOptions =
|
||||||
|
typeof content === 'string'
|
||||||
|
? { content, ...defaults, ...options }
|
||||||
|
: { ...defaults, ...content, ...options }
|
||||||
|
|
||||||
|
return handler(mergedOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 消息提示封装
|
||||||
|
export const toast = {
|
||||||
|
info: createMessager((opts) => message.info(opts.content, opts), { duration: 3000 }),
|
||||||
|
|
||||||
|
success: createMessager((opts) => message.success(opts.content, opts), { duration: 3000 }),
|
||||||
|
|
||||||
|
warning: createMessager((opts) => message.warning(opts.content, opts), { duration: 5000 }),
|
||||||
|
|
||||||
|
error: createMessager((opts) => message.error(opts.content, opts), { duration: 7000 })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通知封装
|
||||||
|
export const notify = {
|
||||||
|
info: createMessager(notification.info, { title: '提示', duration: 3000 }),
|
||||||
|
|
||||||
|
success: createMessager(notification.success, { title: '成功', duration: 3000 }),
|
||||||
|
|
||||||
|
warning: createMessager(notification.warning, { title: '警告', duration: 5000 }),
|
||||||
|
|
||||||
|
error: createMessager(notification.error, { title: '错误', duration: 7000 })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 对话框封装
|
||||||
|
export const modal = {
|
||||||
|
info: (options) => dialog.info(options),
|
||||||
|
success: (options) => dialog.success(options),
|
||||||
|
warning: (options) => dialog.warning(options),
|
||||||
|
error: (options) => dialog.error(options),
|
||||||
|
confirm: (options) => dialog.confirm(options)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载条控制器
|
||||||
|
export const loader = {
|
||||||
|
start: () => loadingBar.start(),
|
||||||
|
finish: () => loadingBar.finish(),
|
||||||
|
error: () => loadingBar.error(),
|
||||||
|
setProgress: (progress) => loadingBar.setProgress(progress)
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue