From d3d9314abb5c5ffcfd82a2323ad81cf0ec7cf261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E4=BB=99=E9=83=BD=E6=B2=A1=E7=94=A8?= <615206459@qq.com> Date: Thu, 20 Feb 2025 11:01:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20type=20DictKey=20=3D=20?= =?UTF-8?q?=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- packages/vite-plugin/dist/index.js | 13 +++++++------ packages/vite-plugin/package.json | 2 +- packages/vite-plugin/src/eps/index.ts | 19 +++++++++++-------- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 28da638..c8da230 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "xlsx": "^0.18.5" }, "devDependencies": { - "@cool-vue/vite-plugin": "^8.0.0", + "@cool-vue/vite-plugin": "^8.0.1", "@intlify/unplugin-vue-i18n": "^6.0.3", "@rushstack/eslint-patch": "^1.10.5", "@tsconfig/node20": "^20.1.4", diff --git a/packages/vite-plugin/dist/index.js b/packages/vite-plugin/dist/index.js index 4096494..f777a8e 100644 --- a/packages/vite-plugin/dist/index.js +++ b/packages/vite-plugin/dist/index.js @@ -521,15 +521,16 @@ } // 创建 dict async function createDict() { - return axios - .get(config.reqUrl + "/" + config.type + "/dict/info/types") - .then(async (res) => { + return axios.get(config.reqUrl + "/" + config.type + "/dict/info/types").then((res) => { const { code, data } = res.data; if (code === 1000) { - return `type DictKey = ${data.map((e) => `"${e.key}"`).join(" | ")}`; + let v = "string"; + if (!lodash.isEmpty(data)) { + v = data.map((e) => `"${e.key}"`).join(" | "); + } + return `type DictKey = ${v}`; } - }) - .catch((err) => { }); + }); } // 创建 eps async function createEps() { diff --git a/packages/vite-plugin/package.json b/packages/vite-plugin/package.json index a1d2795..18dd407 100644 --- a/packages/vite-plugin/package.json +++ b/packages/vite-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@cool-vue/vite-plugin", - "version": "8.0.0", + "version": "8.0.1", "description": "cool-admin、cool-uni builder", "types": "./dist/index.d.ts", "main": "/dist/index.js", diff --git a/packages/vite-plugin/src/eps/index.ts b/packages/vite-plugin/src/eps/index.ts index 94fd498..efffac3 100644 --- a/packages/vite-plugin/src/eps/index.ts +++ b/packages/vite-plugin/src/eps/index.ts @@ -481,16 +481,19 @@ function createService() { // 创建 dict async function createDict() { - return axios - .get(config.reqUrl + "/" + config.type + "/dict/info/types") - .then(async (res) => { - const { code, data } = res.data; + return axios.get(config.reqUrl + "/" + config.type + "/dict/info/types").then((res) => { + const { code, data } = res.data as { code: number; data: any[] }; - if (code === 1000) { - return `type DictKey = ${data.map((e: any) => `"${e.key}"`).join(" | ")}`; + if (code === 1000) { + let v = "string"; + + if (!isEmpty(data)) { + v = data.map((e) => `"${e.key}"`).join(" | "); } - }) - .catch((err) => {}); + + return `type DictKey = ${v}`; + } + }); } // 创建 eps