浏览代码

fix: 代码瘦身

wanggaokun 1 年之前
父节点
当前提交
175426aa13

+ 2 - 2
build/plugins.ts

@@ -28,8 +28,8 @@ export const createVitePlugins = (viteEnv: ViteEnv, isBuild = false): (PluginOpt
     // name 可以写在 script 标签上
     vueSetupExtend({}),
     // vue api
-    createAutoImport(path),
-    createComponents(path),
+    createAutoImport(),
+    createComponents(),
     createIcons(),
     createSvgIconsPlugin(path, isBuild),
     // 创建打包压缩配置

+ 0 - 1
src/components/ECharts/index.vue

@@ -7,7 +7,6 @@ import { EChartsType, ECElementEvent } from 'echarts/core'
 import echarts, { ECOption } from './config'
 import { useDebounceFn } from '@vueuse/core'
 import { useGlobalStore } from '@/stores/modules/global'
-import { storeToRefs } from 'pinia'
 
 interface Props {
   option: ECOption

+ 0 - 1
src/hooks/useTheme.ts

@@ -1,4 +1,3 @@
-import { storeToRefs } from 'pinia'
 import { Theme } from './interface'
 import { ElMessage } from 'element-plus'
 import { DEFAULT_PRIMARY } from '@/config'

+ 0 - 1
src/layouts/components/Main/index.vue

@@ -16,7 +16,6 @@
 </template>
 
 <script setup lang="ts">
-import { storeToRefs } from 'pinia'
 import { useDebounceFn } from '@vueuse/core'
 import { useGlobalStore } from '@/stores/modules/global'
 import { useKeepAliveStore } from '@/stores/modules/keepAlive'

+ 0 - 1
src/layouts/components/ThemeDrawer/index.vue

@@ -128,7 +128,6 @@
 </template>
 
 <script setup lang="ts">
-import { storeToRefs } from 'pinia'
 import { useTheme } from '@/hooks/useTheme'
 import { useGlobalStore } from '@/stores/modules/global'
 import { LayoutType } from '@/stores/interface'

+ 0 - 1
src/stores/index.ts

@@ -1,4 +1,3 @@
-import { createPinia } from 'pinia'
 import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
 
 // pinia persist

+ 1 - 2
src/stores/modules/auth.ts

@@ -1,4 +1,3 @@
-import { defineStore } from 'pinia'
 import { AuthState } from '@/stores/interface'
 import { getRoutersApi } from '@/api/modules/system/menu'
 import { getFlatMenuList, getShowMenuList, getAllBreadcrumbList } from '@/utils'
@@ -29,7 +28,7 @@ export const useAuthStore = defineStore('admin-auth', {
     // Get AuthMenuList
     async getAuthMenuList() {
       const { data } = await getRoutersApi()
-      this.authMenuList = [...staticRouterList.data, ...data]
+      this.authMenuList = [...staticRouterList.data, ...data] as any[]
     },
     // Set RouteName
     async setRouteName(name: string) {

+ 0 - 2
src/stores/modules/dict.ts

@@ -1,5 +1,3 @@
-import { defineStore } from 'pinia'
-
 const useDictStore = defineStore('dict', {
   state: (): {
     dict: any[]

+ 0 - 1
src/stores/modules/global.ts

@@ -1,4 +1,3 @@
-import { defineStore } from 'pinia'
 import { GlobalState } from '@/stores/interface'
 import { DEFAULT_PRIMARY } from '@/config'
 import piniaPersistConfig from '@/stores/helper/persist'

+ 0 - 1
src/stores/modules/keepAlive.ts

@@ -1,4 +1,3 @@
-import { defineStore } from 'pinia'
 import { KeepAliveState } from '@/stores/interface'
 
 export const useKeepAliveStore = defineStore('admin-keepAlive', {

+ 0 - 1
src/stores/modules/tabs.ts

@@ -1,5 +1,4 @@
 import router from '@/routers'
-import { defineStore } from 'pinia'
 import { getUrlWithParams } from '@/utils'
 import { useKeepAliveStore } from './keepAlive'
 import { TabsState, TabsMenuProps } from '@/stores/interface'

+ 2 - 3
src/stores/modules/user.ts

@@ -1,10 +1,9 @@
-import { defineStore } from 'pinia'
 import { UserState } from '@/stores/interface'
 import piniaPersistConfig from '@/stores/helper/persist'
 import { getToken, setToken, removeToken } from '@/utils/token'
 import { loginApi, getInfoApi, logoutApi } from '@/api/modules/login'
 import defAva from '@/assets/images/defAva.png'
-import { Login } from '@/api/interface/index'
+import { LoginData } from '@/api/interface/login'
 export const useUserStore = defineStore('admin-user', {
   state: (): UserState => ({
     token: getToken(),
@@ -15,7 +14,7 @@ export const useUserStore = defineStore('admin-user', {
   }),
   getters: {},
   actions: {
-    userLogin(userInfo: Login.ReqLoginForm) {
+    userLogin(userInfo: LoginData) {
       return new Promise<any>((resolve, reject) => {
         loginApi(userInfo)
           .then((res: any) => {

+ 5 - 3
vite/plugins/auto-import.ts

@@ -2,12 +2,13 @@ import AutoImport from 'unplugin-auto-import/vite'
 import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
 import IconsResolver from 'unplugin-icons/resolver'
 
-export default (path: any) => {
+export default () => {
   return AutoImport({
     // 自动导入 Vue 相关函数
     imports: ['vue', 'vue-router', '@vueuse/core', 'pinia'],
     eslintrc: {
-      enabled: true,
+      // false
+      enabled: false,
       filepath: './.eslintrc-auto-import.json',
       globalsPropValue: true
     },
@@ -19,6 +20,7 @@ export default (path: any) => {
       })
     ],
     vueTemplate: true, // 是否在 vue 模板中自动导入
-    dts: path.resolve(path.resolve(__dirname, '../../src'), 'typings', 'auto-imports.d.ts')
+    dts: false
+    // dts: path.resolve(path.resolve(__dirname, '../../src'), 'typings', 'auto-imports.d.ts')
   })
 }

+ 3 - 2
vite/plugins/components.ts

@@ -2,7 +2,7 @@ import Components from 'unplugin-vue-components/vite'
 import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
 import IconsResolver from 'unplugin-icons/resolver'
 
-export default (path: any) => {
+export default () => {
   return Components({
     resolvers: [
       // 自动导入 Element Plus 组件
@@ -12,6 +12,7 @@ export default (path: any) => {
         enabledCollections: ['ep']
       })
     ],
-    dts: path.resolve(path.resolve(__dirname, '../../src'), 'typings', 'components.d.ts')
+    dts: false
+    // dts: path.resolve(path.resolve(__dirname, '../../src'), 'typings', 'components.d.ts')
   })
 }