mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-08 01:17:23 +08:00
feat: 路由添加可配置的fixedTag
属性,作用为当前菜单是否固定显示在标签页且不可关闭
This commit is contained in:
parent
d685a18b9e
commit
ddc0eeea81
@ -40,7 +40,8 @@ const systemManagementRouter = {
|
|||||||
meta: {
|
meta: {
|
||||||
icon: "ep:menu",
|
icon: "ep:menu",
|
||||||
title: "menus.pureSystemMenu",
|
title: "menus.pureSystemMenu",
|
||||||
roles: ["admin"]
|
roles: ["admin"],
|
||||||
|
fixedTag: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -119,7 +120,8 @@ const permissionRouter = {
|
|||||||
name: "PermissionPage",
|
name: "PermissionPage",
|
||||||
meta: {
|
meta: {
|
||||||
title: "menus.purePermissionPage",
|
title: "menus.purePermissionPage",
|
||||||
roles: ["admin", "common"]
|
roles: ["admin", "common"],
|
||||||
|
fixedTag: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -243,7 +245,8 @@ const frameRouter = {
|
|||||||
title: "menus.purePiniaDoc",
|
title: "menus.purePiniaDoc",
|
||||||
frameSrc: "https://pinia.vuejs.org/zh/index.html",
|
frameSrc: "https://pinia.vuejs.org/zh/index.html",
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
roles: ["admin", "common"]
|
roles: ["admin", "common"],
|
||||||
|
fixedTag: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -90,6 +90,10 @@
|
|||||||
padding: 0 12px;
|
padding: 0 12px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fixed-tag {
|
||||||
|
padding: 0 12px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,7 +425,7 @@ function showMenuModel(
|
|||||||
|
|
||||||
function openMenu(tag, e) {
|
function openMenu(tag, e) {
|
||||||
closeMenu();
|
closeMenu();
|
||||||
if (tag.path === topPath) {
|
if (tag.path === topPath || tag?.meta?.fixedTag) {
|
||||||
// 右键菜单为顶级菜单,只显示刷新
|
// 右键菜单为顶级菜单,只显示刷新
|
||||||
showMenus(false);
|
showMenus(false);
|
||||||
tagsViews[0].show = true;
|
tagsViews[0].show = true;
|
||||||
@ -549,7 +549,11 @@ onBeforeUnmount(() => {
|
|||||||
v-for="(item, index) in multiTags"
|
v-for="(item, index) in multiTags"
|
||||||
:ref="'dynamic' + index"
|
:ref="'dynamic' + index"
|
||||||
:key="index"
|
:key="index"
|
||||||
:class="['scroll-item is-closable', linkIsActive(item)]"
|
:class="[
|
||||||
|
'scroll-item is-closable',
|
||||||
|
linkIsActive(item),
|
||||||
|
!isAllEmpty(item?.meta?.fixedTag) && 'fixed-tag'
|
||||||
|
]"
|
||||||
@contextmenu.prevent="openMenu(item, $event)"
|
@contextmenu.prevent="openMenu(item, $event)"
|
||||||
@mouseenter.prevent="onMouseenter(index)"
|
@mouseenter.prevent="onMouseenter(index)"
|
||||||
@mouseleave.prevent="onMouseleave(index)"
|
@mouseleave.prevent="onMouseleave(index)"
|
||||||
@ -562,8 +566,10 @@ onBeforeUnmount(() => {
|
|||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
v-if="
|
v-if="
|
||||||
iconIsActive(item, index) ||
|
isAllEmpty(item?.meta?.fixedTag)
|
||||||
(index === activeIndex && index !== 0)
|
? iconIsActive(item, index) ||
|
||||||
|
(index === activeIndex && index !== 0)
|
||||||
|
: false
|
||||||
"
|
"
|
||||||
class="el-icon-close"
|
class="el-icon-close"
|
||||||
@click.stop="deleteMenu(item)"
|
@click.stop="deleteMenu(item)"
|
||||||
|
@ -32,7 +32,8 @@ export default {
|
|||||||
name: "WaterMark",
|
name: "WaterMark",
|
||||||
component: () => import("@/views/able/watermark.vue"),
|
component: () => import("@/views/able/watermark.vue"),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t("menus.pureWatermark")
|
title: $t("menus.pureWatermark"),
|
||||||
|
fixedTag: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -72,7 +73,8 @@ export default {
|
|||||||
name: "Debounce",
|
name: "Debounce",
|
||||||
component: () => import("@/views/able/debounce.vue"),
|
component: () => import("@/views/able/debounce.vue"),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t("menus.pureDebounce")
|
title: $t("menus.pureDebounce"),
|
||||||
|
fixedTag: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,8 @@ export default {
|
|||||||
meta: {
|
meta: {
|
||||||
icon: "ri:bank-card-line",
|
icon: "ri:bank-card-line",
|
||||||
title: $t("menus.pureListCard"),
|
title: $t("menus.pureListCard"),
|
||||||
showParent: true
|
showParent: true,
|
||||||
|
fixedTag: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -42,7 +42,8 @@ export default {
|
|||||||
name: "Menu1-2-1",
|
name: "Menu1-2-1",
|
||||||
meta: {
|
meta: {
|
||||||
title: $t("menus.pureMenu1-2-1"),
|
title: $t("menus.pureMenu1-2-1"),
|
||||||
keepAlive: true
|
keepAlive: true,
|
||||||
|
fixedTag: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,8 @@ export default {
|
|||||||
title: "PPT",
|
title: "PPT",
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
frameSrc: "https://pipipi-pikachu.github.io/PPTist/",
|
frameSrc: "https://pipipi-pikachu.github.io/PPTist/",
|
||||||
frameLoading: false
|
frameLoading: false,
|
||||||
|
fixedTag: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -23,7 +23,8 @@ export default {
|
|||||||
name: "PureTableHigh",
|
name: "PureTableHigh",
|
||||||
component: () => import("@/views/table/high.vue"),
|
component: () => import("@/views/table/high.vue"),
|
||||||
meta: {
|
meta: {
|
||||||
title: $t("menus.pureTableHigh")
|
title: $t("menus.pureTableHigh"),
|
||||||
|
fixedTag: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { store } from "@/store";
|
import { store } from "@/store";
|
||||||
|
import { usePermissionStoreHook } from "./permission";
|
||||||
import { routerArrays } from "@/layout/types";
|
import { routerArrays } from "@/layout/types";
|
||||||
import { responsiveStorageNameSpace } from "@/config";
|
import { responsiveStorageNameSpace } from "@/config";
|
||||||
import type { multiType, positionType } from "./types";
|
import type { multiType, positionType } from "./types";
|
||||||
@ -15,7 +16,10 @@ export const useMultiTagsStore = defineStore({
|
|||||||
? storageLocal().getItem<StorageConfigs>(
|
? storageLocal().getItem<StorageConfigs>(
|
||||||
`${responsiveStorageNameSpace()}tags`
|
`${responsiveStorageNameSpace()}tags`
|
||||||
)
|
)
|
||||||
: [...routerArrays],
|
: [
|
||||||
|
...routerArrays,
|
||||||
|
...usePermissionStoreHook().tagLists.filter(v => v?.meta?.fixedTag)
|
||||||
|
],
|
||||||
multiTagsCache: storageLocal().getItem<StorageConfigs>(
|
multiTagsCache: storageLocal().getItem<StorageConfigs>(
|
||||||
`${responsiveStorageNameSpace()}configure`
|
`${responsiveStorageNameSpace()}configure`
|
||||||
)?.multiTagsCache
|
)?.multiTagsCache
|
||||||
|
@ -4,7 +4,12 @@ import type { cacheType } from "./types";
|
|||||||
import { constantMenus } from "@/router";
|
import { constantMenus } from "@/router";
|
||||||
import { useMultiTagsStoreHook } from "./multiTags";
|
import { useMultiTagsStoreHook } from "./multiTags";
|
||||||
import { debounce, getKeyList } from "@pureadmin/utils";
|
import { debounce, getKeyList } from "@pureadmin/utils";
|
||||||
import { ascending, filterTree, filterNoPermissionTree } from "@/router/utils";
|
import {
|
||||||
|
ascending,
|
||||||
|
filterTree,
|
||||||
|
filterNoPermissionTree,
|
||||||
|
formatFlatteningRoutes
|
||||||
|
} from "@/router/utils";
|
||||||
|
|
||||||
export const usePermissionStore = defineStore({
|
export const usePermissionStore = defineStore({
|
||||||
id: "pure-permission",
|
id: "pure-permission",
|
||||||
@ -13,6 +18,7 @@ export const usePermissionStore = defineStore({
|
|||||||
constantMenus,
|
constantMenus,
|
||||||
// 整体路由生成的菜单(静态、动态)
|
// 整体路由生成的菜单(静态、动态)
|
||||||
wholeMenus: [],
|
wholeMenus: [],
|
||||||
|
tagLists: [],
|
||||||
// 缓存页面keepAlive
|
// 缓存页面keepAlive
|
||||||
cachePageList: []
|
cachePageList: []
|
||||||
}),
|
}),
|
||||||
@ -22,6 +28,7 @@ export const usePermissionStore = defineStore({
|
|||||||
this.wholeMenus = filterNoPermissionTree(
|
this.wholeMenus = filterNoPermissionTree(
|
||||||
filterTree(ascending(this.constantMenus.concat(routes)))
|
filterTree(ascending(this.constantMenus.concat(routes)))
|
||||||
);
|
);
|
||||||
|
this.tagLists = formatFlatteningRoutes(this.constantMenus.concat(routes));
|
||||||
},
|
},
|
||||||
cacheOperate({ mode, name }: cacheType) {
|
cacheOperate({ mode, name }: cacheType) {
|
||||||
const delIndex = this.cachePageList.findIndex(v => v === name);
|
const delIndex = this.cachePageList.findIndex(v => v === name);
|
||||||
|
@ -61,7 +61,7 @@ const {
|
|||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<PureTableBar
|
<PureTableBar
|
||||||
title="菜单管理(初版,持续完善中)"
|
title="菜单管理(仅演示,操作后不生效)"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:isExpandAll="false"
|
:isExpandAll="false"
|
||||||
:tableRef="tableRef?.getTableRef()"
|
:tableRef="tableRef?.getTableRef()"
|
||||||
|
4
types/router.d.ts
vendored
4
types/router.d.ts
vendored
@ -45,8 +45,10 @@ declare global {
|
|||||||
/** 离场动画 */
|
/** 离场动画 */
|
||||||
leaveTransition?: string;
|
leaveTransition?: string;
|
||||||
};
|
};
|
||||||
// 是否不添加信息到标签页,(默认`false`)
|
/** 当前菜单名称或自定义信息禁止添加到标签页(默认`false`) */
|
||||||
hiddenTag?: boolean;
|
hiddenTag?: boolean;
|
||||||
|
/** 当前菜单是否固定显示在标签页且不可关闭(默认`false`) */
|
||||||
|
fixedTag?: boolean;
|
||||||
/** 动态路由可打开的最大数量 `可选` */
|
/** 动态路由可打开的最大数量 `可选` */
|
||||||
dynamicLevel?: number;
|
dynamicLevel?: number;
|
||||||
/** 将某个菜单激活
|
/** 将某个菜单激活
|
||||||
|
Loading…
x
Reference in New Issue
Block a user