'admin-22.05.22:修复标记为需要缓存的tab页后,再次从左侧菜单打开,还是显示被缓存的页面内容(#I4UY3G),感谢@axcc1234、特别感谢群友@华仔'
This commit is contained in:
parent
2c8dbace6c
commit
1cd056cb83
@ -34,6 +34,7 @@
|
|||||||
- 🐞 修复 `router.push` 路径找不到时报错问题,`404、401 界面` 已移入到 `main` 主布局里(之前全屏)
|
- 🐞 修复 `router.push` 路径找不到时报错问题,`404、401 界面` 已移入到 `main` 主布局里(之前全屏)
|
||||||
- 🐞 修复 [全局修改组件大小失效了](https://gitee.com/lyt-top/vue-next-admin/issues/I551RP),感谢[lg_boy](https://gitee.com/lg_boy)
|
- 🐞 修复 [全局修改组件大小失效了](https://gitee.com/lyt-top/vue-next-admin/issues/I551RP),感谢[lg_boy](https://gitee.com/lg_boy)
|
||||||
- 🐞 修复 [修改一下配置时,需要每次都清理 `window.localStorage` 浏览器永久缓存,配置才会生效,问题解决#I567R1](https://gitee.com/lyt-top/vue-next-admin/issues/I567R1),感谢[@lanbao123](https://gitee.com/lanbao123)
|
- 🐞 修复 [修改一下配置时,需要每次都清理 `window.localStorage` 浏览器永久缓存,配置才会生效,问题解决#I567R1](https://gitee.com/lyt-top/vue-next-admin/issues/I567R1),感谢[@lanbao123](https://gitee.com/lanbao123)
|
||||||
|
- 🐞 修复 [标记为需要缓存的 tab 页后,再次从左侧菜单打开,还是显示被缓存的页面内容#I4UY3G](https://gitee.com/lyt-top/vue-next-admin/issues/I4UY3G),感谢@axcc1234、特别感谢群友@华仔
|
||||||
- 🌈 重构 路由(`/src/router/index.ts`)解决 No match found for location with path "xxx"(前端控制,后端控制未解决) 问题
|
- 🌈 重构 路由(`/src/router/index.ts`)解决 No match found for location with path "xxx"(前端控制,后端控制未解决) 问题
|
||||||
|
|
||||||
## 2.0.2
|
## 2.0.2
|
||||||
|
@ -131,6 +131,7 @@ cnpm run build
|
|||||||
- <a href="https://gitee.com/click33/sa-plus" target="_blank">@省长</a>
|
- <a href="https://gitee.com/click33/sa-plus" target="_blank">@省长</a>
|
||||||
- <a href="https://gitee.com/jskz/Jskz-SpringCloud" target="_blank">@唐参
|
- <a href="https://gitee.com/jskz/Jskz-SpringCloud" target="_blank">@唐参
|
||||||
- <a href="https://gitee.com/chuange" target="_blank">@川歌</a>
|
- <a href="https://gitee.com/chuange" target="_blank">@川歌</a>
|
||||||
|
- @华仔
|
||||||
|
|
||||||
#### 💌 支持作者
|
#### 💌 支持作者
|
||||||
|
|
||||||
|
1062
package-lock.json
generated
1062
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@ -18,7 +18,8 @@
|
|||||||
"echarts": "^5.3.2",
|
"echarts": "^5.3.2",
|
||||||
"echarts-gl": "^2.0.9",
|
"echarts-gl": "^2.0.9",
|
||||||
"echarts-wordcloud": "^2.0.0",
|
"echarts-wordcloud": "^2.0.0",
|
||||||
"element-plus": "^2.2.0",
|
"element-plus": "^2.2.1",
|
||||||
|
"js-cookie": "^3.0.1",
|
||||||
"jsplumb": "^2.15.6",
|
"jsplumb": "^2.15.6",
|
||||||
"mitt": "^3.0.0",
|
"mitt": "^3.0.0",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
@ -28,25 +29,25 @@
|
|||||||
"screenfull": "^6.0.1",
|
"screenfull": "^6.0.1",
|
||||||
"sortablejs": "^1.15.0",
|
"sortablejs": "^1.15.0",
|
||||||
"splitpanes": "^3.1.1",
|
"splitpanes": "^3.1.1",
|
||||||
"vue": "^3.2.33",
|
"vue": "^3.2.35",
|
||||||
"vue-clipboard3": "^2.0.0",
|
"vue-clipboard3": "^2.0.0",
|
||||||
"vue-grid-layout": "^3.0.0-beta1",
|
"vue-grid-layout": "^3.0.0-beta1",
|
||||||
"vue-i18n": "^9.1.10",
|
"vue-i18n": "^9.1.10",
|
||||||
"vue-router": "^4.0.15"
|
"vue-router": "^4.0.15"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^17.0.34",
|
"@types/node": "^17.0.35",
|
||||||
"@types/nprogress": "^0.2.0",
|
"@types/nprogress": "^0.2.0",
|
||||||
"@types/sortablejs": "^1.13.0",
|
"@types/sortablejs": "^1.13.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.25.0",
|
"@typescript-eslint/eslint-plugin": "^5.25.0",
|
||||||
"@typescript-eslint/parser": "^5.25.0",
|
"@typescript-eslint/parser": "^5.25.0",
|
||||||
"@vitejs/plugin-vue": "^2.3.3",
|
"@vitejs/plugin-vue": "^2.3.3",
|
||||||
"@vue/compiler-sfc": "^3.2.33",
|
"@vue/compiler-sfc": "^3.2.35",
|
||||||
"dotenv": "^16.0.1",
|
"dotenv": "^16.0.1",
|
||||||
"eslint": "^8.15.0",
|
"eslint": "^8.16.0",
|
||||||
"eslint-plugin-vue": "^9.0.1",
|
"eslint-plugin-vue": "^9.0.1",
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.6.2",
|
||||||
"sass": "^1.51.0",
|
"sass": "^1.52.1",
|
||||||
"sass-loader": "^13.0.0",
|
"sass-loader": "^13.0.0",
|
||||||
"typescript": "^4.6.4",
|
"typescript": "^4.6.4",
|
||||||
"vite": "^2.9.9",
|
"vite": "^2.9.9",
|
||||||
|
1
plugins.d.ts
vendored
1
plugins.d.ts
vendored
@ -1,3 +1,4 @@
|
|||||||
declare module 'vue-grid-layout';
|
declare module 'vue-grid-layout';
|
||||||
declare module 'qrcodejs2-fixes';
|
declare module 'qrcodejs2-fixes';
|
||||||
declare module 'splitpanes';
|
declare module 'splitpanes';
|
||||||
|
declare module 'js-cookie';
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-config-provider :size="getGlobalComponentSize" :locale="i18nLocale">
|
<el-config-provider :size="getGlobalComponentSize" :locale="i18nLocale">
|
||||||
<router-view v-show="themeConfig.lockScreenTime !== 0" />
|
<router-view v-show="themeConfig.lockScreenTime > 1" />
|
||||||
<LockScreen v-if="themeConfig.isLockScreen" />
|
<LockScreen v-if="themeConfig.isLockScreen" />
|
||||||
<Setings ref="setingsRef" v-show="themeConfig.lockScreenTime !== 0" />
|
<Setings ref="setingsRef" v-show="themeConfig.lockScreenTime > 1" />
|
||||||
<CloseFull />
|
<CloseFull v-if="!themeConfig.isLockScreen" />
|
||||||
</el-config-provider>
|
</el-config-provider>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -49,9 +49,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="layout-lock-screen-login-icon">
|
<div class="layout-lock-screen-login-icon">
|
||||||
<SvgIcon name="ele-Microphone" />
|
<SvgIcon name="ele-Microphone" :size="20" />
|
||||||
<SvgIcon name="ele-AlarmClock" />
|
<SvgIcon name="ele-AlarmClock" :size="20" />
|
||||||
<SvgIcon name="ele-SwitchButton" />
|
<SvgIcon name="ele-SwitchButton" :size="20" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
@ -255,11 +255,11 @@ export default defineComponent({
|
|||||||
bottom: 50px;
|
bottom: 50px;
|
||||||
&-time {
|
&-time {
|
||||||
font-size: 100px;
|
font-size: 100px;
|
||||||
color: var(--color-whites);
|
color: var(--el-color-white);
|
||||||
}
|
}
|
||||||
&-info {
|
&-info {
|
||||||
font-size: 40px;
|
font-size: 40px;
|
||||||
color: var(--color-whites);
|
color: var(--el-color-white);
|
||||||
}
|
}
|
||||||
&-minutes {
|
&-minutes {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
@ -272,7 +272,7 @@ export default defineComponent({
|
|||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
border: 1px solid var(--el-border-color-light, #ebeef5);
|
border: 1px solid var(--el-border-color-light, #ebeef5);
|
||||||
background: rgba(255, 255, 255, 0.1);
|
background: rgba(255, 255, 255, 0.1);
|
||||||
color: var(--color-whites);
|
color: var(--el-color-white);
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 30px;
|
right: 30px;
|
||||||
@ -288,7 +288,7 @@ export default defineComponent({
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: 150%;
|
top: 150%;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: var(--color-whites);
|
color: var(--el-color-white);
|
||||||
left: 50%;
|
left: 50%;
|
||||||
line-height: 1.2;
|
line-height: 1.2;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
@ -299,7 +299,7 @@ export default defineComponent({
|
|||||||
border: 1px solid rgba(255, 255, 255, 0.5);
|
border: 1px solid rgba(255, 255, 255, 0.5);
|
||||||
background: rgba(255, 255, 255, 0.2);
|
background: rgba(255, 255, 255, 0.2);
|
||||||
box-shadow: 0 0 12px 0 rgba(255, 255, 255, 0.5);
|
box-shadow: 0 0 12px 0 rgba(255, 255, 255, 0.5);
|
||||||
color: var(--color-whites);
|
color: var(--el-color-white);
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
i {
|
i {
|
||||||
@ -324,7 +324,7 @@ export default defineComponent({
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
color: var(--color-whites);
|
color: var(--el-color-white);
|
||||||
&-box {
|
&-box {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
|
@ -93,7 +93,6 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
// 当前路由字符串切割成数组,并删除第一项空内容
|
// 当前路由字符串切割成数组,并删除第一项空内容
|
||||||
const initRouteSplit = (path: string) => {
|
const initRouteSplit = (path: string) => {
|
||||||
state.breadcrumbList = [];
|
|
||||||
if (!themeConfig.value.isBreadcrumb) return false;
|
if (!themeConfig.value.isBreadcrumb) return false;
|
||||||
state.breadcrumbList = [routesList.value[0]];
|
state.breadcrumbList = [routesList.value[0]];
|
||||||
state.routeSplit = path.split('/');
|
state.routeSplit = path.split('/');
|
||||||
@ -129,12 +128,16 @@ export default defineComponent({
|
|||||||
height: inherit;
|
height: inherit;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding-left: 15px;
|
|
||||||
.layout-navbars-breadcrumb-icon {
|
.layout-navbars-breadcrumb-icon {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
margin-right: 15px;
|
|
||||||
color: var(--next-bg-topBarColor);
|
color: var(--next-bg-topBarColor);
|
||||||
|
height: 100%;
|
||||||
|
width: 40px;
|
||||||
|
opacity: 0.8;
|
||||||
|
&:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.layout-navbars-breadcrumb-span {
|
.layout-navbars-breadcrumb-span {
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
|
@ -97,7 +97,7 @@ export default defineComponent({
|
|||||||
});
|
});
|
||||||
// 页面卸载时
|
// 页面卸载时
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
proxy.mittBus.off('getBreadcrumbIndexSetFilterRoutes');
|
proxy.mittBus.off('getBreadcrumbIndexSetFilterRoutes', () => {});
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
setIsShowLogo,
|
setIsShowLogo,
|
||||||
|
@ -64,8 +64,10 @@ export default defineComponent({
|
|||||||
state.isShowSearch = true;
|
state.isShowSearch = true;
|
||||||
initTageView();
|
initTageView();
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
|
setTimeout(() => {
|
||||||
layoutMenuAutocompleteRef.value.focus();
|
layoutMenuAutocompleteRef.value.focus();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
// 搜索弹窗关闭
|
// 搜索弹窗关闭
|
||||||
const closeSearch = () => {
|
const closeSearch = () => {
|
||||||
|
@ -643,7 +643,7 @@ export default defineComponent({
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
proxy.mittBus.off('layoutMobileResize');
|
proxy.mittBus.off('layoutMobileResize', () => {});
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
openDrawer,
|
openDrawer,
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<i class="icon-skin iconfont" :title="$t('message.user.title3')"></i>
|
<i class="icon-skin iconfont" :title="$t('message.user.title3')"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="layout-navbars-breadcrumb-user-icon">
|
<div class="layout-navbars-breadcrumb-user-icon">
|
||||||
<el-popover placement="bottom" trigger="click" transition="el-zoom-in-top" :width="300">
|
<el-popover placement="bottom" trigger="click" transition="el-zoom-in-top" :width="300" :persistent="false">
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<el-badge :is-dot="true">
|
<el-badge :is-dot="true">
|
||||||
<el-icon :title="$t('message.user.title4')">
|
<el-icon :title="$t('message.user.title4')">
|
||||||
|
@ -67,6 +67,7 @@ import { storeToRefs } from 'pinia';
|
|||||||
import pinia from '/@/stores/index';
|
import pinia from '/@/stores/index';
|
||||||
import { useTagsViewRoutes } from '/@/stores/tagsViewRoutes';
|
import { useTagsViewRoutes } from '/@/stores/tagsViewRoutes';
|
||||||
import { useThemeConfig } from '/@/stores/themeConfig';
|
import { useThemeConfig } from '/@/stores/themeConfig';
|
||||||
|
import { useKeepALiveNames } from '/@/stores/keepAliveNames';
|
||||||
import { Session } from '/@/utils/storage';
|
import { Session } from '/@/utils/storage';
|
||||||
import { isObjectValueEqual } from '/@/utils/arrayOperation';
|
import { isObjectValueEqual } from '/@/utils/arrayOperation';
|
||||||
import other from '/@/utils/other';
|
import other from '/@/utils/other';
|
||||||
@ -115,6 +116,7 @@ export default defineComponent({
|
|||||||
const storesTagsViewRoutes = useTagsViewRoutes();
|
const storesTagsViewRoutes = useTagsViewRoutes();
|
||||||
const { themeConfig } = storeToRefs(storesThemeConfig);
|
const { themeConfig } = storeToRefs(storesThemeConfig);
|
||||||
const { tagsViewRoutes } = storeToRefs(storesTagsViewRoutes);
|
const { tagsViewRoutes } = storeToRefs(storesTagsViewRoutes);
|
||||||
|
const storesKeepALiveNames = useKeepALiveNames();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const state = reactive<TagsViewState>({
|
const state = reactive<TagsViewState>({
|
||||||
@ -176,6 +178,7 @@ export default defineComponent({
|
|||||||
if (v.meta.isAffix && !v.meta.isHide) {
|
if (v.meta.isAffix && !v.meta.isHide) {
|
||||||
v.url = setTagsViewHighlight(v);
|
v.url = setTagsViewHighlight(v);
|
||||||
state.tagsViewList.push({ ...v });
|
state.tagsViewList.push({ ...v });
|
||||||
|
storesKeepALiveNames.addCachedView(v);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
await addTagsView(route.path, route);
|
await addTagsView(route.path, route);
|
||||||
@ -202,6 +205,7 @@ export default defineComponent({
|
|||||||
if (findItem.meta.isLink && !findItem.meta.isIframe) return false;
|
if (findItem.meta.isLink && !findItem.meta.isIframe) return false;
|
||||||
to.meta.isDynamic ? (findItem.params = to.params) : (findItem.query = to.query);
|
to.meta.isDynamic ? (findItem.params = to.params) : (findItem.query = to.query);
|
||||||
findItem.url = setTagsViewHighlight(findItem);
|
findItem.url = setTagsViewHighlight(findItem);
|
||||||
|
await storesKeepALiveNames.addCachedView(findItem);
|
||||||
state.tagsViewList.push({ ...findItem });
|
state.tagsViewList.push({ ...findItem });
|
||||||
addBrowserSetSession(state.tagsViewList);
|
addBrowserSetSession(state.tagsViewList);
|
||||||
}
|
}
|
||||||
@ -247,19 +251,26 @@ export default defineComponent({
|
|||||||
if (to && to.meta.isDynamic) item.params = to?.params ? to?.params : route.params;
|
if (to && to.meta.isDynamic) item.params = to?.params ? to?.params : route.params;
|
||||||
else item.query = to?.query ? to?.query : route.query;
|
else item.query = to?.query ? to?.query : route.query;
|
||||||
item.url = setTagsViewHighlight(item);
|
item.url = setTagsViewHighlight(item);
|
||||||
|
await storesKeepALiveNames.addCachedView(item);
|
||||||
await state.tagsViewList.push({ ...item });
|
await state.tagsViewList.push({ ...item });
|
||||||
await addBrowserSetSession(state.tagsViewList);
|
await addBrowserSetSession(state.tagsViewList);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// 2、刷新当前 tagsView:
|
// 2、刷新当前 tagsView:
|
||||||
const refreshCurrentTagsView = (fullPath: string) => {
|
const refreshCurrentTagsView = async (fullPath: string) => {
|
||||||
|
const item = state.tagsViewList.find((v: any) => (getThemeConfig.value.isShareTagsView ? v.path === fullPath : v.url === fullPath));
|
||||||
|
if (item != null) {
|
||||||
|
await storesKeepALiveNames.delCachedView(item);
|
||||||
proxy.mittBus.emit('onTagsViewRefreshRouterView', fullPath);
|
proxy.mittBus.emit('onTagsViewRefreshRouterView', fullPath);
|
||||||
|
if (item.meta.isKeepAlive) storesKeepALiveNames.addCachedView(item);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// 3、关闭当前 tagsView:如果是设置了固定的(isAffix),不可以关闭
|
// 3、关闭当前 tagsView:如果是设置了固定的(isAffix),不可以关闭
|
||||||
const closeCurrentTagsView = (path: string) => {
|
const closeCurrentTagsView = (path: string) => {
|
||||||
state.tagsViewList.map((v: any, k: number, arr: any) => {
|
state.tagsViewList.map((v: any, k: number, arr: any) => {
|
||||||
if (!v.meta.isAffix) {
|
if (!v.meta.isAffix) {
|
||||||
if (getThemeConfig.value.isShareTagsView ? v.path === path : v.url === path) {
|
if (getThemeConfig.value.isShareTagsView ? v.path === path : v.url === path) {
|
||||||
|
storesKeepALiveNames.delCachedView(v);
|
||||||
state.tagsViewList.splice(k, 1);
|
state.tagsViewList.splice(k, 1);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (state.tagsViewList.length === k && getThemeConfig.value.isShareTagsView ? state.routePath === path : state.routeActive === path) {
|
if (state.tagsViewList.length === k && getThemeConfig.value.isShareTagsView ? state.routePath === path : state.routeActive === path) {
|
||||||
@ -298,6 +309,7 @@ export default defineComponent({
|
|||||||
Session.get('tagsViewList').map((v: any) => {
|
Session.get('tagsViewList').map((v: any) => {
|
||||||
if (v.meta.isAffix && !v.meta.isHide) {
|
if (v.meta.isAffix && !v.meta.isHide) {
|
||||||
v.url = setTagsViewHighlight(v);
|
v.url = setTagsViewHighlight(v);
|
||||||
|
storesKeepALiveNames.delOthersCachedViews(v);
|
||||||
state.tagsViewList.push({ ...v });
|
state.tagsViewList.push({ ...v });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -308,6 +320,7 @@ export default defineComponent({
|
|||||||
// 5、关闭全部 tagsView:如果是设置了固定的(isAffix),不进行关闭
|
// 5、关闭全部 tagsView:如果是设置了固定的(isAffix),不进行关闭
|
||||||
const closeAllTagsView = () => {
|
const closeAllTagsView = () => {
|
||||||
if (Session.get('tagsViewList')) {
|
if (Session.get('tagsViewList')) {
|
||||||
|
storesKeepALiveNames.delAllCachedViews();
|
||||||
state.tagsViewList = [];
|
state.tagsViewList = [];
|
||||||
Session.get('tagsViewList').map((v: any) => {
|
Session.get('tagsViewList').map((v: any) => {
|
||||||
if (v.meta.isAffix && !v.meta.isHide) {
|
if (v.meta.isAffix && !v.meta.isHide) {
|
||||||
@ -531,11 +544,11 @@ export default defineComponent({
|
|||||||
// 页面卸载时
|
// 页面卸载时
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
// 取消非本页面调用监听
|
// 取消非本页面调用监听
|
||||||
proxy.mittBus.off('onCurrentContextmenuClick');
|
proxy.mittBus.off('onCurrentContextmenuClick', () => {});
|
||||||
// 取消监听布局配置界面开启/关闭拖拽
|
// 取消监听布局配置界面开启/关闭拖拽
|
||||||
proxy.mittBus.off('openOrCloseSortable');
|
proxy.mittBus.off('openOrCloseSortable', () => {});
|
||||||
// 取消监听布局配置开启 TagsView 共用
|
// 取消监听布局配置开启 TagsView 共用
|
||||||
proxy.mittBus.off('openShareTagsView');
|
proxy.mittBus.off('openShareTagsView', () => {});
|
||||||
// 取消窗口 resize 监听
|
// 取消窗口 resize 监听
|
||||||
window.removeEventListener('resize', onSortableResize);
|
window.removeEventListener('resize', onSortableResize);
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div class="h100">
|
<div class="h100">
|
||||||
<router-view v-slot="{ Component }">
|
<router-view v-slot="{ Component }">
|
||||||
<transition :name="setTransitionName" mode="out-in">
|
<transition :name="setTransitionName" mode="out-in">
|
||||||
<keep-alive :include="keepAliveNameList">
|
<keep-alive :include="getKeepAliveNames">
|
||||||
<component :is="Component" :key="refreshRouterViewKey" class="w100" />
|
<component :is="Component" :key="refreshRouterViewKey" class="w100" />
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
</transition>
|
</transition>
|
||||||
@ -28,9 +28,9 @@ export default defineComponent({
|
|||||||
setup() {
|
setup() {
|
||||||
const { proxy } = <any>getCurrentInstance();
|
const { proxy } = <any>getCurrentInstance();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const stores = useKeepALiveNames();
|
const storesKeepAliveNames = useKeepALiveNames();
|
||||||
const storesThemeConfig = useThemeConfig();
|
const storesThemeConfig = useThemeConfig();
|
||||||
const { keepAliveNames } = storeToRefs(stores);
|
const { keepAliveNames, cachedViews } = storeToRefs(storesKeepAliveNames);
|
||||||
const { themeConfig } = storeToRefs(storesThemeConfig);
|
const { themeConfig } = storeToRefs(storesThemeConfig);
|
||||||
const state = reactive<ParentViewState>({
|
const state = reactive<ParentViewState>({
|
||||||
refreshRouterViewKey: null,
|
refreshRouterViewKey: null,
|
||||||
@ -40,6 +40,10 @@ export default defineComponent({
|
|||||||
const setTransitionName = computed(() => {
|
const setTransitionName = computed(() => {
|
||||||
return themeConfig.value.animation;
|
return themeConfig.value.animation;
|
||||||
});
|
});
|
||||||
|
// 获取组件缓存列表(name值)
|
||||||
|
const getKeepAliveNames = computed(() => {
|
||||||
|
return themeConfig.value.isTagsview ? cachedViews.value : state.keepAliveNameList;
|
||||||
|
});
|
||||||
// 页面加载前,处理缓存,页面刷新时路由缓存处理
|
// 页面加载前,处理缓存,页面刷新时路由缓存处理
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
state.keepAliveNameList = keepAliveNames.value;
|
state.keepAliveNameList = keepAliveNames.value;
|
||||||
@ -54,7 +58,7 @@ export default defineComponent({
|
|||||||
});
|
});
|
||||||
// 页面卸载时
|
// 页面卸载时
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
proxy.mittBus.off('onTagsViewRefreshRouterView');
|
proxy.mittBus.off('onTagsViewRefreshRouterView', () => {});
|
||||||
});
|
});
|
||||||
// 监听路由变化,防止 tagsView 多标签时,切换动画消失
|
// 监听路由变化,防止 tagsView 多标签时,切换动画消失
|
||||||
watch(
|
watch(
|
||||||
@ -65,6 +69,7 @@ export default defineComponent({
|
|||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
setTransitionName,
|
setTransitionName,
|
||||||
|
getKeepAliveNames,
|
||||||
...toRefs(state),
|
...toRefs(state),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -18,6 +18,7 @@ export interface UserInfosStates {
|
|||||||
// 路由缓存列表
|
// 路由缓存列表
|
||||||
export interface KeepAliveNamesState {
|
export interface KeepAliveNamesState {
|
||||||
keepAliveNames: string[];
|
keepAliveNames: string[];
|
||||||
|
cachedViews: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 后端返回原始路由(未处理时)
|
// 后端返回原始路由(未处理时)
|
||||||
|
@ -3,15 +3,35 @@ import { KeepAliveNamesState } from './interface';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 路由缓存列表
|
* 路由缓存列表
|
||||||
* @methods setCacheKeepAlive 设置要缓存的路由 names
|
* @methods setCacheKeepAlive 设置要缓存的路由 names(开启 Tagsview)
|
||||||
|
* @methods addCachedView 添加要缓存的路由 names(关闭 Tagsview)
|
||||||
|
* @methods delCachedView 删除要缓存的路由 names(关闭 Tagsview)
|
||||||
|
* @methods delOthersCachedViews 右键菜单`关闭其它`,删除要缓存的路由 names(关闭 Tagsview)
|
||||||
|
* @methods delAllCachedViews 右键菜单`全部关闭`,删除要缓存的路由 names(关闭 Tagsview)
|
||||||
*/
|
*/
|
||||||
export const useKeepALiveNames = defineStore('keepALiveNames', {
|
export const useKeepALiveNames = defineStore('keepALiveNames', {
|
||||||
state: (): KeepAliveNamesState => ({
|
state: (): KeepAliveNamesState => ({
|
||||||
keepAliveNames: [],
|
keepAliveNames: [],
|
||||||
|
cachedViews: [],
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
async setCacheKeepAlive(data: Array<string>) {
|
async setCacheKeepAlive(data: Array<string>) {
|
||||||
this.keepAliveNames = data;
|
this.keepAliveNames = data;
|
||||||
},
|
},
|
||||||
|
async addCachedView(view: any) {
|
||||||
|
if (this.cachedViews.includes(view.name)) return;
|
||||||
|
if (view.meta.isKeepAlive) this.cachedViews.push(view.name);
|
||||||
|
},
|
||||||
|
async delCachedView(view: any) {
|
||||||
|
const index = this.cachedViews.indexOf(view.name);
|
||||||
|
index > -1 && this.cachedViews.splice(index, 1);
|
||||||
|
},
|
||||||
|
async delOthersCachedViews(view: any) {
|
||||||
|
if (view.meta.isKeepAlive) this.cachedViews = [view.name];
|
||||||
|
else this.cachedViews = [];
|
||||||
|
},
|
||||||
|
async delAllCachedViews() {
|
||||||
|
this.cachedViews = [];
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { UserInfosStates, UserInfosState } from './interface';
|
import Cookies from 'js-cookie';
|
||||||
|
import { UserInfosStates } from './interface';
|
||||||
import { Session } from '/@/utils/storage';
|
import { Session } from '/@/utils/storage';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -9,21 +10,54 @@ import { Session } from '/@/utils/storage';
|
|||||||
export const useUserInfo = defineStore('userInfo', {
|
export const useUserInfo = defineStore('userInfo', {
|
||||||
state: (): UserInfosStates => ({
|
state: (): UserInfosStates => ({
|
||||||
userInfos: {
|
userInfos: {
|
||||||
authBtnList: [],
|
|
||||||
photo: '',
|
|
||||||
roles: [],
|
|
||||||
time: 0,
|
|
||||||
userName: '',
|
userName: '',
|
||||||
|
photo: '',
|
||||||
|
time: 0,
|
||||||
|
roles: [],
|
||||||
|
authBtnList: [],
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
async setUserInfos(data?: UserInfosState) {
|
async setUserInfos() {
|
||||||
if (data) {
|
// 模拟数据,请求接口时,记得删除多余代码及对应依赖的引入
|
||||||
this.userInfos = <any>data;
|
const userName = Cookies.get('userName');
|
||||||
|
// 模拟数据
|
||||||
|
let defaultRoles: Array<string> = [];
|
||||||
|
let defaultAuthBtnList: Array<string> = [];
|
||||||
|
// admin 页面权限标识,对应路由 meta.roles,用于控制路由的显示/隐藏
|
||||||
|
let adminRoles: Array<string> = ['admin'];
|
||||||
|
// admin 按钮权限标识
|
||||||
|
let adminAuthBtnList: Array<string> = ['btn.add', 'btn.del', 'btn.edit', 'btn.link'];
|
||||||
|
// test 页面权限标识,对应路由 meta.roles,用于控制路由的显示/隐藏
|
||||||
|
let testRoles: Array<string> = ['common'];
|
||||||
|
// test 按钮权限标识
|
||||||
|
let testAuthBtnList: Array<string> = ['btn.add', 'btn.link'];
|
||||||
|
// 不同用户模拟不同的用户权限
|
||||||
|
if (userName === 'admin') {
|
||||||
|
defaultRoles = adminRoles;
|
||||||
|
defaultAuthBtnList = adminAuthBtnList;
|
||||||
} else {
|
} else {
|
||||||
|
defaultRoles = testRoles;
|
||||||
|
defaultAuthBtnList = testAuthBtnList;
|
||||||
|
}
|
||||||
|
// 用户信息模拟数据
|
||||||
|
const userInfos = {
|
||||||
|
userName: userName,
|
||||||
|
photo:
|
||||||
|
userName === 'admin'
|
||||||
|
? 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1813762643,1914315241&fm=26&gp=0.jpg'
|
||||||
|
: 'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=317673774,2961727727&fm=26&gp=0.jpg',
|
||||||
|
time: new Date().getTime(),
|
||||||
|
roles: defaultRoles,
|
||||||
|
authBtnList: defaultAuthBtnList,
|
||||||
|
};
|
||||||
|
// 存储用户信息到浏览器缓存
|
||||||
|
Session.set('userInfo', userInfos);
|
||||||
|
|
||||||
if (Session.get('userInfo')) {
|
if (Session.get('userInfo')) {
|
||||||
this.userInfos = Session.get('userInfo');
|
this.userInfos = Session.get('userInfo');
|
||||||
}
|
} else {
|
||||||
|
this.userInfos = userInfos;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import Cookies from 'js-cookie';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* window.localStorage 浏览器永久缓存
|
* window.localStorage 浏览器永久缓存
|
||||||
* @method set 设置永久缓存
|
* @method set 设置永久缓存
|
||||||
@ -35,19 +37,23 @@ export const Local = {
|
|||||||
export const Session = {
|
export const Session = {
|
||||||
// 设置临时缓存
|
// 设置临时缓存
|
||||||
set(key: string, val: any) {
|
set(key: string, val: any) {
|
||||||
|
if (key === 'token') return Cookies.set(key, val);
|
||||||
window.sessionStorage.setItem(key, JSON.stringify(val));
|
window.sessionStorage.setItem(key, JSON.stringify(val));
|
||||||
},
|
},
|
||||||
// 获取临时缓存
|
// 获取临时缓存
|
||||||
get(key: string) {
|
get(key: string) {
|
||||||
|
if (key === 'token') return Cookies.get(key);
|
||||||
let json: any = window.sessionStorage.getItem(key);
|
let json: any = window.sessionStorage.getItem(key);
|
||||||
return JSON.parse(json);
|
return JSON.parse(json);
|
||||||
},
|
},
|
||||||
// 移除临时缓存
|
// 移除临时缓存
|
||||||
remove(key: string) {
|
remove(key: string) {
|
||||||
|
if (key === 'token') return Cookies.remove(key);
|
||||||
window.sessionStorage.removeItem(key);
|
window.sessionStorage.removeItem(key);
|
||||||
},
|
},
|
||||||
// 移除全部临时缓存
|
// 移除全部临时缓存
|
||||||
clear() {
|
clear() {
|
||||||
|
Cookies.remove('token');
|
||||||
window.sessionStorage.clear();
|
window.sessionStorage.clear();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -24,16 +24,16 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { toRefs, reactive, onMounted, defineComponent } from 'vue';
|
import { toRefs, reactive, onMounted, defineComponent } from 'vue';
|
||||||
|
import Cookies from 'js-cookie';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { useUserInfo } from '/@/stores/userInfo';
|
import { useUserInfo } from '/@/stores/userInfo';
|
||||||
import { frontEndsResetRoute, setAddRoute, setFilterMenuAndCacheTagsViewRoutes } from '/@/router/frontEnd';
|
import { frontEndsResetRoute, setAddRoute, setFilterMenuAndCacheTagsViewRoutes } from '/@/router/frontEnd';
|
||||||
import { Session } from '/@/utils/storage';
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'limitsFrontEndPage',
|
name: 'limitsFrontEndPage',
|
||||||
setup() {
|
setup() {
|
||||||
const stores = useUserInfo();
|
const storesUserInfo = useUserInfo();
|
||||||
const { userInfos } = storeToRefs(stores);
|
const { userInfos } = storeToRefs(storesUserInfo);
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
val: '',
|
val: '',
|
||||||
userAuth: '',
|
userAuth: '',
|
||||||
@ -46,36 +46,9 @@ export default defineComponent({
|
|||||||
const onRadioChange = async () => {
|
const onRadioChange = async () => {
|
||||||
// 模拟数据
|
// 模拟数据
|
||||||
frontEndsResetRoute();
|
frontEndsResetRoute();
|
||||||
let defaultRoles: string[] = [];
|
Cookies.set('userName', state.userAuth);
|
||||||
let defaultAuthBtnList: string[] = [];
|
// 模拟切换不同权限用户
|
||||||
// admin 页面权限标识,对应路由 meta.roles,用于控制路由的显示/隐藏
|
storesUserInfo.setUserInfos();
|
||||||
let adminRoles: string[] = ['admin'];
|
|
||||||
// admin 按钮权限标识
|
|
||||||
let adminAuthBtnList: string[] = ['btn.add', 'btn.del', 'btn.edit', 'btn.link'];
|
|
||||||
// test 页面权限标识,对应路由 meta.roles,用于控制路由的显示/隐藏
|
|
||||||
let testRoles: string[] = ['common'];
|
|
||||||
// test 按钮权限标识
|
|
||||||
let testAuthBtnList: string[] = ['btn.add', 'btn.link'];
|
|
||||||
// 不同用户模拟不同的用户权限
|
|
||||||
if (state.userAuth === 'admin') {
|
|
||||||
defaultRoles = adminRoles;
|
|
||||||
defaultAuthBtnList = adminAuthBtnList;
|
|
||||||
} else {
|
|
||||||
defaultRoles = testRoles;
|
|
||||||
defaultAuthBtnList = testAuthBtnList;
|
|
||||||
}
|
|
||||||
const userInfos = {
|
|
||||||
userName: state.userAuth,
|
|
||||||
photo:
|
|
||||||
state.userAuth === 'admin'
|
|
||||||
? 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1813762643,1914315241&fm=26&gp=0.jpg'
|
|
||||||
: 'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=317673774,2961727727&fm=26&gp=0.jpg',
|
|
||||||
time: new Date().getTime(),
|
|
||||||
roles: defaultRoles,
|
|
||||||
authBtnList: defaultAuthBtnList,
|
|
||||||
};
|
|
||||||
Session.set('userInfo', userInfos);
|
|
||||||
stores.setUserInfos({ ...userInfos }); // 请注意执行顺序(存储用户信息 pinia)
|
|
||||||
await setAddRoute();
|
await setAddRoute();
|
||||||
setFilterMenuAndCacheTagsViewRoutes();
|
setFilterMenuAndCacheTagsViewRoutes();
|
||||||
};
|
};
|
||||||
|
@ -60,11 +60,11 @@ import { toRefs, reactive, defineComponent, computed } from 'vue';
|
|||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import Cookies from 'js-cookie';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { useThemeConfig } from '/@/stores/themeConfig';
|
import { useThemeConfig } from '/@/stores/themeConfig';
|
||||||
import { initFrontEndControlRoutes } from '/@/router/frontEnd';
|
import { initFrontEndControlRoutes } from '/@/router/frontEnd';
|
||||||
import { initBackEndControlRoutes } from '/@/router/backEnd';
|
import { initBackEndControlRoutes } from '/@/router/backEnd';
|
||||||
import { useUserInfo } from '/@/stores/userInfo';
|
|
||||||
import { Session } from '/@/utils/storage';
|
import { Session } from '/@/utils/storage';
|
||||||
import { formatAxis } from '/@/utils/formatTime';
|
import { formatAxis } from '/@/utils/formatTime';
|
||||||
import { NextLoading } from '/@/utils/loading';
|
import { NextLoading } from '/@/utils/loading';
|
||||||
@ -73,7 +73,6 @@ export default defineComponent({
|
|||||||
name: 'loginAccount',
|
name: 'loginAccount',
|
||||||
setup() {
|
setup() {
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const stores = useUserInfo();
|
|
||||||
const storesThemeConfig = useThemeConfig();
|
const storesThemeConfig = useThemeConfig();
|
||||||
const { themeConfig } = storeToRefs(storesThemeConfig);
|
const { themeConfig } = storeToRefs(storesThemeConfig);
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@ -95,43 +94,11 @@ export default defineComponent({
|
|||||||
});
|
});
|
||||||
// 登录
|
// 登录
|
||||||
const onSignIn = async () => {
|
const onSignIn = async () => {
|
||||||
// 模拟数据
|
|
||||||
state.loading.signIn = true;
|
state.loading.signIn = true;
|
||||||
let defaultRoles: Array<string> = [];
|
|
||||||
let defaultAuthBtnList: Array<string> = [];
|
|
||||||
// admin 页面权限标识,对应路由 meta.roles,用于控制路由的显示/隐藏
|
|
||||||
let adminRoles: Array<string> = ['admin'];
|
|
||||||
// admin 按钮权限标识
|
|
||||||
let adminAuthBtnList: Array<string> = ['btn.add', 'btn.del', 'btn.edit', 'btn.link'];
|
|
||||||
// test 页面权限标识,对应路由 meta.roles,用于控制路由的显示/隐藏
|
|
||||||
let testRoles: Array<string> = ['common'];
|
|
||||||
// test 按钮权限标识
|
|
||||||
let testAuthBtnList: Array<string> = ['btn.add', 'btn.link'];
|
|
||||||
// 不同用户模拟不同的用户权限
|
|
||||||
if (state.ruleForm.userName === 'admin') {
|
|
||||||
defaultRoles = adminRoles;
|
|
||||||
defaultAuthBtnList = adminAuthBtnList;
|
|
||||||
} else {
|
|
||||||
defaultRoles = testRoles;
|
|
||||||
defaultAuthBtnList = testAuthBtnList;
|
|
||||||
}
|
|
||||||
// 用户信息模拟数据
|
|
||||||
const userInfos = {
|
|
||||||
userName: state.ruleForm.userName,
|
|
||||||
photo:
|
|
||||||
state.ruleForm.userName === 'admin'
|
|
||||||
? 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1813762643,1914315241&fm=26&gp=0.jpg'
|
|
||||||
: 'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=317673774,2961727727&fm=26&gp=0.jpg',
|
|
||||||
time: new Date().getTime(),
|
|
||||||
roles: defaultRoles,
|
|
||||||
authBtnList: defaultAuthBtnList,
|
|
||||||
};
|
|
||||||
// 存储 token 到浏览器缓存
|
// 存储 token 到浏览器缓存
|
||||||
Session.set('token', Math.random().toString(36).substr(0));
|
Session.set('token', Math.random().toString(36).substr(0));
|
||||||
// 存储用户信息到浏览器缓存
|
// 模拟数据,对接接口时,记得删除多余代码及对应依赖的引入。用于 `/src/stores/userInfo.ts` 中不同用户登录判断(模拟数据)
|
||||||
Session.set('userInfo', userInfos);
|
Cookies.set('userName', state.ruleForm.userName);
|
||||||
// 1、请注意执行顺序(存储用户信息到vuex)
|
|
||||||
stores.setUserInfos({ ...userInfos });
|
|
||||||
if (!themeConfig.value.isRequestRoutes) {
|
if (!themeConfig.value.isRequestRoutes) {
|
||||||
// 前端控制路由,2、请注意执行顺序
|
// 前端控制路由,2、请注意执行顺序
|
||||||
await initFrontEndControlRoutes();
|
await initFrontEndControlRoutes();
|
||||||
|
Loading…
Reference in New Issue
Block a user