From 35f3a87a0cb9f98cdf945d822f04a39d2ca2cf61 Mon Sep 17 00:00:00 2001 From: Json_Lee <2622336659@qq.com> Date: Fri, 30 May 2025 00:07:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20=E4=BF=AE=E6=94=B9=E6=9E=B6?= =?UTF-8?q?=E6=9E=84=E4=B8=8A=E9=9D=A2=E7=9A=84=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .build/plugins/index.ts | 39 ++++++++++++ .build/plugins/svg-icon.ts | 21 ++++++ .build/plugins/types/auto-imports.d.ts | 88 ++++++++++++++++++++++++++ .build/plugins/types/components.d.ts | 23 +++++++ package.json | 1 + pnpm-lock.yaml | 64 +++++++++++++------ vite.config.ts | 28 ++------ vite/plugins/svg-icon.ts | 20 ------ 8 files changed, 221 insertions(+), 63 deletions(-) create mode 100644 .build/plugins/index.ts create mode 100644 .build/plugins/svg-icon.ts create mode 100644 .build/plugins/types/auto-imports.d.ts create mode 100644 .build/plugins/types/components.d.ts delete mode 100644 vite/plugins/svg-icon.ts diff --git a/.build/plugins/index.ts b/.build/plugins/index.ts new file mode 100644 index 0000000..29d8021 --- /dev/null +++ b/.build/plugins/index.ts @@ -0,0 +1,39 @@ +import type { ConfigEnv, PluginOption } from 'vite'; +import path from 'node:path'; +import vue from '@vitejs/plugin-vue'; +import UnoCSS from 'unocss/vite'; +import AutoImport from 'unplugin-auto-import/vite'; +import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'; +import Components from 'unplugin-vue-components/vite'; +import envTyped from 'vite-plugin-env-typed'; +import createSvgIcon from './svg-icon'; + +const root = path.resolve(__dirname, '../../'); + +function plugins({ mode, command }: ConfigEnv): PluginOption[] { + return [ + UnoCSS(), + envTyped({ + mode, + envDir: root, + envPrefix: 'VITE_', + filePath: path.join(root, 'types', 'import_meta.d.ts'), + }), + vue(), + AutoImport({ + imports: ['vue'], + eslintrc: { + enabled: true, + }, + resolvers: [ElementPlusResolver()], + dts: path.resolve(__dirname, './types/auto-imports.d.ts'), + }), + Components({ + resolvers: [ElementPlusResolver()], + dts: path.resolve(__dirname, './types/components.d.ts'), + }), + createSvgIcon(command === 'build'), + ]; +} + +export default plugins; diff --git a/.build/plugins/svg-icon.ts b/.build/plugins/svg-icon.ts new file mode 100644 index 0000000..ebe7617 --- /dev/null +++ b/.build/plugins/svg-icon.ts @@ -0,0 +1,21 @@ +import path from 'node:path'; +import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'; + +const root = path.resolve(__dirname, '../../'); + +export default function createSvgIcon(isBuild: boolean) { + return createSvgIconsPlugin({ + iconDirs: [ + path.join(root, 'src/assets/icons/svg'), + path.join(root, 'src/assets/icons/Buildings'), + path.join(root, 'src/assets/icons/Business'), + path.join(root, 'src/assets/icons/Device'), + path.join(root, 'src/assets/icons/Document'), + path.join(root, 'src/assets/icons/Others'), + path.join(root, 'src/assets/icons/System'), + path.join(root, 'src/assets/icons/User'), + ], + symbolId: 'icon-[dir]-[name]', + svgoOptions: isBuild, + }); +} diff --git a/.build/plugins/types/auto-imports.d.ts b/.build/plugins/types/auto-imports.d.ts new file mode 100644 index 0000000..3ddfdbc --- /dev/null +++ b/.build/plugins/types/auto-imports.d.ts @@ -0,0 +1,88 @@ +/* eslint-disable */ +/* prettier-ignore */ +// @ts-nocheck +// noinspection JSUnusedGlobalSymbols +// Generated by unplugin-auto-import +// biome-ignore lint: disable +export {} +declare global { + const EffectScope: (typeof import("vue"))["EffectScope"]; + const computed: (typeof import("vue"))["computed"]; + const createApp: (typeof import("vue"))["createApp"]; + const customRef: (typeof import("vue"))["customRef"]; + const defineAsyncComponent: (typeof import("vue"))["defineAsyncComponent"]; + const defineComponent: (typeof import("vue"))["defineComponent"]; + const effectScope: (typeof import("vue"))["effectScope"]; + const getCurrentInstance: (typeof import("vue"))["getCurrentInstance"]; + const getCurrentScope: (typeof import("vue"))["getCurrentScope"]; + const h: (typeof import("vue"))["h"]; + const inject: (typeof import("vue"))["inject"]; + const isProxy: (typeof import("vue"))["isProxy"]; + const isReactive: (typeof import("vue"))["isReactive"]; + const isReadonly: (typeof import("vue"))["isReadonly"]; + const isRef: (typeof import("vue"))["isRef"]; + const markRaw: (typeof import("vue"))["markRaw"]; + const nextTick: (typeof import("vue"))["nextTick"]; + const onActivated: (typeof import("vue"))["onActivated"]; + const onBeforeMount: (typeof import("vue"))["onBeforeMount"]; + const onBeforeUnmount: (typeof import("vue"))["onBeforeUnmount"]; + const onBeforeUpdate: (typeof import("vue"))["onBeforeUpdate"]; + const onDeactivated: (typeof import("vue"))["onDeactivated"]; + const onErrorCaptured: (typeof import("vue"))["onErrorCaptured"]; + const onMounted: (typeof import("vue"))["onMounted"]; + const onRenderTracked: (typeof import("vue"))["onRenderTracked"]; + const onRenderTriggered: (typeof import("vue"))["onRenderTriggered"]; + const onScopeDispose: (typeof import("vue"))["onScopeDispose"]; + const onServerPrefetch: (typeof import("vue"))["onServerPrefetch"]; + const onUnmounted: (typeof import("vue"))["onUnmounted"]; + const onUpdated: (typeof import("vue"))["onUpdated"]; + const onWatcherCleanup: (typeof import("vue"))["onWatcherCleanup"]; + const provide: (typeof import("vue"))["provide"]; + const reactive: (typeof import("vue"))["reactive"]; + const readonly: (typeof import("vue"))["readonly"]; + const ref: (typeof import("vue"))["ref"]; + const resolveComponent: (typeof import("vue"))["resolveComponent"]; + const shallowReactive: (typeof import("vue"))["shallowReactive"]; + const shallowReadonly: (typeof import("vue"))["shallowReadonly"]; + const shallowRef: (typeof import("vue"))["shallowRef"]; + const toRaw: (typeof import("vue"))["toRaw"]; + const toRef: (typeof import("vue"))["toRef"]; + const toRefs: (typeof import("vue"))["toRefs"]; + const toValue: (typeof import("vue"))["toValue"]; + const triggerRef: (typeof import("vue"))["triggerRef"]; + const unref: (typeof import("vue"))["unref"]; + const useAttrs: (typeof import("vue"))["useAttrs"]; + const useCssModule: (typeof import("vue"))["useCssModule"]; + const useCssVars: (typeof import("vue"))["useCssVars"]; + const useId: (typeof import("vue"))["useId"]; + const useModel: (typeof import("vue"))["useModel"]; + const useSlots: (typeof import("vue"))["useSlots"]; + const useTemplateRef: (typeof import("vue"))["useTemplateRef"]; + const watch: (typeof import("vue"))["watch"]; + const watchEffect: (typeof import("vue"))["watchEffect"]; + const watchPostEffect: (typeof import("vue"))["watchPostEffect"]; + const watchSyncEffect: (typeof import("vue"))["watchSyncEffect"]; +} +// for type re-export +declare global { + // @ts-ignore + export type { + Component, + Slot, + Slots, + ComponentPublicInstance, + ComputedRef, + DirectiveBinding, + ExtractDefaultPropTypes, + ExtractPropTypes, + ExtractPublicPropTypes, + InjectionKey, + PropType, + Ref, + MaybeRef, + MaybeRefOrGetter, + VNode, + WritableComputedRef, + } from "vue"; + import("vue"); +} diff --git a/.build/plugins/types/components.d.ts b/.build/plugins/types/components.d.ts new file mode 100644 index 0000000..197ffd3 --- /dev/null +++ b/.build/plugins/types/components.d.ts @@ -0,0 +1,23 @@ +/* eslint-disable */ +// @ts-nocheck +// Generated by unplugin-vue-components +// Read more: https://github.com/vuejs/core/pull/3399 +// biome-ignore lint: disable +export {}; + +/* prettier-ignore */ +declare module 'vue' { + export interface GlobalComponents { + AccountPassword: typeof import('./../../../src/components/LoginDialog/components/FormLogin/AccountPassword.vue')['default'] + IconSelect: typeof import('./../../../src/components/IconSelect/index.vue')['default'] + LoginDialog: typeof import('./../../../src/components/LoginDialog/index.vue')['default'] + ModelSelect: typeof import('./../../../src/components/ModelSelect/index.vue')['default'] + Popover: typeof import('./../../../src/components/Popover/index.vue')['default'] + QrCodeLogin: typeof import('./../../../src/components/LoginDialog/components/QrCodeLogin/index.vue')['default'] + RouterLink: typeof import('vue-router')['RouterLink'] + RouterView: typeof import('vue-router')['RouterView'] + SvgIcon: typeof import('./../../../src/components/SvgIcon/index.vue')['default'] + VerificationCode: typeof import('./../../../src/components/LoginDialog/components/FormLogin/VerificationCode.vue')['default'] + WelecomeText: typeof import('./../../../src/components/WelecomeText/index.vue')['default'] + } +} diff --git a/package.json b/package.json index b491aa9..f6f0681 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "unplugin-auto-import": "^19.2.0", "unplugin-vue-components": "^28.5.0", "vite": "^6.3.5", + "vite-plugin-env-typed": "^0.0.2", "vue-tsc": "^2.2.10" }, "config": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b939dc5..eab5f62 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -108,6 +108,9 @@ importers: vite: specifier: ^6.3.5 version: 6.3.5(@types/node@22.15.19)(jiti@2.4.2)(sass-embedded@1.89.0)(yaml@2.8.0) + vite-plugin-env-typed: + specifier: ^0.0.2 + version: 0.0.2(vite@6.3.5(@types/node@22.15.19)(jiti@2.4.2)(sass-embedded@1.89.0)(yaml@2.8.0)) vue-tsc: specifier: ^2.2.10 version: 2.2.10(typescript@5.8.3) @@ -725,67 +728,56 @@ packages: resolution: {integrity: sha512-46OzWeqEVQyX3N2/QdiU/CMXYDH/lSHpgfBkuhl3igpZiaB3ZIfSjKuOnybFVBQzjsLwkus2mjaESy8H41SzvA==} cpu: [arm] os: [linux] - libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.41.0': resolution: {integrity: sha512-lfgW3KtQP4YauqdPpcUZHPcqQXmTmH4nYU0cplNeW583CMkAGjtImw4PKli09NFi2iQgChk4e9erkwlfYem6Lg==} cpu: [arm] os: [linux] - libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.41.0': resolution: {integrity: sha512-nn8mEyzMbdEJzT7cwxgObuwviMx6kPRxzYiOl6o/o+ChQq23gfdlZcUNnt89lPhhz3BYsZ72rp0rxNqBSfqlqw==} cpu: [arm64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.41.0': resolution: {integrity: sha512-l+QK99je2zUKGd31Gh+45c4pGDAqZSuWQiuRFCdHYC2CSiO47qUWsCcenrI6p22hvHZrDje9QjwSMAFL3iwXwQ==} cpu: [arm64] os: [linux] - libc: [musl] '@rollup/rollup-linux-loongarch64-gnu@4.41.0': resolution: {integrity: sha512-WbnJaxPv1gPIm6S8O/Wg+wfE/OzGSXlBMbOe4ie+zMyykMOeqmgD1BhPxZQuDqwUN+0T/xOFtL2RUWBspnZj3w==} cpu: [loong64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-powerpc64le-gnu@4.41.0': resolution: {integrity: sha512-eRDWR5t67/b2g8Q/S8XPi0YdbKcCs4WQ8vklNnUYLaSWF+Cbv2axZsp4jni6/j7eKvMLYCYdcsv8dcU+a6QNFg==} cpu: [ppc64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-riscv64-gnu@4.41.0': resolution: {integrity: sha512-TWrZb6GF5jsEKG7T1IHwlLMDRy2f3DPqYldmIhnA2DVqvvhY2Ai184vZGgahRrg8k9UBWoSlHv+suRfTN7Ua4A==} cpu: [riscv64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-riscv64-musl@4.41.0': resolution: {integrity: sha512-ieQljaZKuJpmWvd8gW87ZmSFwid6AxMDk5bhONJ57U8zT77zpZ/TPKkU9HpnnFrM4zsgr4kiGuzbIbZTGi7u9A==} cpu: [riscv64] os: [linux] - libc: [musl] '@rollup/rollup-linux-s390x-gnu@4.41.0': resolution: {integrity: sha512-/L3pW48SxrWAlVsKCN0dGLB2bi8Nv8pr5S5ocSM+S0XCn5RCVCXqi8GVtHFsOBBCSeR+u9brV2zno5+mg3S4Aw==} cpu: [s390x] os: [linux] - libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.41.0': resolution: {integrity: sha512-XMLeKjyH8NsEDCRptf6LO8lJk23o9wvB+dJwcXMaH6ZQbbkHu2dbGIUindbMtRN6ux1xKi16iXWu6q9mu7gDhQ==} cpu: [x64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-x64-musl@4.41.0': resolution: {integrity: sha512-m/P7LycHZTvSQeXhFmgmdqEiTqSV80zn6xHaQ1JSqwCtD1YGtwEK515Qmy9DcB2HK4dOUVypQxvhVSy06cJPEg==} cpu: [x64] os: [linux] - libc: [musl] '@rollup/rollup-win32-arm64-msvc@4.41.0': resolution: {integrity: sha512-4yodtcOrFHpbomJGVEqZ8fzD4kfBeCbpsUy5Pqk4RluXOdsWdjLnjhiKy2w3qzcASWd04fp52Xz7JKarVJ5BTg==} @@ -1124,49 +1116,41 @@ packages: resolution: {integrity: sha512-jon9M7DKRLGZ9VYSkFMflvNqu9hDtOCEnO2QAryFWgT6o6AXU8du56V7YqnaLKr6rAbZBWYsYpikF226v423QA==} cpu: [arm64] os: [linux] - libc: [glibc] '@unrs/resolver-binding-linux-arm64-musl@1.7.2': resolution: {integrity: sha512-c8Cg4/h+kQ63pL43wBNaVMmOjXI/X62wQmru51qjfTvI7kmCy5uHTJvK/9LrF0G8Jdx8r34d019P1DVJmhXQpA==} cpu: [arm64] os: [linux] - libc: [musl] '@unrs/resolver-binding-linux-ppc64-gnu@1.7.2': resolution: {integrity: sha512-A+lcwRFyrjeJmv3JJvhz5NbcCkLQL6Mk16kHTNm6/aGNc4FwPHPE4DR9DwuCvCnVHvF5IAd9U4VIs/VvVir5lg==} cpu: [ppc64] os: [linux] - libc: [glibc] '@unrs/resolver-binding-linux-riscv64-gnu@1.7.2': resolution: {integrity: sha512-hQQ4TJQrSQW8JlPm7tRpXN8OCNP9ez7PajJNjRD1ZTHQAy685OYqPrKjfaMw/8LiHCt8AZ74rfUVHP9vn0N69Q==} cpu: [riscv64] os: [linux] - libc: [glibc] '@unrs/resolver-binding-linux-riscv64-musl@1.7.2': resolution: {integrity: sha512-NoAGbiqrxtY8kVooZ24i70CjLDlUFI7nDj3I9y54U94p+3kPxwd2L692YsdLa+cqQ0VoqMWoehDFp21PKRUoIQ==} cpu: [riscv64] os: [linux] - libc: [musl] '@unrs/resolver-binding-linux-s390x-gnu@1.7.2': resolution: {integrity: sha512-KaZByo8xuQZbUhhreBTW+yUnOIHUsv04P8lKjQ5otiGoSJ17ISGYArc+4vKdLEpGaLbemGzr4ZeUbYQQsLWFjA==} cpu: [s390x] os: [linux] - libc: [glibc] '@unrs/resolver-binding-linux-x64-gnu@1.7.2': resolution: {integrity: sha512-dEidzJDubxxhUCBJ/SHSMJD/9q7JkyfBMT77Px1npl4xpg9t0POLvnWywSk66BgZS/b2Hy9Y1yFaoMTFJUe9yg==} cpu: [x64] os: [linux] - libc: [glibc] '@unrs/resolver-binding-linux-x64-musl@1.7.2': resolution: {integrity: sha512-RvP+Ux3wDjmnZDT4XWFfNBRVG0fMsc+yVzNFUqOflnDfZ9OYujv6nkh+GOr+watwrW4wdp6ASfG/e7bkDradsw==} cpu: [x64] os: [linux] - libc: [musl] '@unrs/resolver-binding-wasm32-wasi@1.7.2': resolution: {integrity: sha512-y797JBmO9IsvXVRCKDXOxjyAE4+CcZpla2GSoBQ33TVb3ILXuFnMrbR/QQZoauBYeOFuu4w3ifWLw52sdHGz6g==} @@ -2612,6 +2596,11 @@ packages: hachure-fill@0.5.2: resolution: {integrity: sha512-3GKBOn+m2LX9iq+JC1064cSFprJY4jL1jCXTcpnfER5HYE2l/4EfWSGzkPa/ZDBmYI0ZOEj5VHV/eKnPGkHuOg==} + handlebars@4.7.8: + resolution: {integrity: sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==} + engines: {node: '>=0.4.7'} + hasBin: true + has-ansi@2.0.0: resolution: {integrity: sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==} engines: {node: '>=0.10.0'} @@ -3402,6 +3391,9 @@ packages: resolution: {integrity: sha512-kKHJhxwpR/Okycz4HhQKKlhWe4ASEfPgkSWNmKFHd7+ezuQlxkA5cM3+XkBPvm1gmHen3w53qsYAv+8GwRrBlg==} engines: {node: '>=18'} + neo-async@2.6.2: + resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} + node-fetch-native@1.6.6: resolution: {integrity: sha512-8Mc2HhqPdlIfedsuZoc3yioPuzp6b+L5jRCRY1QzuWZh2EGJVQrGppC6V6cF0bLdbW0+O2YpqCA25aF/1lvipQ==} @@ -4365,6 +4357,11 @@ packages: ufo@1.6.1: resolution: {integrity: sha512-9a4/uxlTWJ4+a5i0ooc1rU7C7YOw3wT+UGqdeNNHWnOF9qcMBgLRS+4IYUqbczewFx4mLEig6gawh7X6mFlEkA==} + uglify-js@3.19.3: + resolution: {integrity: sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==} + engines: {node: '>=0.8.0'} + hasBin: true + unbox-primitive@1.1.0: resolution: {integrity: sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==} engines: {node: '>= 0.4'} @@ -4501,6 +4498,11 @@ packages: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} + vite-plugin-env-typed@0.0.2: + resolution: {integrity: sha512-IloScAeDfhG81diZuvoozs73LvELSG7h3q5Eim035TUbFpou4FanMLpVZqD0lZNH2oMMHILbzx6udmkg3/NFbA==} + peerDependencies: + vite: ^6.0.0 + vite-plugin-svg-icons@2.0.1: resolution: {integrity: sha512-6ktD+DhV6Rz3VtedYvBKKVA2eXF+sAQVaKkKLDSqGUfnhqXl3bj5PPkVTl3VexfTuZy66PmINi8Q6eFnVfRUmA==} peerDependencies: @@ -4646,6 +4648,9 @@ packages: resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} engines: {node: '>=0.10.0'} + wordwrap@1.0.0: + resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==} + wrap-ansi@6.2.0: resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==} engines: {node: '>=8'} @@ -7584,6 +7589,15 @@ snapshots: hachure-fill@0.5.2: {} + handlebars@4.7.8: + dependencies: + minimist: 1.2.8 + neo-async: 2.6.2 + source-map: 0.6.1 + wordwrap: 1.0.0 + optionalDependencies: + uglify-js: 3.19.3 + has-ansi@2.0.0: dependencies: ansi-regex: 2.1.1 @@ -8543,6 +8557,8 @@ snapshots: natural-orderby@5.0.0: {} + neo-async@2.6.2: {} + node-fetch-native@1.6.6: {} node-releases@2.0.19: {} @@ -9521,6 +9537,9 @@ snapshots: ufo@1.6.1: {} + uglify-js@3.19.3: + optional: true + unbox-primitive@1.1.0: dependencies: call-bound: 1.0.4 @@ -9735,6 +9754,11 @@ snapshots: vary@1.1.2: {} + vite-plugin-env-typed@0.0.2(vite@6.3.5(@types/node@22.15.19)(jiti@2.4.2)(sass-embedded@1.89.0)(yaml@2.8.0)): + dependencies: + handlebars: 4.7.8 + vite: 6.3.5(@types/node@22.15.19)(jiti@2.4.2)(sass-embedded@1.89.0)(yaml@2.8.0) + vite-plugin-svg-icons@2.0.1(vite@6.3.5(@types/node@22.15.19)(jiti@2.4.2)(sass-embedded@1.89.0)(yaml@2.8.0)): dependencies: '@types/svgo': 2.6.4 @@ -9894,6 +9918,8 @@ snapshots: word-wrap@1.2.5: {} + wordwrap@1.0.0: {} + wrap-ansi@6.2.0: dependencies: ansi-styles: 4.3.0 diff --git a/vite.config.ts b/vite.config.ts index 5a9b6a5..8be180c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,36 +1,16 @@ import { defineConfig, loadEnv } from "vite"; -import vue from "@vitejs/plugin-vue"; -import AutoImport from "unplugin-auto-import/vite"; -import Components from "unplugin-vue-components/vite"; -import { ElementPlusResolver } from "unplugin-vue-components/resolvers"; -import UnoCSS from "unocss/vite"; -import createSvgIcon from "./vite/plugins/svg-icon"; import path from "path"; +import plugins from "./.build/plugins"; // TODO: 开发一个环境变量ts类型处理的插件 // https://vite.dev/config/ -export default defineConfig(({ mode, command }) => { +export default defineConfig((cnf) => { + const { mode } = cnf; const env = loadEnv(mode, process.cwd()); const { VITE_APP_ENV } = env; return { base: VITE_APP_ENV === "production" ? "/" : "/", - plugins: [ - UnoCSS(), - vue(), - AutoImport({ - imports: ["vue"], - eslintrc: { - enabled: true, - }, - resolvers: [ElementPlusResolver()], - dts: path.resolve(__dirname, "./types/auto-imports.d.ts"), - }), - Components({ - resolvers: [ElementPlusResolver()], - dts: path.resolve(__dirname, "./types/components.d.ts"), - }), - createSvgIcon(command === "build"), - ], + plugins: plugins(cnf), resolve: { alias: { "@": path.resolve(__dirname, "./src"), diff --git a/vite/plugins/svg-icon.ts b/vite/plugins/svg-icon.ts deleted file mode 100644 index a3746c7..0000000 --- a/vite/plugins/svg-icon.ts +++ /dev/null @@ -1,20 +0,0 @@ -import path from 'node:path'; -import process from 'node:process'; // 新增此行引入 process 模块 -import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'; - -export default function createSvgIcon(isBuild: boolean) { - return createSvgIconsPlugin({ - iconDirs: [ - path.resolve(process.cwd(), 'src/assets/icons/svg'), - path.resolve(process.cwd(), 'src/assets/icons/Buildings'), - path.resolve(process.cwd(), 'src/assets/icons/Business'), - path.resolve(process.cwd(), 'src/assets/icons/Device'), - path.resolve(process.cwd(), 'src/assets/icons/Document'), - path.resolve(process.cwd(), 'src/assets/icons/Others'), - path.resolve(process.cwd(), 'src/assets/icons/System'), - path.resolve(process.cwd(), 'src/assets/icons/User'), - ], - symbolId: 'icon-[dir]-[name]', - svgoOptions: isBuild, - }); -}