refactor(代码生成器): 优化模板文件格式和类型检查逻辑

style: 统一代码格式并移除多余空行
fix(前端): 修复富文本编辑器在详情页的显示问题
feat(前端): 为代码编辑器添加主题切换功能
docs: 更新README中的命令说明
This commit is contained in:
zhangtao
2025-11-19 23:22:13 +08:00
parent fb48b9ea1f
commit 8712831e45
12 changed files with 177 additions and 154 deletions
@@ -856,7 +856,8 @@ defineOptions({
import "codemirror/mode/javascript/javascript.js";
import "codemirror/mode/sql/sql.js";
import { ref, reactive, computed, onActivated, onMounted } from "vue";
import "codemirror/theme/dracula.css"
import { ref, reactive, computed, onActivated, onMounted, watch } from "vue";
import { useClipboard } from "@vueuse/core";
import { useRoute } from "vue-router";
import Codemirror from "codemirror-editor-vue3";
@@ -883,6 +884,8 @@ import MenuAPI, { MenuTable } from "@/api/module_system/menu";
import DictAPI, { DictTable } from "@/api/module_system/dict";
import { formatTree } from "@/utils/common";
import { MenuTypeEnum } from "@/enums";
import { useSettingsStore } from "@/store";
import { ThemeMode } from "@/enums/settings/theme.enum";
// 表格列配置接口
interface TableColumn {
@@ -995,6 +998,27 @@ const tableColumns = ref<TableColumn[]>([
{ prop: "operation", label: "操作", show: true },
]);
const settingsStore = useSettingsStore();
// 主题计算属性
const codeTheme = computed(() =>
settingsStore.theme === ThemeMode.DARK ? "dracula" : "default"
);
// 监听主题变化并更新CodeMirror实例
watch(codeTheme, (newTheme) => {
// 更新SQL编辑器主题
if (sqlRef.value && sqlRef.value.cminstance) {
sqlRef.value.cminstance.setOption("theme", newTheme);
}
// 更新代码预览编辑器主题
if (cmRef.value && cmRef.value.cminstance) {
cmRef.value.cminstance.setOption("theme", newTheme);
}
});
// CodeMirror配置
const cmOptions: EditorConfiguration = {
mode: "text/javascript",
@@ -1002,7 +1026,10 @@ const cmOptions: EditorConfiguration = {
smartIndent: true,
indentUnit: 2,
tabSize: 2,
readOnly: true,
readOnly: false,
theme: codeTheme.value,
lineWrapping: true,
autofocus: false,
};
const sqlOptions: EditorConfiguration = {
@@ -1012,8 +1039,9 @@ const sqlOptions: EditorConfiguration = {
indentUnit: 2,
tabSize: 2,
readOnly: false,
theme: "default",
theme: codeTheme.value,
lineWrapping: true,
autofocus: false,
};
// 工具函数
@@ -349,7 +349,7 @@
>
<!-- 详情 -->
<template v-if="dialogVisible.type === 'detail'">
<el-descriptions :column="4" border>
<el-descriptions :column="4" border label-width="120px">
<el-descriptions-item label="标题" :span="2">
{{ detailFormData.notice_title }}
</el-descriptions-item>
@@ -368,12 +368,12 @@
{{ detailFormData.status ? "启用" : "停用" }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="内容" :span="2">
{{ detailFormData.notice_content }}
</el-descriptions-item>
<el-descriptions-item label="描述" :span="2">
{{ detailFormData.description }}
</el-descriptions-item>
<el-descriptions-item label="内容" :span="4">
<WangEditor v-model="detailFormData.notice_content" :readonly="true" />
</el-descriptions-item>
<el-descriptions-item label="创建人" :span="2">
{{ detailFormData.creator?.name }}
</el-descriptions-item>