From 8cf313c1f46d2b6f417dd5f711f0c08d7a5a72b2 Mon Sep 17 00:00:00 2001 From: yuntian001 <479820787@qq.com> Date: Sun, 7 Aug 2022 12:55:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=AE=9A=E4=B9=89keepAlive?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E6=94=AF=E6=8C=81=E6=97=A0name=E7=BC=93?= =?UTF-8?q?=E5=AD=98=EF=BC=8C=E6=94=AF=E6=8C=81=E4=B8=8D=E5=90=8C=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E5=90=8C=E4=B8=80=E7=BB=84=E4=BB=B6=E5=A4=8D=E7=94=A8?= =?UTF-8?q?=E6=97=B6=E5=88=86=E5=88=AB=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 27 ++- mock/apiDemo/user.ts | 6 +- mock/helper.ts | 4 +- mock/index.ts | 8 +- package.json | 2 +- plugin/vueSetupExtend.ts | 20 +- src/api/user.ts | 6 +- src/app.ts | 6 +- src/app.vue | 6 +- src/components/meComponent.vue | 27 ++- src/components/meDarkSwitch.vue | 4 +- src/components/meKeepAlive/core/Suspense.ts | 26 +-- src/components/meKeepAlive/core/component.ts | 2 +- .../core/componentPublicInstance.ts | 6 +- src/components/meKeepAlive/core/devtools.ts | 76 ++++--- .../meKeepAlive/core/errorHandling.ts | 32 +-- src/components/meKeepAlive/core/renderer.ts | 186 +++++++++--------- src/components/meKeepAlive/core/vnode.ts | 20 +- src/components/meKeepAlive/core/warning.ts | 2 +- src/components/meKeepAlive/index.ts | 9 +- src/components/meLocaleSelect.vue | 4 +- src/components/meSizeSelect.vue | 4 +- src/config/index.ts | 4 +- src/directive/clickoutside.ts | 2 +- src/enums/eventEnmu.ts | 2 +- src/event/index.ts | 2 +- src/event/modules/core.ts | 11 +- .../components/header/components/left.vue | 6 +- .../components/header/components/right.vue | 27 +-- .../tags/components/contextmenu.vue | 63 +++--- .../header/components/tags/index.vue | 5 +- src/layout/components/header/index.vue | 14 +- .../sidebar/components/sidebarItem.vue | 8 +- src/layout/components/sidebar/index.vue | 2 +- src/layout/index.vue | 61 +++--- src/locales/helper.ts | 61 ++---- src/locales/hooks.ts | 53 ++++- src/router/guard/index.ts | 9 +- src/router/routes/1-dashboard.ts | 6 +- src/router/routes/2-other.ts | 4 +- src/router/routes/dashboard/1-index.ts | 4 +- src/router/routes/other/1-index.ts | 26 +-- src/store/modules/global.ts | 2 +- src/store/modules/route.ts | 34 ++-- src/store/modules/setting.ts | 8 +- src/store/modules/user.ts | 10 +- src/styles/common.scss | 7 +- src/utils/helper.ts | 10 +- src/utils/permison.ts | 68 +++---- src/utils/request.ts | 24 +-- src/utils/validate.ts | 2 +- src/views/dashboard/index.vue | 2 +- src/views/link.vue | 10 +- src/views/login/index.vue | 2 +- src/views/redirect.vue | 8 +- src/views/test/index.vue | 16 ++ src/views/test/lang/zh-cn.ts | 3 + tsconfig.json | 2 +- tsconfig.node.json | 6 +- types/vue-router.d.ts | 8 +- vite.config.ts | 125 ++++++------ 61 files changed, 634 insertions(+), 566 deletions(-) create mode 100644 src/views/test/index.vue create mode 100644 src/views/test/lang/zh-cn.ts diff --git a/index.html b/index.html index b9c319a8..d5bc929f 100644 --- a/index.html +++ b/index.html @@ -1,17 +1,16 @@ + + - - + + + + + me-admin + - - - - - me-admin - + +
+ + - -
- - - - + \ No newline at end of file diff --git a/mock/apiDemo/user.ts b/mock/apiDemo/user.ts index 5fc7b94e..5905ab46 100644 --- a/mock/apiDemo/user.ts +++ b/mock/apiDemo/user.ts @@ -16,21 +16,21 @@ const users = { introduction: '我是一个管理员', avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif', name: '超级管理员', - username:'admin', + username: 'admin', }, 'editor-token': { rules: ['edit', 'list'], introduction: '我是一个编辑者', avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif', name: '编辑员工', - username:'editor', + username: 'editor', }, 'viewer': { rules: ['list'], introduction: '我是一个查询者', avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif', name: '查看员工', - username:'viewer', + username: 'viewer', } } export default [ diff --git a/mock/helper.ts b/mock/helper.ts index d8773017..3d801b5d 100644 --- a/mock/helper.ts +++ b/mock/helper.ts @@ -1,5 +1,5 @@ export function success(data: any, msg = '操作成功') { - return { code: '200', data, msg } + return { code: '200', data, msg } } //code 401 代表token失效 @@ -18,5 +18,5 @@ export interface requestParams { * */ export function getRequestToken({ headers }: requestParams): string | undefined { - return headers ? headers['auth-token']:''; + return headers ? headers['auth-token'] : ''; } \ No newline at end of file diff --git a/mock/index.ts b/mock/index.ts index 15a469c7..c4f11b37 100644 --- a/mock/index.ts +++ b/mock/index.ts @@ -6,10 +6,10 @@ export function setupProdMockServer() { import: 'default', eager: true }); - let moduleArr:any[] = []; - Object.entries(modules).forEach(([key,module]:any)=>{ + let moduleArr: any[] = []; + Object.entries(modules).forEach(([key, module]: any) => { moduleArr = moduleArr.concat(module); - + }); - createProdMockServer([...moduleArr]) + createProdMockServer([...moduleArr]) } \ No newline at end of file diff --git a/package.json b/package.json index e4b897e3..957d133d 100644 --- a/package.json +++ b/package.json @@ -51,4 +51,4 @@ "vite-svg-loader": "^3.4.0", "vue-tsc": "^0.34.7" } -} +} \ No newline at end of file diff --git a/plugin/vueSetupExtend.ts b/plugin/vueSetupExtend.ts index f97a02e2..cd26a93e 100644 --- a/plugin/vueSetupExtend.ts +++ b/plugin/vueSetupExtend.ts @@ -1,5 +1,5 @@ import xregexp from 'xregexp'; -import { parse,compileScript } from '@vue/compiler-sfc'; +import { parse, compileScript } from '@vue/compiler-sfc'; import MagicString from 'magic-string' import { Plugin } from 'vite'; import { SFCDescriptor } from 'vue/compiler-sfc'; @@ -23,10 +23,10 @@ function getLangImport(content: string) { if (useI18nParams.endsWith(']')) { let arr = xregexp.matchRecursive(useI18nParams, '\\[', '\\]', 'g', { escapeChar: '\\', - valueNames: [null,null,'value',null], + valueNames: [null, null, 'value', null], }); let res = arr[arr.length - 1]; - if(res && /\,\s*$/.test(useI18nParams.slice(0,res.start-1))){ + if (res && /\,\s*$/.test(useI18nParams.slice(0, res.start - 1))) { return '[' + res.value + ']'; } } @@ -35,12 +35,12 @@ function getLangImport(content: string) { } -function getComponent(sfc: SFCDescriptor){ - const sfcScriptBlock = compileScript(sfc,{id:'vueSetupExtendCompile'}); +function getComponent(sfc: SFCDescriptor) { + const sfcScriptBlock = compileScript(sfc, { id: 'vueSetupExtendCompile' }); let components = []; - if(sfcScriptBlock.imports){ - for( let key in sfcScriptBlock.imports){ - if(/\.vue$/i.test(sfcScriptBlock.imports[key].source)){ + if (sfcScriptBlock.imports) { + for (let key in sfcScriptBlock.imports) { + if (/\.vue$/i.test(sfcScriptBlock.imports[key].source)) { components.push(key); } } @@ -49,7 +49,7 @@ function getComponent(sfc: SFCDescriptor){ } -export function supportScript(code: string, options:ExtendOptions) { +export function supportScript(code: string, options: ExtendOptions) { let s: MagicString | undefined const str = () => s || (s = new MagicString(code)) const { descriptor } = parse(code); @@ -65,7 +65,7 @@ export function supportScript(code: string, options:ExtendOptions) { attrs.langImport = `{{${langImport}}}`; } } - if(options.setComponents){ + if (options.setComponents) { const components = getComponent(descriptor); if (components.length) { attrs.components = `{{{${components}}}}`; diff --git a/src/api/user.ts b/src/api/user.ts index 0b820a6d..ce03b98b 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -31,9 +31,9 @@ export interface UserInfoResult { name: string,//名称 username: string//用户名 } -export function userInfoApi(returnAxios?:T) { - return request(() => ({ +export function userInfoApi(returnAxios?: T) { + return request(() => ({ url: api.userInfo, method: 'get' - }),{noLoading:true},returnAxios); + }), { noLoading: true }, returnAxios); } \ No newline at end of file diff --git a/src/app.ts b/src/app.ts index 5d44570f..fa150fd5 100644 --- a/src/app.ts +++ b/src/app.ts @@ -6,9 +6,9 @@ import meKeepAlive from '@/components/meKeepAlive'; import clickOutside from "@/directive/clickOutside"; export const app = createApp(App); export async function bootscrapt() { - app.component('sidebarItem',sidebarItem); - app.component('meKeepAlive',meKeepAlive); - app.directive('ClickOutside',clickOutside) + app.component('sidebarItem', sidebarItem); + app.component('meKeepAlive', meKeepAlive); + app.directive('ClickOutside', clickOutside) await Promise.allSettled(mitter.emit(event.ready, app)); app.mount('#app'); } \ No newline at end of file diff --git a/src/app.vue b/src/app.vue index 563717c6..459055ce 100644 --- a/src/app.vue +++ b/src/app.vue @@ -1,7 +1,7 @@ diff --git a/src/components/meComponent.vue b/src/components/meComponent.vue index ee298a89..e2af1ab9 100644 --- a/src/components/meComponent.vue +++ b/src/components/meComponent.vue @@ -1,27 +1,36 @@ - diff --git a/src/components/meDarkSwitch.vue b/src/components/meDarkSwitch.vue index b9be708c..1336af25 100644 --- a/src/components/meDarkSwitch.vue +++ b/src/components/meDarkSwitch.vue @@ -21,8 +21,8 @@ const settingStore = useSettingStore(); .#{$namespace}-switch { .#{$namespace}-switch__core { - border-color: getCssVar('switch-off', 'color')!important; - background-color: getCssVar('switch-off', 'color')!important; + border-color: getCssVar('switch-off', 'color') !important; + background-color: getCssVar('switch-off', 'color') !important; .#{$namespace}-switch__action { background-color: getCssVar('bg', 'color'); diff --git a/src/components/meKeepAlive/core/Suspense.ts b/src/components/meKeepAlive/core/Suspense.ts index 663ea187..4b4f24f5 100644 --- a/src/components/meKeepAlive/core/Suspense.ts +++ b/src/components/meKeepAlive/core/Suspense.ts @@ -1,21 +1,21 @@ -import { queuePostFlushCb, SuspenseBoundary} from "vue" +import { queuePostFlushCb, SuspenseBoundary } from "vue" import { isArray } from "@vue/shared" export function queueEffectWithSuspense( - fn: Function | Function[], - suspense: SuspenseBoundary | null - ): void { - if (suspense && suspense.pendingBranch) { - if (isArray(fn)) { - suspense.effects.push(...fn) - } else { - suspense.effects.push(fn) - } + fn: Function | Function[], + suspense: SuspenseBoundary | null +): void { + if (suspense && suspense.pendingBranch) { + if (isArray(fn)) { + suspense.effects.push(...fn) } else { - queuePostFlushCb(fn) + suspense.effects.push(fn) } + } else { + queuePostFlushCb(fn) } +} + +export const isSuspense = (type: any): boolean => type.__isSuspense - export const isSuspense = (type: any): boolean => type.__isSuspense - diff --git a/src/components/meKeepAlive/core/component.ts b/src/components/meKeepAlive/core/component.ts index 4ee1c20a..823ec5c6 100644 --- a/src/components/meKeepAlive/core/component.ts +++ b/src/components/meKeepAlive/core/component.ts @@ -1,5 +1,5 @@ import { ConcreteComponent } from "vue"; -import {isFunction} from '@vue/shared' +import { isFunction } from '@vue/shared' export function getComponentName( Component: ConcreteComponent, includeInferred = true diff --git a/src/components/meKeepAlive/core/componentPublicInstance.ts b/src/components/meKeepAlive/core/componentPublicInstance.ts index 7fe619e0..9cae11e0 100644 --- a/src/components/meKeepAlive/core/componentPublicInstance.ts +++ b/src/components/meKeepAlive/core/componentPublicInstance.ts @@ -1,6 +1,6 @@ import { ComponentInternalInstance } from "vue" export interface ComponentRenderContext { - [key: string]: any - _: ComponentInternalInstance - } \ No newline at end of file + [key: string]: any + _: ComponentInternalInstance +} \ No newline at end of file diff --git a/src/components/meKeepAlive/core/devtools.ts b/src/components/meKeepAlive/core/devtools.ts index aad1364a..0278292b 100644 --- a/src/components/meKeepAlive/core/devtools.ts +++ b/src/components/meKeepAlive/core/devtools.ts @@ -1,36 +1,52 @@ +import { number } from "@intlify/core-base" import { ComponentInternalInstance, devtools } from "vue" const enum DevtoolsHooks { - APP_INIT = 'app:init', - APP_UNMOUNT = 'app:unmount', - COMPONENT_UPDATED = 'component:updated', - COMPONENT_ADDED = 'component:added', - COMPONENT_REMOVED = 'component:removed', - COMPONENT_EMIT = 'component:emit', - PERFORMANCE_START = 'perf:start', - PERFORMANCE_END = 'perf:end' - } + APP_INIT = 'app:init', + APP_UNMOUNT = 'app:unmount', + COMPONENT_UPDATED = 'component:updated', + COMPONENT_ADDED = 'component:added', + COMPONENT_REMOVED = 'component:removed', + COMPONENT_EMIT = 'component:emit', + PERFORMANCE_START = 'perf:start', + PERFORMANCE_END = 'perf:end' +} export const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook( - DevtoolsHooks.COMPONENT_ADDED - ) + DevtoolsHooks.COMPONENT_ADDED +) - function createDevtoolsComponentHook(hook: DevtoolsHooks) { - return (component: ComponentInternalInstance) => { - emit( - hook, - component.appContext.app, - component.uid, - component.parent ? component.parent.uid : undefined, - component - ) - } +function createDevtoolsComponentHook(hook: DevtoolsHooks) { + return (component: ComponentInternalInstance) => { + emit( + hook, + component.appContext.app, + component.uid, + component.parent ? component.parent.uid : undefined, + component + ) } +} - function emit(event: string, ...args: any[]) { - if (devtools) { - devtools.emit(event, ...args) - } - //TODO::因为拿不到devtoolsNotInstalled和buffer这里做特别处理 - // else if (!devtoolsNotInstalled) { - // buffer.push({ event, args }) - // } - } \ No newline at end of file +function emit(event: string, ...args: any[]) { + // if (devtools) { + // return devtools.emit(event, ...args) + // } else if (!devtoolsNotInstalled) { + // buffer.push({ event, args }) + // } + //TODO::因为拿不到devtoolsNotInstalled和buffer这里只在devtools Installed 成功后处理 + if (devtools) { + return devtools.emit(event, ...args) + } + //TODO::因为拿不到devtoolsNotInstalled和buffer这里做特别处理 + // const doEmit = (event: string,frequency:number,...args: any[])=>{ + // if (devtools) { + // return devtools.emit(event, ...args) + // } + // if(frequency > 3){ + // return console.warn('devtools is Not installed'); + // } + // setTimeout(() => { + // doEmit(event,frequency++,...args); + // }, 1000); + // } + // doEmit(event,1,args); +} \ No newline at end of file diff --git a/src/components/meKeepAlive/core/errorHandling.ts b/src/components/meKeepAlive/core/errorHandling.ts index f3427828..04612d15 100644 --- a/src/components/meKeepAlive/core/errorHandling.ts +++ b/src/components/meKeepAlive/core/errorHandling.ts @@ -1,17 +1,17 @@ export const enum ErrorCodes { - SETUP_FUNCTION, - RENDER_FUNCTION, - WATCH_GETTER, - WATCH_CALLBACK, - WATCH_CLEANUP, - NATIVE_EVENT_HANDLER, - COMPONENT_EVENT_HANDLER, - VNODE_HOOK, - DIRECTIVE_HOOK, - TRANSITION_HOOK, - APP_ERROR_HANDLER, - APP_WARN_HANDLER, - FUNCTION_REF, - ASYNC_COMPONENT_LOADER, - SCHEDULER - } \ No newline at end of file + SETUP_FUNCTION, + RENDER_FUNCTION, + WATCH_GETTER, + WATCH_CALLBACK, + WATCH_CLEANUP, + NATIVE_EVENT_HANDLER, + COMPONENT_EVENT_HANDLER, + VNODE_HOOK, + DIRECTIVE_HOOK, + TRANSITION_HOOK, + APP_ERROR_HANDLER, + APP_WARN_HANDLER, + FUNCTION_REF, + ASYNC_COMPONENT_LOADER, + SCHEDULER +} \ No newline at end of file diff --git a/src/components/meKeepAlive/core/renderer.ts b/src/components/meKeepAlive/core/renderer.ts index 2fb0cb99..04ec8ef2 100644 --- a/src/components/meKeepAlive/core/renderer.ts +++ b/src/components/meKeepAlive/core/renderer.ts @@ -25,101 +25,101 @@ export interface RendererInternals< // be directly exported. In order to avoid maintaining function signatures in // two places, we declare them once here and use them inside the closure. type PatchFn = ( - n1: VNode | null, // null means this is a mount - n2: VNode, - container: RendererElement, - anchor?: RendererNode | null, - parentComponent?: ComponentInternalInstance | null, - parentSuspense?: SuspenseBoundary | null, - isSVG?: boolean, - slotScopeIds?: string[] | null, - optimized?: boolean - ) => void - - + n1: VNode | null, // null means this is a mount + n2: VNode, + container: RendererElement, + anchor?: RendererNode | null, + parentComponent?: ComponentInternalInstance | null, + parentSuspense?: SuspenseBoundary | null, + isSVG?: boolean, + slotScopeIds?: string[] | null, + optimized?: boolean +) => void + + type UnmountFn = ( - vnode: VNode, - parentComponent: ComponentInternalInstance | null, - parentSuspense: SuspenseBoundary | null, - doRemove?: boolean, - optimized?: boolean - ) => void - - type RemoveFn = (vnode: VNode) => void - - type MoveFn = ( - vnode: VNode, - container: RendererElement, - anchor: RendererNode | null, - type: MoveType, - parentSuspense?: SuspenseBoundary | null - ) => void - - export const enum MoveType { - ENTER, - LEAVE, - REORDER - } - - export type MountComponentFn = ( - initialVNode: VNode, - container: RendererElement, - anchor: RendererNode | null, - parentComponent: ComponentInternalInstance | null, - parentSuspense: SuspenseBoundary | null, - isSVG: boolean, - optimized: boolean - ) => void - - - type MountChildrenFn = ( - children: VNodeArrayChildren, - container: RendererElement, - anchor: RendererNode | null, - parentComponent: ComponentInternalInstance | null, - parentSuspense: SuspenseBoundary | null, - isSVG: boolean, - slotScopeIds: string[] | null, - optimized: boolean, - start?: number - ) => void - - type PatchChildrenFn = ( - n1: VNode | null, - n2: VNode, - container: RendererElement, - anchor: RendererNode | null, - parentComponent: ComponentInternalInstance | null, - parentSuspense: SuspenseBoundary | null, - isSVG: boolean, - slotScopeIds: string[] | null, - optimized: boolean - ) => void - - type PatchBlockChildrenFn = ( - oldChildren: VNode[], - newChildren: VNode[], - fallbackContainer: RendererElement, - parentComponent: ComponentInternalInstance | null, - parentSuspense: SuspenseBoundary | null, - isSVG: boolean, - slotScopeIds: string[] | null - ) => void - - type NextFn = (vnode: VNode) => RendererNode | null - - - export const queuePostRenderEffect = __FEATURE_SUSPENSE__ + vnode: VNode, + parentComponent: ComponentInternalInstance | null, + parentSuspense: SuspenseBoundary | null, + doRemove?: boolean, + optimized?: boolean +) => void + +type RemoveFn = (vnode: VNode) => void + +type MoveFn = ( + vnode: VNode, + container: RendererElement, + anchor: RendererNode | null, + type: MoveType, + parentSuspense?: SuspenseBoundary | null +) => void + +export const enum MoveType { + ENTER, + LEAVE, + REORDER +} + +export type MountComponentFn = ( + initialVNode: VNode, + container: RendererElement, + anchor: RendererNode | null, + parentComponent: ComponentInternalInstance | null, + parentSuspense: SuspenseBoundary | null, + isSVG: boolean, + optimized: boolean +) => void + + +type MountChildrenFn = ( + children: VNodeArrayChildren, + container: RendererElement, + anchor: RendererNode | null, + parentComponent: ComponentInternalInstance | null, + parentSuspense: SuspenseBoundary | null, + isSVG: boolean, + slotScopeIds: string[] | null, + optimized: boolean, + start?: number +) => void + +type PatchChildrenFn = ( + n1: VNode | null, + n2: VNode, + container: RendererElement, + anchor: RendererNode | null, + parentComponent: ComponentInternalInstance | null, + parentSuspense: SuspenseBoundary | null, + isSVG: boolean, + slotScopeIds: string[] | null, + optimized: boolean +) => void + +type PatchBlockChildrenFn = ( + oldChildren: VNode[], + newChildren: VNode[], + fallbackContainer: RendererElement, + parentComponent: ComponentInternalInstance | null, + parentSuspense: SuspenseBoundary | null, + isSVG: boolean, + slotScopeIds: string[] | null +) => void + +type NextFn = (vnode: VNode) => RendererNode | null + + +export const queuePostRenderEffect = __FEATURE_SUSPENSE__ ? queueEffectWithSuspense : queuePostFlushCb - export type SetupRenderEffectFn = ( - instance: ComponentInternalInstance, - initialVNode: VNode, - container: RendererElement, - anchor: RendererNode | null, - parentSuspense: SuspenseBoundary | null, - isSVG: boolean, - optimized: boolean - ) => void \ No newline at end of file +export type SetupRenderEffectFn = ( + instance: ComponentInternalInstance, + initialVNode: VNode, + container: RendererElement, + anchor: RendererNode | null, + parentSuspense: SuspenseBoundary | null, + isSVG: boolean, + optimized: boolean +) => void \ No newline at end of file diff --git a/src/components/meKeepAlive/core/vnode.ts b/src/components/meKeepAlive/core/vnode.ts index ae488dba..e1a8c916 100644 --- a/src/components/meKeepAlive/core/vnode.ts +++ b/src/components/meKeepAlive/core/vnode.ts @@ -10,13 +10,13 @@ export type VNodeHook = export function invokeVNodeHook( - hook: VNodeHook, - instance: ComponentInternalInstance | null, - vnode: VNode, - prevVNode: VNode | null = null - ) { - callWithAsyncErrorHandling(hook, instance, ErrorCodes.VNODE_HOOK, [ - vnode, - prevVNode - ]) - } \ No newline at end of file + hook: VNodeHook, + instance: ComponentInternalInstance | null, + vnode: VNode, + prevVNode: VNode | null = null +) { + callWithAsyncErrorHandling(hook, instance, ErrorCodes.VNODE_HOOK, [ + vnode, + prevVNode + ]) +} \ No newline at end of file diff --git a/src/components/meKeepAlive/core/warning.ts b/src/components/meKeepAlive/core/warning.ts index dc00787d..faa6cdfd 100644 --- a/src/components/meKeepAlive/core/warning.ts +++ b/src/components/meKeepAlive/core/warning.ts @@ -1,4 +1,4 @@ -import { pauseTracking, resetTracking } from '@vue/reactivity' +import { pauseTracking, resetTracking } from '@vue/reactivity' export function warn(msg: string, ...args: any[]) { pauseTracking() diff --git a/src/components/meKeepAlive/index.ts b/src/components/meKeepAlive/index.ts index 682036fd..1c0b9ba4 100644 --- a/src/components/meKeepAlive/index.ts +++ b/src/components/meKeepAlive/index.ts @@ -215,11 +215,11 @@ const KeepAliveImpl: ComponentOptions = { // prune cache on includeKey/excludeKey prop change watch( () => [props.includeKey, props.excludeKey], - ([includeKey,excludeKey]) => { + ([includeKey, excludeKey]) => { includeKey && pruneCacheByKey(key => typeof key === 'string' && matches(includeKey, key)) - excludeKey && pruneCacheByKey(key =>{ + excludeKey && pruneCacheByKey(key => { return typeof key !== 'string' || !matches(excludeKey, key) - } ) + }) }, // prune post-render after `current` has been updated { flush: 'post', deep: true } @@ -288,14 +288,13 @@ const KeepAliveImpl: ComponentOptions = { const { include, exclude, includeKey, excludeKey, max } = props if ( (include && (!name || !matches(include, name))) || - (exclude && name && matches(exclude, name)) + (exclude && name && matches(exclude, name)) || (includeKey && (typeof key !== 'string' || !matches(includeKey, key))) || (excludeKey && typeof key === 'string' && matches(excludeKey, key)) ) { current = vnode return rawVNode } - console.log(key,vnode); const cachedVNode = cache.get(key) // clone vnode if it's reused because we are going to mutate it diff --git a/src/components/meLocaleSelect.vue b/src/components/meLocaleSelect.vue index d8485cc7..e750043c 100644 --- a/src/components/meLocaleSelect.vue +++ b/src/components/meLocaleSelect.vue @@ -1,6 +1,8 @@