参考mower的conf配置

This commit is contained in:
li-xiaochen 2024-12-02 22:34:54 +08:00
parent 01c4bee95e
commit 3aad1fe8ff
11 changed files with 199 additions and 67 deletions

View file

@ -5,16 +5,12 @@ import Update from '@/pages/Update.vue'
import Fix from '@/pages/Fix.vue'
import { dateZhCN, zhCN } from 'naive-ui'
import Settings from '@/pages/Settings.vue'
import { useConfigStore } from '@/stores/config.js'
const configStore = useConfigStore()
const loading = ref(true)
const page = ref(null)
function load_config() {
pywebview.api.get_page().then((value) => {
page.value = value
loading.value = false
})
}
let conf
async function init_version() {
version.value = await pywebview.api.get_version()
@ -23,6 +19,12 @@ async function init_version() {
update_able.value = true
}
}
async function initialize_config() {
await configStore.load_config()
conf = configStore.config
await init_version()
loading.value = false
}
const log = ref('')
provide('log', log)
@ -36,12 +38,10 @@ watch(log, () => {
onMounted(() => {
if (window.pywebview && pywebview.api) {
load_config()
init_version()
initialize_config()
} else {
window.addEventListener('pywebviewready', () => {
load_config()
init_version()
initialize_config()
})
}
window.addEventListener('log', (e) => {
@ -51,7 +51,6 @@ onMounted(() => {
function set_page(value) {
log.value = ''
pywebview.api.set_page(value)
}
const running = ref(false)
@ -80,7 +79,7 @@ provide('new_version', new_version)
type="card"
placement="left"
class="container"
:default-value="page"
v-model:value="conf.page"
@update:value="set_page"
>
<n-tab-pane :disabled="running" name="init" tab="初始化"><init /></n-tab-pane>