From 3922c16601266e78ee3b90936ba49305c6c8b09a Mon Sep 17 00:00:00 2001
From: ahao <liuhaoai545@gmail.com>
Date: 星期三, 27 十二月 2023 12:12:51 +0800
Subject: [PATCH] fix 修复 vue 类型识别问题
---
src/components/ImageUpload/index.vue | 4
src/types/element.d.ts | 3
src/types/router.d.ts | 3
src/store/modules/tagsView.ts | 86 +++++++++++------
src/store/modules/user.ts | 4
src/layout/components/TagsView/index.vue | 51 +++++----
src/views/system/user/authRole.vue | 13 ++
src/store/modules/permission.ts | 25 ++++
src/layout/components/IframeToggle/index.vue | 1
src/views/system/role/authUser.vue | 13 ++
src/views/tool/gen/index.vue | 5
src/layout/components/TagsView/ScrollPane.vue | 6
src/views/system/dict/data.vue | 15 ++
src/views/tool/gen/editTable.vue | 13 ++
src/components/TopNav/index.vue | 2
src/layout/components/AppMain.vue | 3
src/layout/components/Sidebar/index.vue | 2
src/plugins/tab.ts | 42 +++++---
src/components/HeaderSearch/index.vue | 4
19 files changed, 204 insertions(+), 91 deletions(-)
diff --git a/src/components/HeaderSearch/index.vue b/src/components/HeaderSearch/index.vue
index f6143d0..a785958 100644
--- a/src/components/HeaderSearch/index.vue
+++ b/src/components/HeaderSearch/index.vue
@@ -36,7 +36,7 @@
const fuse = ref();
const headerSearchSelectRef = ref<ElSelectInstance>();
const router = useRouter();
-const routes = computed(() => usePermissionStore().routes);
+const routes = computed(() => usePermissionStore().getRoutes());
const click = () => {
show.value = !show.value;
@@ -149,7 +149,7 @@
}
});
-watch(searchPool, (list) => {
+watch(searchPool, (list: Router) => {
initFuse(list);
});
</script>
diff --git a/src/components/ImageUpload/index.vue b/src/components/ImageUpload/index.vue
index 6b7a39b..ae5cd45 100644
--- a/src/components/ImageUpload/index.vue
+++ b/src/components/ImageUpload/index.vue
@@ -81,14 +81,14 @@
watch(
() => props.modelValue,
- async (val) => {
+ async (val: string) => {
if (val) {
// 棣栧厛灏嗗�艰浆涓烘暟缁�
let list: OssVO[] = [];
if (Array.isArray(val)) {
list = val as OssVO[];
} else {
- const res = await listByIds(val as string);
+ const res = await listByIds(val);
list = res.data;
}
// 鐒跺悗灏嗘暟缁勮浆涓哄璞℃暟缁�
diff --git a/src/components/TopNav/index.vue b/src/components/TopNav/index.vue
index 6b416d4..c41177e 100644
--- a/src/components/TopNav/index.vue
+++ b/src/components/TopNav/index.vue
@@ -43,7 +43,7 @@
// 涓婚棰滆壊
const theme = computed(() => settingsStore.theme);
// 鎵�鏈夌殑璺敱淇℃伅
-const routers = computed(() => permissionStore.topbarRouters);
+const routers = computed(() => permissionStore.getTopbarRoutes());
// 椤堕儴鏄剧ず鑿滃崟
const topMenus = computed(() => {
diff --git a/src/layout/components/AppMain.vue b/src/layout/components/AppMain.vue
index b7c6ef0..2b38a4e 100644
--- a/src/layout/components/AppMain.vue
+++ b/src/layout/components/AppMain.vue
@@ -12,8 +12,9 @@
</template>
<script setup name="AppMain" lang="ts">
-import useTagsViewStore from '@/store/modules/tagsView';
import useSettingsStore from '@/store/modules/settings';
+import useTagsViewStore from '@/store/modules/tagsView';
+
import IframeToggle from './IframeToggle/index.vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const tagsViewStore = useTagsViewStore();
diff --git a/src/layout/components/IframeToggle/index.vue b/src/layout/components/IframeToggle/index.vue
index 870624c..2de529d 100644
--- a/src/layout/components/IframeToggle/index.vue
+++ b/src/layout/components/IframeToggle/index.vue
@@ -10,6 +10,7 @@
<script setup lang="ts">
import InnerLink from '../InnerLink/index.vue';
+
import useTagsViewStore from '@/store/modules/tagsView';
const route = useRoute();
diff --git a/src/layout/components/Sidebar/index.vue b/src/layout/components/Sidebar/index.vue
index f42473a..3fd5593 100644
--- a/src/layout/components/Sidebar/index.vue
+++ b/src/layout/components/Sidebar/index.vue
@@ -35,7 +35,7 @@
const appStore = useAppStore();
const settingsStore = useSettingsStore();
const permissionStore = usePermissionStore();
-const sidebarRouters = computed<RouteRecordRaw[]>(() => permissionStore.sidebarRouters);
+const sidebarRouters = computed<RouteRecordRaw[]>(() => permissionStore.getSidebarRoutes());
const showLogo = computed(() => settingsStore.sidebarLogo);
const sideTheme = computed(() => settingsStore.sideTheme);
const theme = computed(() => settingsStore.theme);
diff --git a/src/layout/components/TagsView/ScrollPane.vue b/src/layout/components/TagsView/ScrollPane.vue
index 2223070..3b30043 100644
--- a/src/layout/components/TagsView/ScrollPane.vue
+++ b/src/layout/components/TagsView/ScrollPane.vue
@@ -5,13 +5,13 @@
</template>
<script setup lang="ts">
+import { RouteLocationNormalized } from 'vue-router';
import useTagsViewStore from '@/store/modules/tagsView';
-import { TagView } from 'vue-router';
const tagAndTagSpacing = ref(4);
const scrollContainerRef = ref<ElScrollbarInstance>();
-const scrollWrapper = computed(() => scrollContainerRef.value?.$refs.wrapRef as any);
+const scrollWrapper = computed(() => scrollContainerRef.value?.$refs.wrapRef);
onMounted(() => {
scrollWrapper.value?.addEventListener('scroll', emitScroll, true);
@@ -33,7 +33,7 @@
const tagsViewStore = useTagsViewStore();
const visitedViews = computed(() => tagsViewStore.visitedViews);
-const moveToTarget = (currentTag: TagView) => {
+const moveToTarget = (currentTag: RouteLocationNormalized) => {
const $container = scrollContainerRef.value?.$el;
const $containerWidth = $container.offsetWidth;
const $scrollWrapper = scrollWrapper.value;
diff --git a/src/layout/components/TagsView/index.vue b/src/layout/components/TagsView/index.vue
index 0e23caa..1e12ca4 100644
--- a/src/layout/components/TagsView/index.vue
+++ b/src/layout/components/TagsView/index.vue
@@ -32,24 +32,24 @@
<script setup lang="ts">
import ScrollPane from './ScrollPane.vue';
import { getNormalPath } from '@/utils/ruoyi';
-import useTagsViewStore from '@/store/modules/tagsView';
import useSettingsStore from '@/store/modules/settings';
import usePermissionStore from '@/store/modules/permission';
-import { RouteRecordRaw, TagView } from 'vue-router';
+import useTagsViewStore from '@/store/modules/tagsView';
+import { RouteRecordRaw, RouteLocationNormalized } from 'vue-router';
const visible = ref(false);
const top = ref(0);
const left = ref(0);
-const selectedTag = ref<TagView>({});
-const affixTags = ref<TagView[]>([]);
+const selectedTag = ref<RouteLocationNormalized>();
+const affixTags = ref<RouteLocationNormalized[]>([]);
const scrollPaneRef = ref<InstanceType<typeof ScrollPane>>();
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const route = useRoute();
const router = useRouter();
-const visitedViews = computed(() => useTagsViewStore().visitedViews);
-const routes = computed(() => usePermissionStore().routes);
+const visitedViews = computed(() => useTagsViewStore().getVisitedViews());
+const routes = computed(() => usePermissionStore().getRoutes());
const theme = computed(() => useSettingsStore().theme);
watch(route, () => {
@@ -64,18 +64,18 @@
}
});
-const isActive = (r: TagView): boolean => {
+const isActive = (r: RouteLocationNormalized): boolean => {
return r.path === route.path;
};
-const activeStyle = (tag: TagView) => {
+const activeStyle = (tag: RouteLocationNormalized) => {
if (!isActive(tag)) return {};
return {
'background-color': theme.value,
'border-color': theme.value
};
};
-const isAffix = (tag: TagView) => {
- return tag.meta && tag.meta.affix;
+const isAffix = (tag: RouteLocationNormalized) => {
+ return tag?.meta && tag?.meta?.affix;
};
const isFirstView = () => {
try {
@@ -92,12 +92,17 @@
}
};
const filterAffixTags = (routes: RouteRecordRaw[], basePath = '') => {
- let tags: TagView[] = [];
+ let tags: RouteLocationNormalized[] = [];
routes.forEach((route) => {
if (route.meta && route.meta.affix) {
const tagPath = getNormalPath(basePath + '/' + route.path);
tags.push({
+ hash: '',
+ matched: [],
+ params: undefined,
+ query: undefined,
+ redirectedFrom: undefined,
fullPath: tagPath,
path: tagPath,
name: route.name as string,
@@ -114,7 +119,7 @@
return tags;
};
const initTags = () => {
- const res = filterAffixTags(routes.value as any);
+ const res = filterAffixTags(routes.value);
affixTags.value = res;
for (const tag of res) {
// Must have tag name
@@ -143,19 +148,19 @@
scrollPaneRef.value?.moveToTarget(r);
// when query is different then update
if (r.fullPath !== route.fullPath) {
- useTagsViewStore().updateVisitedView(route as any);
+ useTagsViewStore().updateVisitedView(route);
}
}
}
});
};
-const refreshSelectedTag = (view: TagView) => {
+const refreshSelectedTag = (view: RouteLocationNormalized) => {
proxy?.$tab.refreshPage(view);
if (route.meta.link) {
- useTagsViewStore().delIframeView(route as any);
+ useTagsViewStore().delIframeView(route);
}
};
-const closeSelectedTag = (view: TagView) => {
+const closeSelectedTag = (view: RouteLocationNormalized) => {
proxy?.$tab.closePage(view).then(({ visitedViews }: any) => {
if (isActive(view)) {
toLastView(visitedViews, view);
@@ -163,15 +168,15 @@
});
};
const closeRightTags = () => {
- proxy?.$tab.closeRightPage(selectedTag.value).then((visitedViews: TagView[]) => {
- if (!visitedViews.find((i: TagView) => i.fullPath === route.fullPath)) {
+ proxy?.$tab.closeRightPage(selectedTag.value).then((visitedViews: RouteLocationNormalized[]) => {
+ if (!visitedViews.find((i: RouteLocationNormalized) => i.fullPath === route.fullPath)) {
toLastView(visitedViews);
}
});
};
const closeLeftTags = () => {
- proxy?.$tab.closeLeftPage(selectedTag.value).then((visitedViews: TagView[]) => {
- if (!visitedViews.find((i: TagView) => i.fullPath === route.fullPath)) {
+ proxy?.$tab.closeLeftPage(selectedTag.value).then((visitedViews: RouteLocationNormalized[]) => {
+ if (!visitedViews.find((i: RouteLocationNormalized) => i.fullPath === route.fullPath)) {
toLastView(visitedViews);
}
});
@@ -182,7 +187,7 @@
moveToCurrentTag();
});
};
-const closeAllTags = (view: TagView) => {
+const closeAllTags = (view: RouteLocationNormalized) => {
proxy?.$tab.closeAllPage().then(({ visitedViews }) => {
if (affixTags.value.some((tag) => tag.path === route.path)) {
return;
@@ -190,7 +195,7 @@
toLastView(visitedViews, view);
});
};
-const toLastView = (visitedViews: TagView[], view?: TagView) => {
+const toLastView = (visitedViews: RouteLocationNormalized[], view?: RouteLocationNormalized) => {
const latestView = visitedViews.slice(-1)[0];
if (latestView) {
router.push(latestView.fullPath as string);
@@ -205,7 +210,7 @@
}
}
};
-const openMenu = (tag: TagView, e: MouseEvent) => {
+const openMenu = (tag: RouteLocationNormalized, e: MouseEvent) => {
const menuMinWidth = 105;
const offsetLeft = proxy?.$el.getBoundingClientRect().left; // container margin left
const offsetWidth = proxy?.$el.offsetWidth; // container width
diff --git a/src/plugins/tab.ts b/src/plugins/tab.ts
index 259dfa5..dd240cd 100644
--- a/src/plugins/tab.ts
+++ b/src/plugins/tab.ts
@@ -1,19 +1,29 @@
-import { useTagsViewStore } from '@/store/modules/tagsView';
import router from '@/router';
-import { TagView, RouteLocationMatched } from 'vue-router';
+import { RouteLocationMatched, RouteLocationNormalized } from 'vue-router';
+import useTagsViewStore from '@/store/modules/tagsView';
export default {
/**
* 鍒锋柊褰撳墠tab椤电
* @param obj 鏍囩瀵硅薄
*/
- async refreshPage(obj?: TagView): Promise<void> {
+ async refreshPage(obj?: RouteLocationNormalized): Promise<void> {
const { path, query, matched } = router.currentRoute.value;
if (obj === undefined) {
matched.forEach((m: RouteLocationMatched) => {
if (m.components && m.components.default && m.components.default.name) {
if (!['Layout', 'ParentView'].includes(m.components.default.name)) {
- obj = { name: m.components.default.name, path: path, query: query };
+ obj = {
+ name: m.components.default.name,
+ path: path,
+ query: query,
+ matched: undefined,
+ fullPath: undefined,
+ hash: undefined,
+ params: undefined,
+ redirectedFrom: undefined,
+ meta: undefined
+ };
}
}
});
@@ -31,20 +41,20 @@
});
},
// 鍏抽棴褰撳墠tab椤电锛屾墦寮�鏂伴〉绛�
- closeOpenPage(obj: TagView): void {
- useTagsViewStore().delView(router.currentRoute.value as any);
+ closeOpenPage(obj: RouteLocationNormalized): void {
+ useTagsViewStore().delView(router.currentRoute.value);
if (obj !== undefined) {
router.push(obj);
}
},
// 鍏抽棴鎸囧畾tab椤电
- async closePage(obj?: TagView): Promise<{ visitedViews: TagView[]; cachedViews: string[] } | any> {
+ async closePage(obj?: RouteLocationNormalized): Promise<{ visitedViews: RouteLocationNormalized[]; cachedViews: string[] } | any> {
if (obj === undefined) {
// prettier-ignore
- const { visitedViews } = await useTagsViewStore().delView(router.currentRoute.value as any)
+ const { visitedViews } = await useTagsViewStore().delView(router.currentRoute.value)
const latestView = visitedViews.slice(-1)[0];
if (latestView) {
- return router.push(latestView.fullPath as any);
+ return router.push(latestView.fullPath);
}
return router.push('/');
}
@@ -55,16 +65,16 @@
return useTagsViewStore().delAllViews();
},
// 鍏抽棴宸︿晶tab椤电
- closeLeftPage(obj?: TagView) {
- return useTagsViewStore().delLeftTags(obj || (router.currentRoute.value as any));
+ closeLeftPage(obj?: RouteLocationNormalized) {
+ return useTagsViewStore().delLeftTags(obj || router.currentRoute.value);
},
// 鍏抽棴鍙充晶tab椤电
- closeRightPage(obj?: TagView) {
- return useTagsViewStore().delRightTags(obj || (router.currentRoute.value as any));
+ closeRightPage(obj?: RouteLocationNormalized) {
+ return useTagsViewStore().delRightTags(obj || router.currentRoute.value);
},
// 鍏抽棴鍏朵粬tab椤电
- closeOtherPage(obj?: TagView) {
- return useTagsViewStore().delOthersViews(obj || (router.currentRoute.value as any));
+ closeOtherPage(obj?: RouteLocationNormalized) {
+ return useTagsViewStore().delOthersViews(obj || router.currentRoute.value);
},
/**
* 鎵撳紑tab椤电
@@ -80,7 +90,7 @@
* 淇敼tab椤电
* @param obj 鏍囩瀵硅薄
*/
- updatePage(obj: TagView) {
+ updatePage(obj: RouteLocationNormalized) {
return useTagsViewStore().updateVisitedView(obj);
}
};
diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts
index 14d2387..cf12a73 100644
--- a/src/store/modules/permission.ts
+++ b/src/store/modules/permission.ts
@@ -18,6 +18,16 @@
const topbarRouters = ref<RouteRecordRaw[]>([]);
const sidebarRouters = ref<RouteRecordRaw[]>([]);
+ const getRoutes = (): RouteRecordRaw[] => {
+ return routes.value;
+ };
+ const getSidebarRoutes = (): RouteRecordRaw[] => {
+ return sidebarRouters.value;
+ };
+ const getTopbarRoutes = (): RouteRecordRaw[] => {
+ return topbarRouters.value;
+ };
+
const setRoutes = (newRoutes: RouteRecordRaw[]): void => {
addRoutes.value = newRoutes;
routes.value = constantRoutes.concat(newRoutes);
@@ -108,7 +118,20 @@
});
return children;
};
- return { routes, setRoutes, generateRoutes, setSidebarRouters, topbarRouters, sidebarRouters, defaultRoutes };
+ return {
+ routes,
+ topbarRouters,
+ sidebarRouters,
+ defaultRoutes,
+
+ getRoutes,
+ getSidebarRoutes,
+ getTopbarRoutes,
+
+ setRoutes,
+ generateRoutes,
+ setSidebarRouters
+ };
});
// 鍔ㄦ�佽矾鐢遍亶鍘嗭紝楠岃瘉鏄惁鍏峰鏉冮檺
diff --git a/src/store/modules/tagsView.ts b/src/store/modules/tagsView.ts
index 2735a05..b9502eb 100644
--- a/src/store/modules/tagsView.ts
+++ b/src/store/modules/tagsView.ts
@@ -1,38 +1,53 @@
-import { TagView, RouteRecordNormalized, RouteLocationNormalized } from 'vue-router';
+import { RouteLocationNormalized } from 'vue-router';
export const useTagsViewStore = defineStore('tagsView', () => {
- const visitedViews = ref<TagView[]>([]);
+ const visitedViews = ref<RouteLocationNormalized[]>([]);
const cachedViews = ref<string[]>([]);
- const iframeViews = ref<TagView[]>([]);
+ const iframeViews = ref<RouteLocationNormalized[]>([]);
- const addView = (view: TagView) => {
+ const getVisitedViews = (): RouteLocationNormalized[] => {
+ return visitedViews.value;
+ };
+ const getIframeViews = (): RouteLocationNormalized[] => {
+ return iframeViews.value;
+ };
+ const getCachedViews = (): string[] => {
+ return cachedViews.value;
+ };
+
+ const addView = (view: RouteLocationNormalized) => {
addVisitedView(view);
addCachedView(view);
};
- const addIframeView = (view: TagView): void => {
- if (iframeViews.value.some((v: TagView) => v.path === view.path)) return;
+ const addIframeView = (view: RouteLocationNormalized): void => {
+ if (iframeViews.value.some((v: RouteLocationNormalized) => v.path === view.path)) return;
iframeViews.value.push(
Object.assign({}, view, {
title: view.meta?.title || 'no-name'
})
);
};
- const delIframeView = (view: TagView): Promise<TagView[]> => {
+ const delIframeView = (view: RouteLocationNormalized): Promise<RouteLocationNormalized[]> => {
return new Promise((resolve) => {
- iframeViews.value = iframeViews.value.filter((item: TagView) => item.path !== view.path);
+ iframeViews.value = iframeViews.value.filter((item: RouteLocationNormalized) => item.path !== view.path);
resolve([...iframeViews.value]);
});
};
- const addVisitedView = (view: TagView): void => {
- if (visitedViews.value.some((v: TagView) => v.path === view.path)) return;
+ const addVisitedView = (view: RouteLocationNormalized): void => {
+ if (visitedViews.value.some((v: RouteLocationNormalized) => v.path === view.path)) return;
visitedViews.value.push(
Object.assign({}, view, {
title: view.meta?.title || 'no-name'
})
);
};
- const delView = (view: TagView): Promise<{ visitedViews: TagView[]; cachedViews: string[] }> => {
+ const delView = (
+ view: RouteLocationNormalized
+ ): Promise<{
+ visitedViews: RouteLocationNormalized[];
+ cachedViews: string[];
+ }> => {
return new Promise((resolve) => {
delVisitedView(view);
if (!isDynamicRoute(view)) {
@@ -45,7 +60,7 @@
});
};
- const delVisitedView = (view: TagView): Promise<TagView[]> => {
+ const delVisitedView = (view: RouteLocationNormalized): Promise<RouteLocationNormalized[]> => {
return new Promise((resolve) => {
for (const [i, v] of visitedViews.value.entries()) {
if (v.path === view.path) {
@@ -56,7 +71,7 @@
resolve([...visitedViews.value]);
});
};
- const delCachedView = (view?: TagView): Promise<string[]> => {
+ const delCachedView = (view?: RouteLocationNormalized): Promise<string[]> => {
let viewName = '';
if (view) {
viewName = view.name as string;
@@ -67,7 +82,12 @@
resolve([...cachedViews.value]);
});
};
- const delOthersViews = (view: TagView): Promise<{ visitedViews: TagView[]; cachedViews: string[] }> => {
+ const delOthersViews = (
+ view: RouteLocationNormalized
+ ): Promise<{
+ visitedViews: RouteLocationNormalized[];
+ cachedViews: string[];
+ }> => {
return new Promise((resolve) => {
delOthersVisitedViews(view);
delOthersCachedViews(view);
@@ -78,15 +98,15 @@
});
};
- const delOthersVisitedViews = (view: TagView): Promise<TagView[]> => {
+ const delOthersVisitedViews = (view: RouteLocationNormalized): Promise<RouteLocationNormalized[]> => {
return new Promise((resolve) => {
- visitedViews.value = visitedViews.value.filter((v: TagView) => {
+ visitedViews.value = visitedViews.value.filter((v: RouteLocationNormalized) => {
return v.meta?.affix || v.path === view.path;
});
resolve([...visitedViews.value]);
});
};
- const delOthersCachedViews = (view: TagView): Promise<string[]> => {
+ const delOthersCachedViews = (view: RouteLocationNormalized): Promise<string[]> => {
const viewName = view.name as string;
return new Promise((resolve) => {
const index = cachedViews.value.indexOf(viewName);
@@ -99,7 +119,7 @@
});
};
- const delAllViews = (): Promise<{ visitedViews: TagView[]; cachedViews: string[] }> => {
+ const delAllViews = (): Promise<{ visitedViews: RouteLocationNormalized[]; cachedViews: string[] }> => {
return new Promise((resolve) => {
delAllVisitedViews();
delAllCachedViews();
@@ -109,9 +129,9 @@
});
});
};
- const delAllVisitedViews = (): Promise<TagView[]> => {
+ const delAllVisitedViews = (): Promise<RouteLocationNormalized[]> => {
return new Promise((resolve) => {
- visitedViews.value = visitedViews.value.filter((tag: TagView) => tag.meta?.affix);
+ visitedViews.value = visitedViews.value.filter((tag: RouteLocationNormalized) => tag.meta?.affix);
resolve([...visitedViews.value]);
});
};
@@ -123,7 +143,7 @@
});
};
- const updateVisitedView = (view: TagView): void => {
+ const updateVisitedView = (view: RouteLocationNormalized): void => {
for (let v of visitedViews.value) {
if (v.path === view.path) {
v = Object.assign(v, view);
@@ -131,13 +151,13 @@
}
}
};
- const delRightTags = (view: TagView): Promise<TagView[]> => {
+ const delRightTags = (view: RouteLocationNormalized): Promise<RouteLocationNormalized[]> => {
return new Promise((resolve) => {
- const index = visitedViews.value.findIndex((v: TagView) => v.path === view.path);
+ const index = visitedViews.value.findIndex((v: RouteLocationNormalized) => v.path === view.path);
if (index === -1) {
return;
}
- visitedViews.value = visitedViews.value.filter((item: TagView, idx: number) => {
+ visitedViews.value = visitedViews.value.filter((item: RouteLocationNormalized, idx: number) => {
if (idx <= index || (item.meta && item.meta.affix)) {
return true;
}
@@ -150,13 +170,13 @@
resolve([...visitedViews.value]);
});
};
- const delLeftTags = (view: TagView): Promise<TagView[]> => {
+ const delLeftTags = (view: RouteLocationNormalized): Promise<RouteLocationNormalized[]> => {
return new Promise((resolve) => {
- const index = visitedViews.value.findIndex((v: TagView) => v.path === view.path);
+ const index = visitedViews.value.findIndex((v: RouteLocationNormalized) => v.path === view.path);
if (index === -1) {
return;
}
- visitedViews.value = visitedViews.value.filter((item: TagView, idx: number) => {
+ visitedViews.value = visitedViews.value.filter((item: RouteLocationNormalized, idx: number) => {
if (idx >= index || (item.meta && item.meta.affix)) {
return true;
}
@@ -170,7 +190,7 @@
});
};
- const addCachedView = (view: TagView): void => {
+ const addCachedView = (view: RouteLocationNormalized): void => {
const viewName = view.name as string;
if (!viewName) return;
if (cachedViews.value.includes(viewName)) return;
@@ -179,15 +199,20 @@
}
};
- const isDynamicRoute = (view: any): boolean => {
+ const isDynamicRoute = (view: RouteLocationNormalized): boolean => {
// 妫�鏌ュ尮閰嶇殑璺敱璁板綍涓槸鍚︽湁鍔ㄦ�佹
- return view.matched.some((m: RouteRecordNormalized) => m.path.includes(':'));
+ return view.matched.some((m) => m.path.includes(':'));
};
return {
visitedViews,
cachedViews,
iframeViews,
+
+ getVisitedViews,
+ getIframeViews,
+ getCachedViews,
+
addVisitedView,
addCachedView,
delVisitedView,
@@ -205,5 +230,4 @@
delIframeView
};
});
-
export default useTagsViewStore;
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index 7c02de0..4122294 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -1,9 +1,9 @@
import { to } from 'await-to-js';
-import defAva from '@/assets/images/profile.jpg';
-import store from '@/store';
import { getToken, removeToken, setToken } from '@/utils/auth';
import { login as loginApi, logout as logoutApi, getInfo as getUserInfo } from '@/api/login';
import { LoginData } from '@/api/types';
+import defAva from '@/assets/images/profile.jpg';
+import store from '@/store';
export const useUserStore = defineStore('user', () => {
const token = ref(getToken());
diff --git a/src/types/element.d.ts b/src/types/element.d.ts
index 2087773..9c544e4 100644
--- a/src/types/element.d.ts
+++ b/src/types/element.d.ts
@@ -1,6 +1,6 @@
import type * as ep from 'element-plus';
declare global {
- declare type ElTagType = '' | 'success' | 'warning' | 'info' | 'danger' | 'default' | 'primary';
+ declare type ElTagType = 'success' | 'info' | 'warning' | 'danger' | '';
declare type ElFormInstance = ep.FormInstance;
declare type ElTableInstance = ep.TableInstance;
declare type ElUploadInstance = ep.UploadInstance;
@@ -32,5 +32,4 @@
declare type ElFormRules = ep.FormRules;
declare type DateModelType = ep.DateModelType;
declare type UploadFile = ep.UploadFile;
-
}
diff --git a/src/types/router.d.ts b/src/types/router.d.ts
index f920921..11a60a0 100644
--- a/src/types/router.d.ts
+++ b/src/types/router.d.ts
@@ -22,6 +22,7 @@
interface _RouteLocationBase {
children?: _RouteRecordBase[];
path?: string;
+ title?: string;
}
interface TagView {
@@ -33,3 +34,5 @@
query?: LocationQuery;
}
}
+
+export {};
diff --git a/src/views/system/dict/data.vue b/src/views/system/dict/data.vue
index c6889ba..92cc29c 100644
--- a/src/views/system/dict/data.vue
+++ b/src/views/system/dict/data.vue
@@ -131,6 +131,7 @@
import { listData, getData, delData, addData, updateData } from '@/api/system/dict/data';
import { DictTypeVO } from '@/api/system/dict/type/types';
import { DictDataForm, DictDataQuery, DictDataVO } from '@/api/system/dict/data/types';
+import { RouteLocationNormalized } from 'vue-router';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const route = useRoute();
@@ -168,7 +169,7 @@
dictLabel: '',
dictValue: '',
cssClass: '',
- listClass: 'default',
+ listClass: '',
dictSort: 0,
remark: ''
};
@@ -228,7 +229,17 @@
};
/** 杩斿洖鎸夐挳鎿嶄綔 */
const handleClose = () => {
- const obj = { path: '/system/dict' };
+ const obj: RouteLocationNormalized = {
+ fullPath: '',
+ hash: '',
+ matched: [],
+ meta: undefined,
+ name: undefined,
+ params: undefined,
+ query: undefined,
+ redirectedFrom: undefined,
+ path: '/system/dict'
+ };
proxy?.$tab.closeOpenPage(obj);
};
/** 閲嶇疆鎸夐挳鎿嶄綔 */
diff --git a/src/views/system/role/authUser.vue b/src/views/system/role/authUser.vue
index 98beb1b..9ab11a4 100644
--- a/src/views/system/role/authUser.vue
+++ b/src/views/system/role/authUser.vue
@@ -69,6 +69,7 @@
import { UserQuery } from '@/api/system/user/types';
import { UserVO } from '@/api/system/user/types';
import SelectUser from './selectUser.vue';
+import { RouteLocationNormalized } from 'vue-router';
const route = useRoute();
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@@ -102,7 +103,17 @@
};
// 杩斿洖鎸夐挳
const handleClose = () => {
- const obj = { path: '/system/role' };
+ const obj: RouteLocationNormalized = {
+ path: '/system/role',
+ fullPath: '',
+ hash: '',
+ matched: [],
+ meta: undefined,
+ name: undefined,
+ params: undefined,
+ query: undefined,
+ redirectedFrom: undefined
+ };
proxy?.$tab.closeOpenPage(obj);
};
/** 鎼滅储鎸夐挳鎿嶄綔 */
diff --git a/src/views/system/user/authRole.vue b/src/views/system/user/authRole.vue
index b661811..656ffc2 100644
--- a/src/views/system/user/authRole.vue
+++ b/src/views/system/user/authRole.vue
@@ -58,6 +58,7 @@
import { RoleVO } from '@/api/system/role/types';
import { getAuthRole, updateAuthRole } from '@/api/system/user';
import { UserForm } from '@/api/system/user/types';
+import { RouteLocationNormalized } from 'vue-router';
const route = useRoute();
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@@ -91,7 +92,17 @@
};
/** 鍏抽棴鎸夐挳 */
const close = () => {
- const obj = { path: '/system/user' };
+ const obj: RouteLocationNormalized = {
+ fullPath: '',
+ hash: '',
+ matched: [],
+ meta: undefined,
+ name: undefined,
+ params: undefined,
+ query: undefined,
+ redirectedFrom: undefined,
+ path: '/system/user'
+ };
proxy?.$tab.closeOpenPage(obj);
};
/** 鎻愪氦鎸夐挳 */
diff --git a/src/views/tool/gen/editTable.vue b/src/views/tool/gen/editTable.vue
index d2f7375..2175a9c 100644
--- a/src/views/tool/gen/editTable.vue
+++ b/src/views/tool/gen/editTable.vue
@@ -119,6 +119,7 @@
import { DictTypeVO } from '@/api/system/dict/type/types';
import BasicInfoForm from './basicInfoForm.vue';
import GenInfoForm from './genInfoForm.vue';
+import { RouteLocationNormalized } from 'vue-router';
const route = useRoute();
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@@ -167,7 +168,17 @@
});
};
const close = () => {
- const obj = { path: '/tool/gen', query: { t: Date.now(), pageNum: route.query.pageNum } };
+ const obj: RouteLocationNormalized = {
+ path: '/tool/gen',
+ fullPath: '',
+ hash: '',
+ matched: [],
+ meta: undefined,
+ name: undefined,
+ params: undefined,
+ redirectedFrom: undefined,
+ query: { t: Date.now().toString(), pageNum: route.query.pageNum }
+ };
proxy?.$tab.closeOpenPage(obj);
};
diff --git a/src/views/tool/gen/index.vue b/src/views/tool/gen/index.vue
index 5bc0863..5ce1b67 100644
--- a/src/views/tool/gen/index.vue
+++ b/src/views/tool/gen/index.vue
@@ -143,7 +143,10 @@
dataName: ''
});
-const preview = ref<any>({
+const preview = ref<{
+ data: Record<string, string>;
+ activeName: string;
+}>({
data: {},
activeName: 'domain.java'
});
--
Gitblit v1.9.3