mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-05-02 07:54:30 +08:00
修复 Menu TagMenu 类型错误问题
This commit is contained in:
parent
6bc7a23987
commit
161b133b9a
@ -61,7 +61,7 @@ const MenuTag = defineComponent({
|
|||||||
return (
|
return (
|
||||||
<NScrollbar class="menu-tag" xScrollable>
|
<NScrollbar class="menu-tag" xScrollable>
|
||||||
<NSpace class="menu-tag-sapce" wrap={false} align="center">
|
<NSpace class="menu-tag-sapce" wrap={false} align="center">
|
||||||
{this.menuTagOptions.map((curr: MenuOption, idx) => (
|
{this.menuTagOptions.map((curr, idx) => (
|
||||||
<NTag
|
<NTag
|
||||||
closable={
|
closable={
|
||||||
curr.key !== '/dashboard' && this.menuTagOptions.length > 1
|
curr.key !== '/dashboard' && this.menuTagOptions.length > 1
|
||||||
|
@ -15,12 +15,12 @@ export const useMenu = defineStore('menu', () => {
|
|||||||
|
|
||||||
const menuState = reactive({
|
const menuState = reactive({
|
||||||
menuKey: cacheMenuKey as string | null, // 当前菜单 `key`
|
menuKey: cacheMenuKey as string | null, // 当前菜单 `key`
|
||||||
options: [] as RouteRecordRaw[], // 菜单列表
|
options: [] as IMenuOptions[], // 菜单列表
|
||||||
collapsed: false, // 是否折叠菜单
|
collapsed: false, // 是否折叠菜单
|
||||||
menuTagOptions: [] as RouteRecordRaw[],
|
menuTagOptions: [] as TagMenuOptions[],
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleMenuTagOptions = (item: RouteRecordRaw) => {
|
const handleMenuTagOptions = (item: IMenuOptions) => {
|
||||||
if (item.path !== menuState.menuKey) {
|
if (item.path !== menuState.menuKey) {
|
||||||
const tag = menuState.menuTagOptions.find(
|
const tag = menuState.menuTagOptions.find(
|
||||||
(curr) => curr.path === item.path,
|
(curr) => curr.path === item.path,
|
||||||
@ -40,7 +40,7 @@ export const useMenu = defineStore('menu', () => {
|
|||||||
* 修改 `menu key` 后的回调函数
|
* 修改 `menu key` 后的回调函数
|
||||||
*/
|
*/
|
||||||
const menuModelValueChange = (key: string, item: MenuOption) => {
|
const menuModelValueChange = (key: string, item: MenuOption) => {
|
||||||
handleMenuTagOptions(item as unknown as RouteRecordRaw)
|
handleMenuTagOptions(item as unknown as TagMenuOptions)
|
||||||
|
|
||||||
menuState.menuKey = key
|
menuState.menuKey = key
|
||||||
|
|
||||||
|
15
src/types/store.d.ts
vendored
Normal file
15
src/types/store.d.ts
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
export {}
|
||||||
|
|
||||||
|
import type { RouteRecordRaw } from 'vue-router'
|
||||||
|
import type { MenuOption } from 'naive-ui'
|
||||||
|
import type { VNode } from 'vue'
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
declare interface IMenuOptions extends MenuOption, RouteRecordRaw {
|
||||||
|
key: string | number
|
||||||
|
path: string
|
||||||
|
label: string | Function
|
||||||
|
}
|
||||||
|
|
||||||
|
declare interface TagMenuOptions extends IMenuOptions {}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user