v3.3.6一些小问题修复

This commit is contained in:
ray_wuhao 2023-06-20 14:10:35 +08:00
parent 25645e1e52
commit 4e6f70280c
4 changed files with 46 additions and 4 deletions

View File

@ -9,6 +9,11 @@
- 修复了鉴权方法的 bug
- 更新了 router permission 方法(路由守卫)
- 补充了一些模块文档
- 搜索支持以菜单模块的 icon 进行渲染,如果为空则以 icon table 默认填充
### Fixes
- 修复选中所搜结果后,菜单不能默认展开 bug
### 补充

View File

@ -7,15 +7,25 @@ import { useMenu } from '@/store'
import { MENU_COLLAPSED_CONFIG, MENU_ACCORDION } from '@/appConfig/appConfig'
import { useVueRouter } from '@/router/helper/useVueRouter'
import type { MenuInst } from 'naive-ui'
const LayoutMenu = defineComponent({
name: 'LayoutMenu',
setup() {
const menuRef = ref<MenuInst | null>(null)
const menuStore = useMenu()
const { router } = useVueRouter()
const { menuModelValueChange, collapsedMenu } = menuStore
const modelMenuKey = computed({
get: () => menuStore.menuKey,
get: () => {
nextTick().then(() => {
menuRef.value?.showOption?.(menuStore.menuKey as string)
})
return menuStore.menuKey
},
// eslint-disable-next-line @typescript-eslint/no-empty-function
set: () => {},
})
@ -41,6 +51,7 @@ const LayoutMenu = defineComponent({
collapsedMenu,
sideBarLogo,
handleSideBarLogoClick,
menuRef,
}
},
render() {
@ -79,6 +90,7 @@ const LayoutMenu = defineComponent({
''
)}
<NMenu
ref="menuRef"
v-model:value={this.modelMenuKey}
options={this.modelMenuOptions as NaiveMenuOptions[]}
indent={MENU_COLLAPSED_CONFIG.MENU_COLLAPSED_INDENT}

View File

@ -120,6 +120,19 @@ const GlobalSeach = defineComponent({
}
}
/** 渲染搜索菜单前缀图标, 如果没有则用 icon table 代替 */
const RenderPreIcon = (meta: AppRouteMeta) => {
const { icon } = meta
if (typeof icon === 'string') {
return <RayIcon name={icon} size="24" />
} else if (typeof icon === 'function') {
return () => icon
} else {
return <RayIcon name="table" size="24" />
}
}
onMounted(() => {
on(window, 'keydown', registerKeyboard)
})
@ -134,6 +147,7 @@ const GlobalSeach = defineComponent({
tiptextOptions,
handleSearchMenuOptions: debounce(handleSearchMenuOptions, 300),
handleSearchItemClick,
RenderPreIcon,
}
},
render() {
@ -167,7 +181,7 @@ const GlobalSeach = defineComponent({
}}
>
<div class="content-item-icon">
<RayIcon name="table" size="24" />
{this.RenderPreIcon(curr.meta)}
</div>
<div class="content-item-label">
{curr.breadcrumbLabel}

View File

@ -16,7 +16,6 @@
* - getAppLocales: 获取所有语言
*/
/* eslint-disable @typescript-eslint/no-explicit-any */
import { set } from 'lodash-es'
import { zhCN, dateZhCN } from 'naive-ui' // 导入 `naive ui` 中文包
import { getCache } from '@use-utils/cache'
@ -25,7 +24,19 @@ import { APP_CATCH_KEY } from '@/appConfig/appConfig'
import type { Recordable } from '@/types/type-utils'
export const mergeMessage = (langs: Record<string, any>, prefix = 'lang') => {
/**
*
* @param langs
* @param prefix
*
* @remark , prefix
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const mergeMessage = (langs: Record<string, any>, prefix: string) => {
if (!prefix) {
throw new Error('Expected prefix to be string, got undefined instead')
}
const langsGather: Recordable = {}
Object.keys(langs).forEach((key) => {