mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-04-06 03:57:49 +08:00
修复 Menu TagMenu 类型错误问题
This commit is contained in:
parent
6bc7a23987
commit
161b133b9a
@ -61,7 +61,7 @@ const MenuTag = defineComponent({
|
||||
return (
|
||||
<NScrollbar class="menu-tag" xScrollable>
|
||||
<NSpace class="menu-tag-sapce" wrap={false} align="center">
|
||||
{this.menuTagOptions.map((curr: MenuOption, idx) => (
|
||||
{this.menuTagOptions.map((curr, idx) => (
|
||||
<NTag
|
||||
closable={
|
||||
curr.key !== '/dashboard' && this.menuTagOptions.length > 1
|
||||
|
@ -15,12 +15,12 @@ export const useMenu = defineStore('menu', () => {
|
||||
|
||||
const menuState = reactive({
|
||||
menuKey: cacheMenuKey as string | null, // 当前菜单 `key`
|
||||
options: [] as RouteRecordRaw[], // 菜单列表
|
||||
options: [] as IMenuOptions[], // 菜单列表
|
||||
collapsed: false, // 是否折叠菜单
|
||||
menuTagOptions: [] as RouteRecordRaw[],
|
||||
menuTagOptions: [] as TagMenuOptions[],
|
||||
})
|
||||
|
||||
const handleMenuTagOptions = (item: RouteRecordRaw) => {
|
||||
const handleMenuTagOptions = (item: IMenuOptions) => {
|
||||
if (item.path !== menuState.menuKey) {
|
||||
const tag = menuState.menuTagOptions.find(
|
||||
(curr) => curr.path === item.path,
|
||||
@ -40,7 +40,7 @@ export const useMenu = defineStore('menu', () => {
|
||||
* 修改 `menu key` 后的回调函数
|
||||
*/
|
||||
const menuModelValueChange = (key: string, item: MenuOption) => {
|
||||
handleMenuTagOptions(item as unknown as RouteRecordRaw)
|
||||
handleMenuTagOptions(item as unknown as TagMenuOptions)
|
||||
|
||||
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