diff --git a/package.json b/package.json index 51d77fe..b1ad447 100644 --- a/package.json +++ b/package.json @@ -36,20 +36,20 @@ "@vueuse/motion": "^2.0.0", "animate.css": "^4.1.1", "axios": "^1.4.0", + "cropperjs": "^1.5.13", "crypto-js": "^4.1.1", "dayjs": "^1.11.8", "echarts": "^5.4.2", "element-plus": "2.3.6", "js-cookie": "^3.0.5", "jsencrypt": "^3.3.2", + "jszip": "^3.10.1", "mitt": "^3.0.0", "mockjs": "^1.1.0", "nprogress": "^0.2.0", "path": "^0.12.7", "pinia": "^2.1.4", "pinyin-pro": "^3.15.2", - "cropperjs": "^1.5.13", - "vue-tippy": "^6.2.0", "qrcode": "^1.5.3", "qs": "^6.11.2", "responsive-storage": "^2.2.0", @@ -57,6 +57,7 @@ "typeit": "^8.7.1", "vue": "^3.3.4", "vue-router": "^4.2.2", + "vue-tippy": "^6.2.0", "vue-types": "^5.1.0", "xlsx": "^0.18.5" }, diff --git a/src/views/system/codegen/components/CodeEditor.vue b/src/views/system/codegen/components/CodeEditor.vue index e2a2b1e..a4c0b11 100644 --- a/src/views/system/codegen/components/CodeEditor.vue +++ b/src/views/system/codegen/components/CodeEditor.vue @@ -32,13 +32,15 @@ const updateValue = (value: string) => { const updateLineNumbers = (content: string) => { const lines = content.split("\n"); - lineNumbers.value = lines.map((_, index) => String(index + 1).padStart(3, " ")); + lineNumbers.value = lines.map((_, index) => + String(index + 1).padStart(3, " ") + ); }; // 监听内容变化,更新行号 watch( () => props.modelValue, - (newValue) => { + newValue => { updateLineNumbers(newValue); }, { immediate: true } @@ -47,7 +49,9 @@ watch( // 同步滚动 const handleScroll = (event: Event) => { const textarea = event.target as HTMLTextAreaElement; - const lineNumbersEl = textarea.parentElement?.querySelector(".line-numbers") as HTMLElement; + const lineNumbersEl = textarea.parentElement?.querySelector( + ".line-numbers" + ) as HTMLElement; if (lineNumbersEl) { lineNumbersEl.scrollTop = textarea.scrollTop; } @@ -74,12 +78,12 @@ const handleKeydown = (event: KeyboardEvent) => { // 计算动态高度 const dynamicHeight = computed(() => { if (props.readonly && props.modelValue) { - const lines = props.modelValue.split('\n').length; + const lines = props.modelValue.split("\n").length; const lineHeight = 19.5; // 匹配CSS中的line-height const padding = 16; // top + bottom padding const minHeight = 200; const calculatedHeight = lines * lineHeight + padding; - return Math.max(calculatedHeight, minHeight) + 'px'; + return Math.max(calculatedHeight, minHeight) + "px"; } return props.height; }); @@ -135,7 +139,7 @@ const dynamicHeight = computed(() => { background: var(--el-bg-color-page); border-right: 1px solid var(--el-border-color-lighter); padding: 8px 4px; - font-family: 'Consolas', 'Monaco', 'Courier New', monospace; + font-family: "Consolas", "Monaco", "Courier New", monospace; font-size: 13px; line-height: 1.5; color: var(--el-text-color-secondary); @@ -167,7 +171,7 @@ const dynamicHeight = computed(() => { outline: none; resize: none; padding: 8px 12px; - font-family: 'Consolas', 'Monaco', 'Courier New', monospace; + font-family: "Consolas", "Monaco", "Courier New", monospace; font-size: 13px; line-height: 1.5; background: transparent; diff --git a/src/views/system/codegen/components/ConfigForm.vue b/src/views/system/codegen/components/ConfigForm.vue index 3a89866..b9347b6 100644 --- a/src/views/system/codegen/components/ConfigForm.vue +++ b/src/views/system/codegen/components/ConfigForm.vue @@ -25,7 +25,12 @@ const updateValue = (key: keyof CodegenOptions, value: any) => { // 配置分组 const basicConfig = [ - { key: "dataType", label: "解析引擎", type: "select", options: "dataTypeOptions" }, + { + key: "dataType", + label: "解析引擎", + type: "select", + options: "dataTypeOptions" + }, { key: "authorName", label: "作者", type: "input" }, { key: "packageName", label: "包名", type: "input" } ]; @@ -37,9 +42,24 @@ const returnConfig = [ ]; const typeConfig = [ - { key: "tinyintTransType", label: "TinyInt转换", type: "select", options: "tinyintTransTypeOptions" }, - { key: "timeTransType", label: "时间类型", type: "select", options: "timeTransTypeOptions" }, - { key: "nameCaseType", label: "命名类型", type: "select", options: "nameCaseTypeOptions" } + { + key: "tinyintTransType", + label: "TinyInt转换", + type: "select", + options: "tinyintTransTypeOptions" + }, + { + key: "timeTransType", + label: "时间类型", + type: "select", + options: "timeTransTypeOptions" + }, + { + key: "nameCaseType", + label: "命名类型", + type: "select", + options: "nameCaseTypeOptions" + } ]; const switchConfig = [ @@ -67,7 +87,7 @@ const switchConfig = [ v-if="config.type === 'select'" :model-value="modelValue[config.key]" class="w-full" - @update:model-value="(val) => updateValue(config.key, val)" + @update:model-value="val => updateValue(config.key, val)" > @@ -96,7 +116,7 @@ const switchConfig = [ > @@ -114,7 +134,7 @@ const switchConfig = [ @@ -165,14 +185,18 @@ const switchConfig = [ padding-left: 12px; &::before { - content: ''; + content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 4px; height: 16px; - background: linear-gradient(135deg, var(--el-color-primary) 0%, var(--el-color-primary-light-3) 100%); + background: linear-gradient( + 135deg, + var(--el-color-primary) 0%, + var(--el-color-primary-light-3) 100% + ); border-radius: 2px; } } @@ -203,7 +227,8 @@ const switchConfig = [ font-size: 14px; } - .el-input, .el-select { + .el-input, + .el-select { .el-input__wrapper { border-radius: 8px; transition: all 0.2s ease; @@ -234,7 +259,11 @@ const switchConfig = [ align-items: center; justify-content: space-between; padding: 12px 16px; - background: linear-gradient(135deg, var(--el-bg-color) 0%, var(--el-bg-color-page) 100%); + background: linear-gradient( + 135deg, + var(--el-bg-color) 0%, + var(--el-bg-color-page) 100% + ); border-radius: 8px; border: 1px solid var(--el-border-color-lighter); transition: all 0.3s ease; @@ -242,13 +271,17 @@ const switchConfig = [ overflow: hidden; &::before { - content: ''; + content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; - background: linear-gradient(90deg, var(--el-color-primary-light-8) 0%, var(--el-color-primary-light-6) 100%); + background: linear-gradient( + 90deg, + var(--el-color-primary-light-8) 0%, + var(--el-color-primary-light-6) 100% + ); transform: scaleX(0); transform-origin: left; transition: transform 0.3s ease; diff --git a/src/views/system/codegen/index.vue b/src/views/system/codegen/index.vue index 5869498..9612738 100644 --- a/src/views/system/codegen/index.vue +++ b/src/views/system/codegen/index.vue @@ -8,6 +8,8 @@ import CodeEditor from "./components/CodeEditor.vue"; import Play from "@iconify-icons/ep/caret-right"; import CopyDocument from "@iconify-icons/ep/document-copy"; +import Download from "@iconify-icons/ep/download"; +import FolderOpened from "@iconify-icons/ep/folder-opened"; import ArrowDown from "@iconify-icons/ep/arrow-down"; import ArrowUp from "@iconify-icons/ep/arrow-up"; @@ -33,6 +35,8 @@ const { setOutputModel, generateCode, copyCode, + downloadCurrentCode, + downloadAllCode, switchHistoricalData } = useCodegen(); @@ -52,8 +56,12 @@ onMounted(() => {
-

- +

+ 代码生成器

@@ -64,10 +72,16 @@ onMounted(() => {