From 044db122241a7c61544b97ec282b08abc961e9b3 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 9 Sep 2025 22:58:58 +0800 Subject: [PATCH] =?UTF-8?q?reactor=EF=BC=9A=E3=80=90infra=20=E5=9F=BA?= =?UTF-8?q?=E7=A1=80=E8=AE=BE=E6=96=BD=E3=80=91codegen=20=E8=BF=9B?= =?UTF-8?q?=E4=B8=80=E6=AD=A5=E7=BB=9F=E4=B8=80=E4=BB=A3=E7=A0=81=E9=A3=8E?= =?UTF-8?q?=E6=A0=BC=EF=BC=8850%=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/api/infra/codegen/index.ts | 4 +- .../src/views/infra/codegen/edit/index.vue | 10 +-- .../src/views/infra/codegen/index.vue | 17 ++-- .../infra/codegen/modules/column-info.vue | 1 + .../infra/codegen/modules/import-table.vue | 10 +-- .../infra/codegen/modules/preview-code.vue | 16 ++-- apps/web-ele/src/views/infra/codegen/data.ts | 5 +- .../src/views/infra/codegen/edit/index.vue | 33 ++++---- .../web-ele/src/views/infra/codegen/index.vue | 1 + .../infra/codegen/modules/column-info.vue | 1 + .../infra/codegen/modules/import-table.vue | 1 + .../infra/codegen/modules/preview-code.vue | 78 +++++++++++-------- 12 files changed, 91 insertions(+), 86 deletions(-) diff --git a/apps/web-antd/src/api/infra/codegen/index.ts b/apps/web-antd/src/api/infra/codegen/index.ts index c72f3ff1b..c8dc90447 100644 --- a/apps/web-antd/src/api/infra/codegen/index.ts +++ b/apps/web-antd/src/api/infra/codegen/index.ts @@ -71,7 +71,7 @@ export namespace InfraCodegenApi { } /** 创建代码生成请求 */ - export interface CodegenCreateListReq { + export interface CodegenCreateListReqVO { dataSourceConfigId?: number; tableNames: string[]; } @@ -136,7 +136,7 @@ export function getSchemaTableList(params: any) { } /** 基于数据库的表结构,创建代码生成器的表定义 */ -export function createCodegenList(data: InfraCodegenApi.CodegenCreateListReq) { +export function createCodegenList(data: InfraCodegenApi.CodegenCreateListReqVO) { return requestClient.post('/infra/codegen/create-list', data); } diff --git a/apps/web-antd/src/views/infra/codegen/edit/index.vue b/apps/web-antd/src/views/infra/codegen/edit/index.vue index 35afb2463..371818c38 100644 --- a/apps/web-antd/src/views/infra/codegen/edit/index.vue +++ b/apps/web-antd/src/views/infra/codegen/edit/index.vue @@ -61,7 +61,7 @@ async function submitForm() { // 提交表单 const hideLoading = message.loading({ content: $t('ui.actionMessage.updating'), - key: 'action_process_msg', + duration: 0, }); try { // 拼接相关信息 @@ -73,10 +73,7 @@ async function submitForm() { columns, }); // 关闭并提示 - message.success({ - content: $t('ui.actionMessage.operationSuccess'), - key: 'action_key_msg', - }); + message.success($t('ui.actionMessage.operationSuccess')); close(); } catch (error) { console.error('保存失败', error); @@ -84,8 +81,9 @@ async function submitForm() { hideLoading(); } } -const tabs = useTabs(); + /** 返回列表 */ +const tabs = useTabs(); function close() { tabs.closeCurrentTab(); router.push('/infra/codegen'); diff --git a/apps/web-antd/src/views/infra/codegen/index.vue b/apps/web-antd/src/views/infra/codegen/index.vue index f33c52312..214957bce 100644 --- a/apps/web-antd/src/views/infra/codegen/index.vue +++ b/apps/web-antd/src/views/infra/codegen/index.vue @@ -73,7 +73,6 @@ async function handleDelete(row: InfraCodegenApi.CodegenTable) { const hideLoading = message.loading({ content: $t('ui.actionMessage.deleting', [row.tableName]), duration: 0, - key: 'action_process_msg', }); try { await deleteCodegenTable(row.id); @@ -98,7 +97,6 @@ async function handleDeleteBatch() { const hideLoading = message.loading({ content: $t('ui.actionMessage.deleting'), duration: 0, - key: 'action_process_msg', }); try { await deleteCodegenTableList(checkedIds.value); @@ -114,14 +112,11 @@ async function handleDeleteBatch() { async function handleSync(row: InfraCodegenApi.CodegenTable) { const hideLoading = message.loading({ content: $t('ui.actionMessage.updating', [row.tableName]), - key: 'action_key_msg', + duration: 0, }); try { await syncCodegenFromDB(row.id); - message.success({ - content: $t('ui.actionMessage.updateSuccess', [row.tableName]), - key: 'action_key_msg', - }); + message.success($t('ui.actionMessage.updateSuccess', [row.tableName])); onRefresh(); } finally { hideLoading(); @@ -132,7 +127,7 @@ async function handleSync(row: InfraCodegenApi.CodegenTable) { async function handleGenerate(row: InfraCodegenApi.CodegenTable) { const hideLoading = message.loading({ content: '正在生成代码...', - key: 'action_key_msg', + duration: 0, }); try { const res = await downloadCodegen(row.id); @@ -143,10 +138,7 @@ async function handleGenerate(row: InfraCodegenApi.CodegenTable) { link.download = `codegen-${row.className}.zip`; link.click(); window.URL.revokeObjectURL(url); - message.success({ - content: '代码生成成功', - key: 'action_key_msg', - }); + message.success('代码生成成功'); } finally { hideLoading(); } @@ -187,6 +179,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ }); /** 获取数据源配置列表 */ +// TODO @芋艿:这种场景的最佳实践; async function initDataSourceConfig() { try { dataSourceConfigList.value = await getDataSourceConfigList(); diff --git a/apps/web-antd/src/views/infra/codegen/modules/column-info.vue b/apps/web-antd/src/views/infra/codegen/modules/column-info.vue index a35530807..ed6fa27d4 100644 --- a/apps/web-antd/src/views/infra/codegen/modules/column-info.vue +++ b/apps/web-antd/src/views/infra/codegen/modules/column-info.vue @@ -25,6 +25,7 @@ const [Grid, gridApi] = useVbenVxeGrid({ keepSource: true, rowConfig: { keyField: 'id', + isHover: true, }, pagerConfig: { enabled: false, diff --git a/apps/web-antd/src/views/infra/codegen/modules/import-table.vue b/apps/web-antd/src/views/infra/codegen/modules/import-table.vue index cc16ac165..38a78bae2 100644 --- a/apps/web-antd/src/views/infra/codegen/modules/import-table.vue +++ b/apps/web-antd/src/views/infra/codegen/modules/import-table.vue @@ -21,7 +21,7 @@ const emit = defineEmits<{ (e: 'success'): void; }>(); -const formData = reactive({ +const formData = reactive({ dataSourceConfigId: 0, tableNames: [], // 已选择的表列表 }); @@ -53,6 +53,7 @@ const [Grid] = useVbenVxeGrid({ }, rowConfig: { keyField: 'name', + isHover: true, }, toolbarConfig: { enabled: false, @@ -96,17 +97,14 @@ const [Modal, modalApi] = useVbenModal({ // 2. 提交请求 const hideLoading = message.loading({ content: '导入中...', - key: 'action_key_msg', + duration: 0, }); try { await createCodegenList(formData); // 关闭并提示 await modalApi.close(); emit('success'); - message.success({ - content: $t('ui.actionMessage.operationSuccess'), - key: 'action_key_msg', - }); + message.success($t('ui.actionMessage.operationSuccess')); } finally { hideLoading(); modalApi.unlock(); diff --git a/apps/web-antd/src/views/infra/codegen/modules/preview-code.vue b/apps/web-antd/src/views/infra/codegen/modules/preview-code.vue index f26c58f47..a532530b9 100644 --- a/apps/web-antd/src/views/infra/codegen/modules/preview-code.vue +++ b/apps/web-antd/src/views/infra/codegen/modules/preview-code.vue @@ -86,19 +86,23 @@ async function copyCode() { /** 文件节点点击事件 */ function handleNodeClick(_: any[], e: any) { - if (!e.node.isLeaf) return; + if (!e.node.isLeaf) { + return; + } activeKey.value = e.node.key; const file = previewFiles.value.find((item) => { const list = activeKey.value.split('.'); - // 特殊处理-包合并 + // 特殊处理 - 包合并 if (list.length > 2) { const lang = list.pop(); return item.filePath === `${list.join('/')}.${lang}`; } return item.filePath === activeKey.value; }); - if (!file) return; + if (!file) { + return; + } const lang = file.filePath.split('.').pop() || ''; setCodeMap(activeKey.value, lang, file.code); @@ -119,7 +123,7 @@ function handleFiles(data: InfraCodegenApi.CodegenPreview[]): FileNode[] { const path = paths[cursor] || ''; const oldFullPath = fullPath; - // 处理Java包路径特殊情况 + // 处理 Java 包路径特殊情况 if (path === 'java' && cursor + 1 < paths.length) { fullPath = fullPath ? `${fullPath}/${path}` : path; cursor++; @@ -202,7 +206,9 @@ const [Modal, modalApi] = useVbenModal({ } const row = modalApi.getData(); - if (!row) return; + if (!row) { + return; + } // 加载预览数据 loading.value = true; diff --git a/apps/web-ele/src/views/infra/codegen/data.ts b/apps/web-ele/src/views/infra/codegen/data.ts index 317a37453..0d63656ca 100644 --- a/apps/web-ele/src/views/infra/codegen/data.ts +++ b/apps/web-ele/src/views/infra/codegen/data.ts @@ -8,15 +8,14 @@ import type { SystemMenuApi } from '#/api/system/menu'; import { h } from 'vue'; import { useAccess } from '@vben/access'; +import { DICT_TYPE } from '@vben/constants'; +import { getDictOptions } from '@vben/hooks'; import { IconifyIcon } from '@vben/icons'; import { handleTree } from '@vben/utils'; import { getDataSourceConfigList } from '#/api/infra/data-source-config'; import { getMenuList } from '#/api/system/menu'; import { $t } from '#/locales'; -import { DICT_TYPE } from '@vben/constants'; -import { getDictOptions } from '@vben/hooks'; - import { getRangePickerDefaultProps } from '#/utils'; const { hasAccessByCodes } = useAccess(); diff --git a/apps/web-ele/src/views/infra/codegen/edit/index.vue b/apps/web-ele/src/views/infra/codegen/edit/index.vue index 47523652d..8d076e151 100644 --- a/apps/web-ele/src/views/infra/codegen/edit/index.vue +++ b/apps/web-ele/src/views/infra/codegen/edit/index.vue @@ -31,7 +31,7 @@ const columnInfoRef = ref>(); const generateInfoRef = ref>(); /** 获取详情数据 */ -const getDetail = async () => { +async function getDetail() { const id = route.query.id as any; if (!id) { return; @@ -42,10 +42,10 @@ const getDetail = async () => { } finally { loading.value = false; } -}; +} /** 提交表单 */ -const submitForm = async () => { +async function submitForm() { // 表单验证 const basicInfoValid = await basicInfoRef.value?.validate(); if (!basicInfoValid) { @@ -79,25 +79,26 @@ const submitForm = async () => { } finally { loadingInstance.close(); } -}; -const tabs = useTabs(); +} + /** 返回列表 */ -const close = () => { +const tabs = useTabs(); +function close() { tabs.closeCurrentTab(); router.push('/infra/codegen'); -}; +} /** 下一步 */ -const nextStep = async () => { +function nextStep() { currentStep.value += 1; -}; +} /** 上一步 */ -const prevStep = () => { +function prevStep() { if (currentStep.value > 0) { currentStep.value -= 1; } -}; +} /** 步骤配置 */ const steps = [ @@ -118,14 +119,8 @@ getDetail();