From 47fc92ebc775be137863d96700d0638e1356d95f Mon Sep 17 00:00:00 2001 From: juetan Date: Tue, 5 Sep 2023 20:05:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 - scripts/vite/plugin.ts | 38 +++------- src/App.vue | 2 +- src/constants/gender.ts | 15 ++-- src/{plugins => libs}/dayjs/index.ts | 0 src/{plugins => libs}/dayjs/interface.d.ts | 0 src/{plugins => libs}/index.ts | 0 src/{plugins => libs}/nprogress/index.ts | 0 .../{_app => _layout}/components/menu.vue | 0 src/pages/{_app => _layout}/index.vue | 3 +- src/pages/_login/index.vue | 2 +- src/pages/home/index.vue | 2 +- src/pages/my/banner.png | Bin 390428 -> 0 bytes src/pages/post/edit.vue | 3 - src/pages/post/index.vue | 8 +- src/pages/system/index.vue | 2 +- src/pages/system/permission/index.vue | 2 +- src/pages/system/role/index.vue | 2 +- src/pages/system/user/index.vue | 4 +- src/router/guards/guard-nprogress.ts | 2 +- src/router/routes/index.ts | 2 +- src/store/user/index.ts | 2 + src/types/auto-component.d.ts | 20 +++++ src/utils/constant.ts | 49 ++++++++++++ src/utils/extendEnum.ts | 71 ------------------ src/utils/index.ts | 3 +- vite.config.ts | 5 +- 27 files changed, 108 insertions(+), 130 deletions(-) rename src/{plugins => libs}/dayjs/index.ts (100%) rename src/{plugins => libs}/dayjs/interface.d.ts (100%) rename src/{plugins => libs}/index.ts (100%) rename src/{plugins => libs}/nprogress/index.ts (100%) rename src/pages/{_app => _layout}/components/menu.vue (100%) rename src/pages/{_app => _layout}/index.vue (99%) delete mode 100644 src/pages/my/banner.png create mode 100644 src/utils/constant.ts delete mode 100644 src/utils/extendEnum.ts diff --git a/package.json b/package.json index 39b6fdf..83a7685 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "typescript": "^4.6.4", "unocss": "^0.49.4", "unplugin-auto-import": "^0.13.0", - "unplugin-icons": "^0.15.2", "unplugin-vue-components": "^0.23.0", "vite": "^4.3.9", "vite-plugin-mock": "^3.0.0", diff --git a/scripts/vite/plugin.ts b/scripts/vite/plugin.ts index f4399ae..6c2cbf9 100644 --- a/scripts/vite/plugin.ts +++ b/scripts/vite/plugin.ts @@ -67,43 +67,25 @@ export default function plugin(): Plugin { configResolved(resolvedConfig) { config = resolvedConfig; - const defaultExt = config.mode === "development" ? "dev" : "prod"; - extension = config.env.VITE_EXTENTION || defaultExt; + extension = config.env.VITE_EXTENTION ?? config.isProduction ? "prod" : "dev"; }, - async transformIndexHtml(html) { + async transformIndexHtml() { const script = await getBuildInfo(); - const replacedHtml = html.replace(/__((\w|_|-)+)__/g, (match, p1) => { - return config.env[`VITE_${p1}`] || ""; - }); - return { - html: replacedHtml, - tags: [ - { - tag: "script", - injectTo: "body", - children: script, - }, - ], - }; - }, - - async resolveId(id, importer, options) { - if (!extension || !id.startsWith("/src")) { - return; - } - const resolution = await this.resolve(id, importer, { skipSelf: true, ...options }); - const targetPath = resolution?.id.replace(/\.([^.]*?)$/, `.${extension}.$1`); - if (targetPath && fs.existsSync(targetPath)) { - return targetPath; - } + return [ + { + tag: "script", + injectTo: "body", + children: script, + }, + ]; }, load(id) { if (!extension || !id.includes("src")) { return; } - if (id.includes("?")) { + if (id.includes("?vue")) { return; } const targetPath = id.replace(/\.([^.]*?)$/, `.${extension}.$1`); diff --git a/src/App.vue b/src/App.vue index ee22659..f6fb06d 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,7 @@