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 @@
-
+
+
+
-
+
+
+
},//全局语言变更前
- [eventEnmu.resize]:void,//窗口变化
+ [eventEnmu.resize]: void,//窗口变化
};
const mitter = Mitt(); // inferred as Emitter
export { eventEnmu as event, mitter }
\ No newline at end of file
diff --git a/src/event/modules/core.ts b/src/event/modules/core.ts
index 30996663..5decc420 100644
--- a/src/event/modules/core.ts
+++ b/src/event/modules/core.ts
@@ -1,16 +1,23 @@
import { installRoute } from '@/router';
-import { installStore, useRouteStore } from '@/store';
+import { installStore } from '@/store';
import { event, mitter } from '../index';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import 'element-plus/theme-chalk/dark/css-vars.css'
import { installIcon } from '@/icons';
import { installI18n } from '@/locales/i18n';
+import nProgress from 'nprogress';
+import 'nprogress/nprogress.css';
+
mitter.once(event.ready, async (app) => {
app.use(ElementPlus);
installIcon(app);
await installStore(app);
await installI18n(app);
installRoute(app);
- window.addEventListener('resize', ()=>mitter.emit(event.resize));
+ window.addEventListener('resize', () => mitter.emit(event.resize));
+ // 进度条配置项这样写
+ nProgress.configure({
+ showSpinner: false
+ });
});
\ No newline at end of file
diff --git a/src/layout/components/header/components/left.vue b/src/layout/components/header/components/left.vue
index 674b3769..5718652b 100644
--- a/src/layout/components/header/components/left.vue
+++ b/src/layout/components/header/components/left.vue
@@ -1,7 +1,8 @@
-
+
+
@@ -16,11 +17,12 @@
\ No newline at end of file
diff --git a/src/layout/components/sidebar/components/sidebarItem.vue b/src/layout/components/sidebar/components/sidebarItem.vue
index e5e0e9a6..7cbe5c50 100644
--- a/src/layout/components/sidebar/components/sidebarItem.vue
+++ b/src/layout/components/sidebar/components/sidebarItem.vue
@@ -1,7 +1,9 @@
-
-
+
+
@@ -51,7 +53,7 @@ const hasOneShowingChild = (children = [] as RouteRecordRaw[], parent: RouteReco
return false
};
const resolvePath = (routePath: string) => {
- if (isExternal(routePath) || isExternal(props.basePath)){
+ if (isExternal(routePath) || isExternal(props.basePath)) {
return routePath;
}
return resolve(props.basePath, routePath)
diff --git a/src/layout/components/sidebar/index.vue b/src/layout/components/sidebar/index.vue
index fee63342..8888fb02 100644
--- a/src/layout/components/sidebar/index.vue
+++ b/src/layout/components/sidebar/index.vue
@@ -26,7 +26,7 @@ watch(route, (route) => {
}
}
}, { immediate: true });
-
+
\ No newline at end of file
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index e682bee5..ad45b00a 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -18,7 +18,7 @@
- {{ t('登 录') }}
+ {{ t('登 录') }}
diff --git a/src/views/redirect.vue b/src/views/redirect.vue
index f809f34e..9062baa7 100644
--- a/src/views/redirect.vue
+++ b/src/views/redirect.vue
@@ -5,14 +5,14 @@ const route = useRoute();
const router = useRouter();
const fullPath = route.params.path as string;
const routeStore = useRouteStore();
-if(routeStore.noCacheFullPath.includes(fullPath)){
+if (routeStore.noCacheFullPath.includes(fullPath)) {
router.replace(fullPath);
-}else{
+} else {
routeStore.setNoCache(fullPath);
- onMounted(()=>{
+ onMounted(() => {
routeStore.removeNoCache(fullPath);
router.replace(fullPath);
-
+
});
}
diff --git a/src/views/test/index.vue b/src/views/test/index.vue
new file mode 100644
index 00000000..b9e77dec
--- /dev/null
+++ b/src/views/test/index.vue
@@ -0,0 +1,16 @@
+
+ test vue
+
+
+
+
\ No newline at end of file
diff --git a/src/views/test/lang/zh-cn.ts b/src/views/test/lang/zh-cn.ts
new file mode 100644
index 00000000..5c933b16
--- /dev/null
+++ b/src/views/test/lang/zh-cn.ts
@@ -0,0 +1,3 @@
+export default {
+
+}
\ No newline at end of file
diff --git a/tsconfig.json b/tsconfig.json
index 06280657..386453de 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,6 +1,6 @@
{
"compilerOptions": {
- "forceConsistentCasingInFileNames":true,
+ "forceConsistentCasingInFileNames": true,
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
diff --git a/tsconfig.node.json b/tsconfig.node.json
index 6893950d..1131246d 100644
--- a/tsconfig.node.json
+++ b/tsconfig.node.json
@@ -1,11 +1,11 @@
{
"compilerOptions": {
- "forceConsistentCasingInFileNames":true,
- "strict":true,
+ "forceConsistentCasingInFileNames": true,
+ "strict": true,
"composite": true,
"module": "esnext",
"moduleResolution": "node",
- "allowSyntheticDefaultImports":true,
+ "allowSyntheticDefaultImports": true,
},
"include": [
"vite.config.ts",
diff --git a/types/vue-router.d.ts b/types/vue-router.d.ts
index 6493725c..ed2b6f0f 100644
--- a/types/vue-router.d.ts
+++ b/types/vue-router.d.ts
@@ -1,4 +1,4 @@
-import { _RouteRecordBase,RouteMeta } from 'vue-router';
+import { _RouteRecordBase, RouteMeta } from 'vue-router';
declare module 'vue-router' {
interface RouteMeta extends Record {
// 标题设置该路由在侧边栏和面包屑中展示的名字
@@ -28,9 +28,9 @@ declare module 'vue-router' {
// 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
alwaysShow?: boolean,
}
- interface _RouteRecordBase {
+ interface _RouteRecordBase {
//没有需要展示的子集(会动态计算不要设置默认值)
- noShowingChildren?:boolean
- }
+ noShowingChildren?: boolean
+ }
}
export { };
\ No newline at end of file
diff --git a/vite.config.ts b/vite.config.ts
index d724a759..f8a6699a 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -6,14 +6,14 @@ import * as fs from 'fs';
import { default as autogenerationImport, getName } from 'vite-plugin-autogeneration-import-file';
import vueSetUpExtend from './plugin/vueSetupExtend';
import { viteMockServe } from 'vite-plugin-mock'
-import { ConfigEnv ,UserConfigExport} from 'vite';
+import { ConfigEnv, UserConfigExport } from 'vite';
function pathResolve(dir: string) {
return resolve(process.cwd(), '.', dir);
}
-export default ({ command,mode }: ConfigEnv): UserConfigExport =>{
+export default ({ command, mode }: ConfigEnv): UserConfigExport => {
return {
- plugins: [viteMockServe({
- mockPath: 'mock/apiDemo',
+ plugins: [viteMockServe({
+ mockPath: 'mock/apiDemo',
localEnabled: command === 'serve',
prodEnabled: command !== 'serve',
// 这样可以控制关闭mock的时候不让mock打包到最终代码内
@@ -21,70 +21,71 @@ export default ({ command,mode }: ConfigEnv): UserConfigExport =>{
import { setupProdMockServer } from '../mock/index';
setupProdMockServer();
`,
- }),
- vue(), svgLoader({
- svgoConfig: {
- plugins: [
- {
- name: 'preset-default',
- params: {
- overrides: {
- removeViewBox: false,//禁用插件
+ }),
+ vue(), svgLoader({
+ svgoConfig: {
+ plugins: [
+ {
+ name: 'preset-default',
+ params: {
+ overrides: {
+ removeViewBox: false,//禁用插件
+ },
+ },
+ },
+ {
+ name: 'removeAttrs',
+ params: {
+ attrs: '(width|height|fill)',//清除svg属性
},
},
+ ],
+ },
+ }), AutoImport({//自动加载函数
+ imports: ['vue', 'vue-router', 'pinia'],
+ // 可以选择auto-imports.d.ts生成的位置,使用ts建议设置为'src/auto-imports.d.ts'
+ dts: 'types/auto-imports.d.ts'
+ }), autogenerationImport([
+ {//svg icon
+ pattern: ['*.svg'],
+ dir: 'src/icons/svg',
+ toFile: 'types/meIconComments.d.ts',
+ name: (name) => {
+ name = getName(name);
+ return 'MeIcon' + name[0].toUpperCase() + name.slice(1);
},
+ template: fs.readFileSync('./template/meIconComments.d.ts', 'utf-8'),
+ codeTemplates: [{ key: '\n //code', template: '\n {{name}}: Icon;' }]
+ },
+ {//pinia module
+ pattern: ['**/*.{ts,js}', '*.{ts,js}'],
+ dir: 'src/store/modules',
+ toFile: 'src/store/module.ts',
+ name: 'use_{{name}}_store'
+ }
+ ]),
+ vueSetUpExtend({ setLangImport: true, exclude: ['steup', 'lang'], setComponents: true })
+ ],
+ resolve: {
+ alias: [
+ // /@/xxxx => src/xxxx
{
- name: 'removeAttrs',
- params: {
- attrs: '(width|height|fill)',//清除svg属性
- },
+ find: /@\//,
+ replacement: pathResolve('src') + '/',
},
+ {
+ find: 'vue-i18n',
+ replacement: 'vue-i18n/dist/vue-i18n.cjs.js'
+ }
],
+ extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
},
- }), AutoImport({//自动加载函数
- imports: ['vue', 'vue-router', 'pinia'],
- // 可以选择auto-imports.d.ts生成的位置,使用ts建议设置为'src/auto-imports.d.ts'
- dts: 'types/auto-imports.d.ts'
- }), autogenerationImport([
- {//svg icon
- pattern: ['*.svg'],
- dir: 'src/icons/svg',
- toFile: 'types/meIconComments.d.ts',
- name: (name) => {
- name = getName(name);
- return 'MeIcon' + name[0].toUpperCase() + name.slice(1);
- },
- template: fs.readFileSync('./template/meIconComments.d.ts', 'utf-8'),
- codeTemplates: [{ key: '\n //code', template: '\n {{name}}: Icon;' }]
- },
- {//pinia module
- pattern: ['**/*.{ts,js}', '*.{ts,js}'],
- dir: 'src/store/modules',
- toFile: 'src/store/module.ts',
- name: 'use_{{name}}_store'
+ define: {
+ __SSR__: `true`,
+ __DEV__: mode === 'development' ? `true` : `false`,
+ __COMPAT__: `false`,
+ __FEATURE_SUSPENSE__: `true`,
+ __FEATURE_PROD_DEVTOOLS__: `false`,
}
- ]),
- vueSetUpExtend({ setLangImport: true, exclude: ['steup', 'lang'], setComponents: true })
- ],
- resolve: {
- alias: [
- // /@/xxxx => src/xxxx
- {
- find: /@\//,
- replacement: pathResolve('src') + '/',
- },
- {
- find:'vue-i18n',
- replacement: 'vue-i18n/dist/vue-i18n.cjs.js'
- }
- ],
- extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
- },
- define:{
- __SSR__:`true`,
- __DEV__:mode === 'development'?`true`:`false`,
- __COMPAT__:`false`,
- __FEATURE_SUSPENSE__:`true`,
- __FEATURE_PROD_DEVTOOLS__: `false`,
}
-}}
+}