From 53d599c2f06c7904b27e46d06fe748962c0640cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E4=B8=83=E5=B9=B4=E5=A4=8F?= <2098833867@qq.com> Date: Tue, 28 Feb 2023 14:38:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E4=B8=80=E4=BA=9BautoImport?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eslintrc/.eslintrc-auto-import.json | 15 --------------- package.json | 1 + src/api/router.ts | 2 +- typings/auto-imports.d.ts | 15 --------------- vite.config.ts | 6 ++++-- 5 files changed, 6 insertions(+), 33 deletions(-) diff --git a/eslintrc/.eslintrc-auto-import.json b/eslintrc/.eslintrc-auto-import.json index f257202..f840826 100644 --- a/eslintrc/.eslintrc-auto-import.json +++ b/eslintrc/.eslintrc-auto-import.json @@ -1,14 +1,12 @@ { "globals": { "EffectScope": true, - "bus": true, "buttonCodes": true, "casHandleChange": true, "clickoutside": true, "cloneDeep": true, "closeElLoading": true, "codesPermission": true, - "commonUtil": true, "computed": true, "copy": true, "copyValueToClipboard": true, @@ -18,7 +16,6 @@ "defineAsyncComponent": true, "defineComponent": true, "directives": true, - "doDelete": true, "effectScope": true, "elConfirm": true, "elConfirmNoCancelBtn": true, @@ -30,15 +27,10 @@ "filterAsyncRoutesByMenuList": true, "filterAsyncRoutesByRoles": true, "freshRouter": true, - "get": true, "getCurrentInstance": true, "getCurrentScope": true, "getLangInstance": true, - "getMyInfo": true, - "getMyRole": true, "getQueryParam": true, - "getRouterList": true, - "getTree": true, "h": true, "inject": true, "isExternal": true, @@ -48,11 +40,8 @@ "isRef": true, "lang": true, "langTitle": true, - "login": true, - "logout": true, "longpress": true, "markRaw": true, - "mockAxiosReq": true, "nextTick": true, "onActivated": true, "onBeforeMount": true, @@ -69,14 +58,12 @@ "onServerPrefetch": true, "onUnmounted": true, "onUpdated": true, - "post": true, "progressClose": true, "progressStart": true, "provide": true, "reactive": true, "readonly": true, "ref": true, - "request": true, "resetRouter": true, "resetState": true, "resizeHandler": true, @@ -87,7 +74,6 @@ "routerBack": true, "routerPush": true, "routerReplace": true, - "searchUser": true, "shallowReactive": true, "shallowReadonly": true, "shallowRef": true, @@ -96,7 +82,6 @@ "toRaw": true, "toRef": true, "toRefs": true, - "transactionList": true, "triggerRef": true, "unref": true, "useAttrs": true, diff --git a/package.json b/package.json index f4a649c..041d438 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "sortablejs": "1.15.0", "splitpanes": "^3.1.1", "tinymce": "^6.1.0", + "vite-plugin-vue-setup-extend": "^0.4.0", "vue": "^3.2.37", "vue-clipboard3": "^2.0.0", "vue-i18n": "9.1.10", diff --git a/src/api/router.ts b/src/api/router.ts index c1db274..9e66397 100644 --- a/src/api/router.ts +++ b/src/api/router.ts @@ -1,4 +1,4 @@ -import request from '@/utils/request' +import { post } from '@/utils/request' export function getRouterList(data) { return post('/menu/navigate', data) diff --git a/typings/auto-imports.d.ts b/typings/auto-imports.d.ts index 3b27028..6f26c03 100644 --- a/typings/auto-imports.d.ts +++ b/typings/auto-imports.d.ts @@ -2,14 +2,12 @@ export {} declare global { const EffectScope: typeof import('vue')['EffectScope'] - const bus: typeof import('../src/utils/bus')['default'] const buttonCodes: typeof import('../src/directives/button-codes')['default'] const casHandleChange: typeof import('../src/hooks/use-element')['casHandleChange'] const clickoutside: typeof import('../src/directives/example/clickoutside.js')['default'] const cloneDeep: typeof import('../src/hooks/use-common')['cloneDeep'] const closeElLoading: typeof import('../src/hooks/use-element')['closeElLoading'] const codesPermission: typeof import('../src/directives/codes-permission')['default'] - const commonUtil: typeof import('../src/utils/common-util')['default'] const computed: typeof import('vue')['computed'] const copy: typeof import('../src/directives/example/copy.js')['default'] const copyValueToClipboard: typeof import('../src/hooks/use-common')['copyValueToClipboard'] @@ -19,7 +17,6 @@ declare global { const defineAsyncComponent: typeof import('vue')['defineAsyncComponent'] const defineComponent: typeof import('vue')['defineComponent'] const directives: typeof import('../src/directives/index')['default'] - const doDelete: typeof import('../src/api/menuManagement')['doDelete'] const effectScope: typeof import('vue')['effectScope'] const elConfirm: typeof import('../src/hooks/use-element')['elConfirm'] const elConfirmNoCancelBtn: typeof import('../src/hooks/use-element')['elConfirmNoCancelBtn'] @@ -31,15 +28,10 @@ declare global { const filterAsyncRoutesByMenuList: typeof import('../src/hooks/use-permission')['filterAsyncRoutesByMenuList'] const filterAsyncRoutesByRoles: typeof import('../src/hooks/use-permission')['filterAsyncRoutesByRoles'] const freshRouter: typeof import('../src/hooks/use-permission')['freshRouter'] - const get: typeof import('../src/utils/request')['get'] const getCurrentInstance: typeof import('vue')['getCurrentInstance'] const getCurrentScope: typeof import('vue')['getCurrentScope'] const getLangInstance: typeof import('../src/hooks/use-common')['getLangInstance'] - const getMyInfo: typeof import('../src/api/user')['getMyInfo'] - const getMyRole: typeof import('../src/api/user')['getMyRole'] const getQueryParam: typeof import('../src/hooks/use-self-router')['getQueryParam'] - const getRouterList: typeof import('../src/api/router')['getRouterList'] - const getTree: typeof import('../src/api/menuManagement')['getTree'] const h: typeof import('vue')['h'] const inject: typeof import('vue')['inject'] const isExternal: typeof import('../src/hooks/use-layout')['isExternal'] @@ -49,11 +41,8 @@ declare global { const isRef: typeof import('vue')['isRef'] const lang: typeof import('../src/directives/lang')['default'] const langTitle: typeof import('../src/hooks/use-common')['langTitle'] - const login: typeof import('../src/api/user')['login'] - const logout: typeof import('../src/api/user')['logout'] const longpress: typeof import('../src/directives/example/longpress.js')['default'] const markRaw: typeof import('vue')['markRaw'] - const mockAxiosReq: typeof import('../src/utils/mock-axios-req')['default'] const nextTick: typeof import('vue')['nextTick'] const onActivated: typeof import('vue')['onActivated'] const onBeforeMount: typeof import('vue')['onBeforeMount'] @@ -70,14 +59,12 @@ declare global { const onServerPrefetch: typeof import('vue')['onServerPrefetch'] const onUnmounted: typeof import('vue')['onUnmounted'] const onUpdated: typeof import('vue')['onUpdated'] - const post: typeof import('../src/utils/request')['post'] const progressClose: typeof import('../src/hooks/use-permission')['progressClose'] const progressStart: typeof import('../src/hooks/use-permission')['progressStart'] 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 request: typeof import('../src/utils/request')['default'] const resetRouter: typeof import('../src/hooks/use-permission')['resetRouter'] const resetState: typeof import('../src/hooks/use-permission')['resetState'] const resizeHandler: typeof import('../src/hooks/use-layout')['resizeHandler'] @@ -88,7 +75,6 @@ declare global { const routerBack: typeof import('../src/hooks/use-self-router')['routerBack'] const routerPush: typeof import('../src/hooks/use-self-router')['routerPush'] const routerReplace: typeof import('../src/hooks/use-self-router')['routerReplace'] - const searchUser: typeof import('../src/api/remote-search')['searchUser'] const shallowReactive: typeof import('vue')['shallowReactive'] const shallowReadonly: typeof import('vue')['shallowReadonly'] const shallowRef: typeof import('vue')['shallowRef'] @@ -97,7 +83,6 @@ declare global { const toRaw: typeof import('vue')['toRaw'] const toRef: typeof import('vue')['toRef'] const toRefs: typeof import('vue')['toRefs'] - const transactionList: typeof import('../src/api/remote-search')['transactionList'] const triggerRef: typeof import('vue')['triggerRef'] const unref: typeof import('vue')['unref'] const useAttrs: typeof import('vue')['useAttrs'] diff --git a/vite.config.ts b/vite.config.ts index 5b8a4c9..b55358f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -12,6 +12,7 @@ import AutoImport from 'unplugin-auto-import/vite' import setting from './src/settings' const prodMock = setting.openProdMock import vitePluginSetupExtend from './src/plugins/vite-plugin-setup-extend' +import vitePluginVueSetupExtend from 'vite-plugin-vue-setup-extend' // import { visualizer } from 'rollup-plugin-visualizer' const pathSrc = resolve(__dirname, 'src') export default defineConfig(({ command, mode }) => { @@ -81,7 +82,7 @@ export default defineConfig(({ command, mode }) => { } ], //配置后会自动扫描目录下的文件 - dirs: ['src/hooks/**', 'src/utils/**', 'src/store/**', 'src/api/**', 'src/directives/**'], + dirs: ['src/hooks/**', 'src/store/**', 'src/directives/**'], eslintrc: { enabled: true, // Default `false` filepath: './eslintrc/.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json` @@ -90,7 +91,8 @@ export default defineConfig(({ command, mode }) => { dts: './typings/auto-imports.d.ts' }), - vitePluginSetupExtend({ inject: { title: setting.title } }) + vitePluginSetupExtend({ inject: { title: setting.title } }), + vitePluginVueSetupExtend() //依赖分析插件 // visualizer({ // open: true,