| | |
| | | |
| | | <div class="editor-wrap" v-loading="loading"> |
| | | <Toolbar |
| | | :key="`toolbar-${activeTab}`" |
| | | class="w-toolbar" |
| | | :editor="editorRef" |
| | | :default-config="toolbarConfig" |
| | | mode="default" |
| | | /> |
| | | <Editor |
| | | :key="`editor-${activeTab}`" |
| | | v-model="currentHtml" |
| | | class="w-editor" |
| | | :default-config="editorConfig" |
| | |
| | | <script setup lang="ts"> |
| | | import "@wangeditor/editor/dist/css/style.css"; |
| | | import { Editor, Toolbar } from "@wangeditor/editor-for-vue"; |
| | | import { computed, nextTick, onBeforeUnmount, onMounted, shallowRef, ref } from "vue"; |
| | | import { computed, nextTick, onBeforeUnmount, onMounted, shallowRef, ref, watch } from "vue"; |
| | | import { ElMessage } from "element-plus"; |
| | | import http from "../api/http"; |
| | | import type { IEditorConfig } from "@wangeditor/editor"; |
| | |
| | | editorRef.value = editor as never; |
| | | } |
| | | |
| | | watch(activeTab, async () => { |
| | | editorRef.value = undefined; |
| | | await nextTick(); |
| | | }); |
| | | |
| | | async function load() { |
| | | loading.value = true; |
| | | try { |
| | |
| | | parkFlowHtml: form.value.parkFlowHtml, |
| | | aboutUsEnabled: form.value.aboutUsEnabled, |
| | | }); |
| | | await load(); |
| | | ElMessage.success("已保存"); |
| | | } catch (e: unknown) { |
| | | ElMessage.error(e instanceof Error ? e.message : "保存失败"); |