From b322428830c1d5f526223cf597602f4bf4ca8760 Mon Sep 17 00:00:00 2001 From: ray <1490493387@qq.com> Date: Sat, 13 Jul 2024 08:55:13 +0800 Subject: [PATCH 01/13] =?UTF-8?q?feat:=20:sparkles:=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E8=8F=9C=E5=8D=95=E5=92=8C?= =?UTF-8?q?=E7=A9=BA=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/generator.ts | 20 ++++++++++++++++++++ src/assets/icons/code.svg | 1 + src/views/generator/index.vue | 15 +++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 src/api/generator.ts create mode 100644 src/assets/icons/code.svg create mode 100644 src/views/generator/index.vue diff --git a/src/api/generator.ts b/src/api/generator.ts new file mode 100644 index 00000000..f1876e2a --- /dev/null +++ b/src/api/generator.ts @@ -0,0 +1,20 @@ +import request from "@/utils/request"; + +const USER_BASE_URL = "/api/v1/generators"; + +class GeneratorAPI { + /** + * 获取代码生成预览数据 + */ + static getPreviewData(tableName: string) { + return request({ + url: `${USER_BASE_URL}/preview/${tableName}`, + method: "get", + }); + } +} + +export default GeneratorAPI; + +/** 代码生成预览对象 */ +export interface GeneratorPreviewVO {} diff --git a/src/assets/icons/code.svg b/src/assets/icons/code.svg new file mode 100644 index 00000000..d8b546ca --- /dev/null +++ b/src/assets/icons/code.svg @@ -0,0 +1 @@ + diff --git a/src/views/generator/index.vue b/src/views/generator/index.vue new file mode 100644 index 00000000..4aef9e2e --- /dev/null +++ b/src/views/generator/index.vue @@ -0,0 +1,15 @@ + + + + + From da0fcf21c10ac8f21f583ba403edf0c1e1785d00 Mon Sep 17 00:00:00 2001 From: ray <1490493387@qq.com> Date: Sun, 14 Jul 2024 23:28:13 +0800 Subject: [PATCH 02/13] =?UTF-8?q?style:=20:lipstick:=20=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/role/index.vue | 49 +++++++++++++++++++------------ src/views/system/user/index.vue | 52 ++++++++++++++++++++------------- 2 files changed, 63 insertions(+), 38 deletions(-) diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue index daec88ba..a468756e 100644 --- a/src/views/system/role/index.vue +++ b/src/views/system/role/index.vue @@ -12,25 +12,32 @@ - 搜索 - 重置 + + + 搜索 + + + + 重置 + - 分配权限 + + 分配权限 - 编辑 + + 编辑 - 删除 + + 删除 @@ -167,14 +177,16 @@
- {{ isExpanded ? "收缩" : "展开" }} + + + {{ isExpanded ? "收缩" : "展开" }} + 父子联动 + > + 父子联动 @@ -205,9 +217,9 @@ @@ -287,6 +299,7 @@ function handleQuery() { loading.value = false; }); } + /** 重置查询 */ function handleResetQuery() { queryFormRef.value.resetFields(); diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index f480b0a2..1d64d66e 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -46,13 +46,14 @@ - 搜索 + + + 搜索 + - 重置 + 重置 +
@@ -65,24 +66,30 @@ v-hasPerm="['sys:user:add']" type="success" @click="handleOpenDialog()" - >新增 + + 新增 + 删除 + + 删除 +
- 导入 + + + 导入 + - 导出 + + + 导出 +
@@ -135,9 +142,9 @@ 重置密码 + + 重置密码 + 编辑 + + 编辑 + 删除 + + 删除 +
@@ -194,7 +207,6 @@ append-to-body @close="handleCloseDialog" > - Date: Sun, 14 Jul 2024 23:30:14 +0800 Subject: [PATCH 03/13] =?UTF-8?q?feat:=20:sparkles:=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=99=A8=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/database.ts | 93 ++++++++++++++ src/api/generator.ts | 20 --- src/views/generator/index.vue | 226 +++++++++++++++++++++++++++++++++- 3 files changed, 316 insertions(+), 23 deletions(-) create mode 100644 src/api/database.ts delete mode 100644 src/api/generator.ts diff --git a/src/api/database.ts b/src/api/database.ts new file mode 100644 index 00000000..9730337c --- /dev/null +++ b/src/api/database.ts @@ -0,0 +1,93 @@ +import request from "@/utils/request"; + +const DATABASE_BASE_URL = "/api/v1/databases"; + +class DatabaseAPI { + /** 获取数据表分页列表 */ + static getTablePage(params: TablePageQuery) { + return request>({ + url: `${DATABASE_BASE_URL}/table/page`, + method: "get", + params: params, + }); + } + + /** 获取代码生成预览数据 */ + static getTableColumns(tableName: string) { + return request({ + url: `${DATABASE_BASE_URL}/${tableName}/columns`, + method: "get", + }); + } + + /** 获取代码生成预览数据 */ + static getPreviewData(tableName: string) { + return request({ + url: `${DATABASE_BASE_URL}/table/${tableName}/generate-preview`, + method: "get", + }); + } +} + +export default DatabaseAPI; + +/** 代码生成预览对象 */ +export interface GeneratorPreviewVO { + /** 文件生成路径 */ + path: string; + /** 文件名称 */ + fileName: string; + /** 文件内容 */ + content: string; +} + +/** 数据表分页查询参数 */ +export interface TablePageQuery extends PageQuery { + /** 关键字(表名) */ + keywords?: string; +} + +/** 数据表分页对象 */ +export interface TablePageVO { + /** 表名称 */ + tableName: string; + + /** 表描述 */ + tableComment: string; + + /** 存储引擎 */ + engine: string; + + /** 字符集排序规则 */ + tableCollation: string; + + /** 创建时间 */ + createTime: string; +} + +/** 数据表字段VO */ +export interface TableColumnVO { + /** 字段名称 */ + columnName: string; + + /** 字段类型 */ + dataType: string; + + /** 字段描述 */ + columnComment: string; + + /** 字段长度 */ + characterMaximumLength: number; + + /** 是否主键(1-是 0-否) */ + isPrimaryKey: number; + + /** 是否可为空(1-是 0-否) */ + isNullable: string; + + /** 字符集 */ + characterSetName: string; + + /** 字符集排序规则 */ + collationName: string; +} diff --git a/src/api/generator.ts b/src/api/generator.ts deleted file mode 100644 index f1876e2a..00000000 --- a/src/api/generator.ts +++ /dev/null @@ -1,20 +0,0 @@ -import request from "@/utils/request"; - -const USER_BASE_URL = "/api/v1/generators"; - -class GeneratorAPI { - /** - * 获取代码生成预览数据 - */ - static getPreviewData(tableName: string) { - return request({ - url: `${USER_BASE_URL}/preview/${tableName}`, - method: "get", - }); - } -} - -export default GeneratorAPI; - -/** 代码生成预览对象 */ -export interface GeneratorPreviewVO {} diff --git a/src/views/generator/index.vue b/src/views/generator/index.vue index 4aef9e2e..f00703a9 100644 --- a/src/views/generator/index.vue +++ b/src/views/generator/index.vue @@ -1,8 +1,111 @@ @@ -10,6 +113,123 @@ defineOptions({ name: "Generator", }); + +import "codemirror/mode/javascript/javascript.js"; +import Codemirror from "codemirror-editor-vue3"; +import type { CmComponentRef } from "codemirror-editor-vue3"; +import type { Editor, EditorConfiguration } from "codemirror"; + +const code = ref( + `var i = 0; +for (; i < 9; i++) { + console.log(i); + // more statements +} +` +); +const cmRef = ref(); +const cmOptions: EditorConfiguration = { + mode: "text/javascript", +}; + +const onChange = (val: string, cm: Editor) => { + console.log(val); + console.log(cm.getValue()); +}; + +const onInput = (val: string) => { + console.log(val); +}; + +const onReady = (cm: Editor) => { + console.log(cm.focus()); +}; + +onMounted(() => { + setTimeout(() => { + cmRef.value?.refresh(); + }, 1000); + + setTimeout(() => { + cmRef.value?.resize(300, 200); + }, 2000); + + setTimeout(() => { + cmRef.value?.cminstance.isClean(); + }, 3000); +}); + +onUnmounted(() => { + handleQuery(); + cmRef.value?.destroy(); +}); + +import DatabaseAPI, { + TablePageVO, + TableColumnVO, + TablePageQuery, + GeneratorPreviewVO, +} from "@/api/database"; + +const queryFormRef = ref(ElForm); + +const loading = ref(false); +const ids = ref([]); +const total = ref(0); + +const queryParams = reactive({ + pageNum: 1, + pageSize: 10, +}); + +const pageData = ref([]); + +const formData = reactive({}); + +const dialog = reactive({ + visible: false, + title: "", +}); + +/** 查询 */ +function handleQuery() { + loading.value = true; + DatabaseAPI.getTablePage(queryParams) + .then((data) => { + pageData.value = data.list; + total.value = data.total; + }) + .finally(() => { + loading.value = false; + }); +} +/** 重置查询 */ +function handleResetQuery() { + queryFormRef.value.resetFields(); + queryParams.pageNum = 1; + handleQuery(); +} + +function handlePreview(tableName: string) { + DatabaseAPI.getPreviewData(tableName).then((data) => { + dialog.title = `预览 ${tableName}`; + handleOpenDialog(); + }); +} + +function handleCloseDialog() { + dialog.visible = false; +} + +function handleOpenDialog() { + dialog.visible = true; +} + +function handleSubmit() {} + +/* onMounted(() => { + handleQuery(); +}); */ From 6c0d50edb4b67e3dbd0c3d9d52d3aeb31728eb8d Mon Sep 17 00:00:00 2001 From: ray <1490493387@qq.com> Date: Sun, 14 Jul 2024 23:31:06 +0800 Subject: [PATCH 04/13] =?UTF-8?q?feat:=20:sparkles:=20=E6=95=B4=E5=90=88?= =?UTF-8?q?=20codemirror-editor-vue3=20=E4=BB=A3=E7=A0=81=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 3 +++ src/main.ts | 2 ++ 2 files changed, 5 insertions(+) diff --git a/package.json b/package.json index d4a35d77..4a758394 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,8 @@ "@wangeditor/editor-for-vue": "5.1.10", "animate.css": "^4.1.1", "axios": "^1.7.2", + "codemirror": "^5", + "codemirror-editor-vue3": "^2.7.0", "color": "^4.2.3", "echarts": "^5.5.1", "element-plus": "^2.7.6", @@ -71,6 +73,7 @@ "@commitlint/cli": "^18.6.1", "@commitlint/config-conventional": "^18.6.3", "@iconify-json/ep": "^1.1.15", + "@types/codemirror": "^5.60.15", "@types/color": "^3.0.6", "@types/lodash": "^4.17.6", "@types/node": "^20.14.10", diff --git a/src/main.ts b/src/main.ts index 16e0cb9f..5b8e96fb 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,7 +10,9 @@ import "element-plus/theme-chalk/dark/css-vars.css"; import "@/styles/index.scss"; import "uno.css"; import "animate.css"; +import { InstallCodemirro } from "codemirror-editor-vue3"; const app = createApp(App); app.use(setupPlugins); +app.use(InstallCodemirro); app.mount("#app"); From ce8149c4ba61e957c0e9678ec76d71bd13f7ea35 Mon Sep 17 00:00:00 2001 From: ray <1490493387@qq.com> Date: Mon, 15 Jul 2024 08:17:40 +0800 Subject: [PATCH 05/13] =?UTF-8?q?feat:=20:sparkles:=20=E4=BD=BF=E7=94=A8co?= =?UTF-8?q?demirror=E9=A2=84=E8=A7=88=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/database.ts | 2 +- src/views/generator/index.vue | 57 ++++++++++++----------------------- 2 files changed, 20 insertions(+), 39 deletions(-) diff --git a/src/api/database.ts b/src/api/database.ts index 9730337c..14d4c4d7 100644 --- a/src/api/database.ts +++ b/src/api/database.ts @@ -22,7 +22,7 @@ class DatabaseAPI { /** 获取代码生成预览数据 */ static getPreviewData(tableName: string) { - return request({ + return request({ url: `${DATABASE_BASE_URL}/table/${tableName}/generate-preview`, method: "get", }); diff --git a/src/views/generator/index.vue b/src/views/generator/index.vue index f00703a9..71339f10 100644 --- a/src/views/generator/index.vue +++ b/src/views/generator/index.vue @@ -85,19 +85,20 @@ size="80%" > - 123 + + + - +
+ +
@@ -119,32 +120,12 @@ import Codemirror from "codemirror-editor-vue3"; import type { CmComponentRef } from "codemirror-editor-vue3"; import type { Editor, EditorConfiguration } from "codemirror"; -const code = ref( - `var i = 0; -for (; i < 9; i++) { - console.log(i); - // more statements -} -` -); +const code = ref(); const cmRef = ref(); const cmOptions: EditorConfiguration = { mode: "text/javascript", }; -const onChange = (val: string, cm: Editor) => { - console.log(val); - console.log(cm.getValue()); -}; - -const onInput = (val: string) => { - console.log(val); -}; - -const onReady = (cm: Editor) => { - console.log(cm.focus()); -}; - onMounted(() => { setTimeout(() => { cmRef.value?.refresh(); @@ -174,7 +155,6 @@ import DatabaseAPI, { const queryFormRef = ref(ElForm); const loading = ref(false); -const ids = ref([]); const total = ref(0); const queryParams = reactive({ @@ -184,8 +164,6 @@ const queryParams = reactive({ const pageData = ref([]); -const formData = reactive({}); - const dialog = reactive({ visible: false, title: "", @@ -213,6 +191,9 @@ function handleResetQuery() { function handlePreview(tableName: string) { DatabaseAPI.getPreviewData(tableName).then((data) => { dialog.title = `预览 ${tableName}`; + code.value = data[0].content; + + console.log("data", data); handleOpenDialog(); }); } @@ -227,9 +208,9 @@ function handleOpenDialog() { function handleSubmit() {} -/* onMounted(() => { +onMounted(() => { handleQuery(); -}); */ +}); From 077cdf0cade27bc902f4afd3646ccb54892b3c56 Mon Sep 17 00:00:00 2001 From: ray <1490493387@qq.com> Date: Mon, 15 Jul 2024 18:20:59 +0800 Subject: [PATCH 06/13] =?UTF-8?q?feat:=20:sparkles:=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/database.ts | 2 +- src/main.ts | 1 + src/views/generator/index.vue | 73 ++++++++++++++++++++--------------- 3 files changed, 44 insertions(+), 32 deletions(-) diff --git a/src/api/database.ts b/src/api/database.ts index 14d4c4d7..e272e6f8 100644 --- a/src/api/database.ts +++ b/src/api/database.ts @@ -15,7 +15,7 @@ class DatabaseAPI { /** 获取代码生成预览数据 */ static getTableColumns(tableName: string) { return request({ - url: `${DATABASE_BASE_URL}/${tableName}/columns`, + url: `${DATABASE_BASE_URL}/table/${tableName}/columns`, method: "get", }); } diff --git a/src/main.ts b/src/main.ts index 5b8e96fb..ff813587 100644 --- a/src/main.ts +++ b/src/main.ts @@ -13,6 +13,7 @@ import "animate.css"; import { InstallCodemirro } from "codemirror-editor-vue3"; const app = createApp(App); +// 注册插件 app.use(setupPlugins); app.use(InstallCodemirro); app.mount("#app"); diff --git a/src/views/generator/index.vue b/src/views/generator/index.vue index 71339f10..689b5a48 100644 --- a/src/views/generator/index.vue +++ b/src/views/generator/index.vue @@ -51,16 +51,16 @@ type="primary" size="small" link - @click="handlePreview(scope.row.tableName)" + @click="handleOpenDialog('config', scope.row.tableName)" > - 预览 + 配置 生成 @@ -84,23 +84,31 @@ @close="handleCloseDialog" size="80%" > - - - - - -
- -
-
-
+
+ + + + + +
+ +
+
+
+
+
+ + 基础信息 + 字段配置 + +