11<template>
22 <DrawerPro v-model="open" :header="$t('website.defaultHtml')" @close="handleClose" size="normal">
3- <el-select v-model="type" class="w-full" @change="get()" v-loading="loading">
3+ <el-select v-model="req. type" class="w-full" @change="get()" v-loading="loading">
44 <el-option :value="'404'" :label="$t('website.website404')"></el-option>
55 <el-option :value="'domain404'" :label="$t('website.domain404')"></el-option>
66 <el-option :value="'index'" :label="$t('website.indexHtml')"></el-option>
77 <el-option :value="'php'" :label="$t('website.indexPHP')"></el-option>
88 <el-option :value="'stop'" :label="$t('website.stopHtml')"></el-option>
99 </el-select>
1010 <div class="mt-1.5">
11- <el-text v-if="type == '404'" type="info">
11+ <el-text v-if="req. type == '404'" type="info">
1212 {{ $t('website.website404Helper') }}
1313 </el-text>
1414 </div>
15+ <div class="mt-1.5">
16+ <el-checkbox v-model="req.sync">{{ $t('同步到 PHP 和静态网站') }}</el-checkbox>
17+ </div>
1518 <div ref="htmlRef" class="default-html"></div>
19+
1620 <template #footer>
1721 <span class="dialog-footer">
1822 <el-button @click="handleClose" :disabled="loading">{{ $t('commons.button.cancel') }}</el-button>
@@ -37,12 +41,15 @@ import { oneDark } from '@codemirror/theme-one-dark';
3741let open = ref(false);
3842let loading = ref(false);
3943const content = ref('');
40- const type = ref('404');
4144const view = ref();
4245const htmlRef = ref();
46+ const req = reactive({
47+ type: '404',
48+ sync: false,
49+ });
4350
4451const acceptParams = () => {
45- type.value = '404';
52+ req.type = '404';
4653 get();
4754 open.value = true;
4855};
@@ -52,7 +59,7 @@ const handleClose = () => {
5259};
5360
5461const get = async () => {
55- const res = await getDefaultHtml(type.value );
62+ const res = await getDefaultHtml(req.type );
5663 content.value = res.data.content;
5764 initEditor();
5865};
@@ -62,7 +69,7 @@ const initEditor = () => {
6269 view.value.destroy();
6370 }
6471 let extensions = [basicSetup, oneDark];
65- if (type.value === 'php') {
72+ if (req.type === 'php') {
6673 extensions.push(php());
6774 } else {
6875 extensions.push(html());
@@ -83,7 +90,7 @@ const submit = async () => {
8390 loading.value = true;
8491 try {
8592 const content = view.value.state.doc.toString();
86- await updateDefaultHtml({ type: type.value , content: content });
93+ await updateDefaultHtml({ type: req.type , content: content, sync: req.sync });
8794 MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
8895 } catch (error) {
8996 } finally {
@@ -97,6 +104,5 @@ defineExpose({ acceptParams });
97104.default-html {
98105 width: 100%;
99106 min-height: 300px;
100- margin-top: 10px;
101107}
102108</style>
0 commit comments