diff --git a/admin-client/src/services/development_tool/low_code/CodeGenerationService.ts b/admin-client/src/services/development_tool/low_code/CodeGenerationService.ts index 6b018ff..de28704 100644 --- a/admin-client/src/services/development_tool/low_code/CodeGenerationService.ts +++ b/admin-client/src/services/development_tool/low_code/CodeGenerationService.ts @@ -6,6 +6,14 @@ import Http from "@/core/utils/Http"; export default class CodeGenerationService { static urlPrefix = "/api/v1/admin/CodeGeneration"; + /** + * 获取数据库列表 + * @returns + */ + static getDatabases() { + return Http.get(`${this.urlPrefix}/GetDatabases`); + } + /** * 获取数据列表 * @param current diff --git a/admin-client/src/views/development_tool/low_code/Index.vue b/admin-client/src/views/development_tool/low_code/Index.vue index beaff62..5186c70 100644 --- a/admin-client/src/views/development_tool/low_code/Index.vue +++ b/admin-client/src/views/development_tool/low_code/Index.vue @@ -19,6 +19,7 @@ const state = reactive({ tableName: undefined, entityName: undefined, displayName: undefined, + dataBase: undefined, }, sort: [] as any[], }, @@ -28,6 +29,7 @@ const state = reactive({ total: 100, columns: [] as any, data: [] as any, + databaseList: [] as any, }); //表格 @@ -43,9 +45,47 @@ const refTableEditor = ref>(); * 初始化 */ onMounted(() => { + loadDatabases(); findList(); }); +/** + * 加载数据库列表 + */ +async function loadDatabases() { + const result = await CodeGenerationService.getDatabases(); + if (result.code != 200) return; + state.databaseList = result.data; +} + +/** + * 数据库切换事件 + */ +function handleDatabaseChange() { + state.page = 1; + findList(); +} + +/** + * 获取数据库颜色 + */ +function getDatabaseColor(dataBaseKey: string): string { + const colorMap: Record = { + 'Admin': 'blue', + 'MiaoYuChat': 'green', + 'LiveForum': 'orange' + }; + return colorMap[dataBaseKey] || 'default'; +} + +/** + * 获取数据库显示名称 + */ +function getDatabaseDisplayName(dataBaseKey: string): string { + const db = state.databaseList.find((d: any) => d.key === dataBaseKey); + return db?.displayName || dataBaseKey; +} + /** *获取数据 */ @@ -139,6 +179,24 @@ function openTableEditor() {