From 705d4c34f27bf4c910d9a80497d0b1a9f63d1445 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: Tue, 13 Aug 2024 17:29:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vite-plugin/dist/eps/index.d.ts | 4 ++ packages/vite-plugin/dist/index.js | 43 ++++++++++++++-------- packages/vite-plugin/package.json | 2 +- packages/vite-plugin/src/config.ts | 1 + packages/vite-plugin/src/eps/index.ts | 37 +++++++++++-------- packages/vite-plugin/src/index.ts | 5 ++- packages/vite-plugin/types/index.d.ts | 1 + src/modules/helper/views/plugins/serve.vue | 6 +-- vite.config.mts | 5 ++- 9 files changed, 67 insertions(+), 37 deletions(-) diff --git a/packages/vite-plugin/dist/eps/index.d.ts b/packages/vite-plugin/dist/eps/index.d.ts index 85e650c..7db3e9c 100644 --- a/packages/vite-plugin/dist/eps/index.d.ts +++ b/packages/vite-plugin/dist/eps/index.d.ts @@ -5,4 +5,8 @@ export declare function createEps(query?: { service: {}; list: Eps.Entity[]; isUpdate: boolean; +} | { + service: {}; + list: never[]; + isUpdate?: undefined; }>; diff --git a/packages/vite-plugin/dist/index.js b/packages/vite-plugin/dist/index.js index 814bd67..2045d0c 100644 --- a/packages/vite-plugin/dist/index.js +++ b/packages/vite-plugin/dist/index.js @@ -9,6 +9,7 @@ reqUrl: "", demo: false, eps: { + enable: true, api: "", dist: "./build/cool", mapping: [ @@ -493,21 +494,29 @@ } // 创建 eps async function createEps(query) { - // 获取数据 - await getData(query?.list || []); - // 创建 service - createService(); - // 创建目录 - createDir(getEpsPath(), true); - // 创建 json 文件 - const isUpdate = createJson(); - // 创建描述文件 - createDescribe({ service, list }); - return { - service, - list, - isUpdate, - }; + if (config.eps.enable) { + // 获取数据 + await getData(query?.list || []); + // 创建 service + createService(); + // 创建目录 + createDir(getEpsPath(), true); + // 创建 json 文件 + const isUpdate = createJson(); + // 创建描述文件 + createDescribe({ service, list }); + return { + service, + list, + isUpdate, + }; + } + else { + return { + service: {}, + list: [], + }; + } } function createTag(code, id) { @@ -872,7 +881,9 @@ if (typeof window !== 'undefined') { config.reqUrl = options.proxy["/dev/"].target; // Eps if (options.eps) { - const { dist, mapping, api } = options.eps; + const { dist, mapping, api, enable = true } = options.eps; + // 是否开启 + config.eps.enable = enable; // 类型 if (api) { config.eps.api = api; diff --git a/packages/vite-plugin/package.json b/packages/vite-plugin/package.json index 3663290..136ec4f 100644 --- a/packages/vite-plugin/package.json +++ b/packages/vite-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@cool-vue/vite-plugin", - "version": "7.2.1", + "version": "7.2.2", "description": "cool-admin、cool-uni builder", "main": "/dist/index.js", "scripts": { diff --git a/packages/vite-plugin/src/config.ts b/packages/vite-plugin/src/config.ts index 47e333b..dec5bf7 100644 --- a/packages/vite-plugin/src/config.ts +++ b/packages/vite-plugin/src/config.ts @@ -5,6 +5,7 @@ export const config: Config.Data = { reqUrl: "", demo: false, eps: { + enable: true, api: "", dist: "./build/cool", mapping: [ diff --git a/packages/vite-plugin/src/eps/index.ts b/packages/vite-plugin/src/eps/index.ts index 974f10c..4a06dec 100644 --- a/packages/vite-plugin/src/eps/index.ts +++ b/packages/vite-plugin/src/eps/index.ts @@ -473,24 +473,31 @@ function createService() { // 创建 eps export async function createEps(query?: { list: any[] }) { - // 获取数据 - await getData(query?.list || []); + if (config.eps.enable) { + // 获取数据 + await getData(query?.list || []); - // 创建 service - createService(); + // 创建 service + createService(); - // 创建目录 - createDir(getEpsPath(), true); + // 创建目录 + createDir(getEpsPath(), true); - // 创建 json 文件 - const isUpdate = createJson(); + // 创建 json 文件 + const isUpdate = createJson(); - // 创建描述文件 - createDescribe({ service, list }); + // 创建描述文件 + createDescribe({ service, list }); - return { - service, - list, - isUpdate, - }; + return { + service, + list, + isUpdate, + }; + } else { + return { + service: {}, + list: [], + }; + } } diff --git a/packages/vite-plugin/src/index.ts b/packages/vite-plugin/src/index.ts index 6d78c03..d28d994 100644 --- a/packages/vite-plugin/src/index.ts +++ b/packages/vite-plugin/src/index.ts @@ -14,7 +14,10 @@ export function cool(options: Config.Options) { // Eps if (options.eps) { - const { dist, mapping, api } = options.eps; + const { dist, mapping, api, enable = true } = options.eps; + + // 是否开启 + config.eps.enable = enable; // 类型 if (api) { diff --git a/packages/vite-plugin/types/index.d.ts b/packages/vite-plugin/types/index.d.ts index cb27dc9..d940377 100644 --- a/packages/vite-plugin/types/index.d.ts +++ b/packages/vite-plugin/types/index.d.ts @@ -62,6 +62,7 @@ export namespace Ctx { export namespace Config { type Type = "app" | "admin"; interface Eps { + enable: boolean; api: "app" | "admin" | (string & {}); dist: string; mapping: { diff --git a/src/modules/helper/views/plugins/serve.vue b/src/modules/helper/views/plugins/serve.vue index 964ceca..d51ee1d 100644 --- a/src/modules/helper/views/plugins/serve.vue +++ b/src/modules/helper/views/plugins/serve.vue @@ -1,6 +1,6 @@