kuaifan a34b0c88d5 refactor: 优化 webTab 管理和状态同步
- 封装 safeCloseWebTab 方法,复用标签关闭时的未保存数据检查逻辑
  - 添加 recreatePreloadPool,支持主题切换后重建预加载池
  - broadcastCommand 扩展到 webTab views,确保子窗口收到同步消息
  - 修复 synchTheme 和 saveDialogDraft 的跨窗口参数传递
  - IDBDel 返回 Promise 并正确 await
2026-01-14 10:11:41 +08:00

71 lines
1.9 KiB
Vue

<template>
<div class="setting-item submit">
<Form ref="formData" :model="formData" :rules="ruleData" v-bind="formOptions" @submit.native.prevent>
<FormItem :label="$L('选择主题')" prop="theme">
<Select v-model="formData.theme" :placeholder="$L('选项主题')">
<Option v-for="(item, index) in themeList" :value="item.value" :key="index">{{$L(item.name)}}</Option>
</Select>
</FormItem>
</Form>
<div class="setting-footer">
<Button :loading="loadIng > 0" type="primary" @click="submitForm">{{$L('提交')}}</Button>
<Button :loading="loadIng > 0" @click="resetForm" style="margin-left: 8px">{{$L('重置')}}</Button>
</div>
</div>
</template>
<script>
import {mapState} from "vuex";
export default {
data() {
return {
loadIng: 0,
formData: {
theme: '',
},
ruleData: { },
}
},
mounted() {
this.initData();
},
computed: {
...mapState([
'themeConf',
'themeList',
'formOptions'
])
},
methods: {
initData() {
this.$set(this.formData, 'theme', this.themeConf);
this.formData_bak = $A.cloneJSON(this.formData);
},
submitForm() {
this.$refs.formData.validate((valid) => {
if (valid) {
this.$store.dispatch("setTheme", this.formData.theme).then(res => {
if (!res) {
return
}
$A.messageSuccess('保存成功');
$A.Electron?.sendMessage('recreatePreloadPool');
})
}
})
},
resetForm() {
this.formData = $A.cloneJSON(this.formData_bak);
}
}
}
</script>