fix: menu order error

This commit is contained in:
chansee97 2025-09-16 22:37:06 +08:00
parent d400ebedc0
commit ecb880b177
3 changed files with 9 additions and 10 deletions

View File

@ -1,7 +1,7 @@
/// <reference path="../../typings/global.d.ts" /> /// <reference path="../../typings/global.d.ts" />
import type { MenuOption } from 'naive-ui' import type { MenuOption } from 'naive-ui'
import { $t, renderIcon } from '@/utils' import { $t, renderIcon } from '@/utils'
import { clone, isEmpty, min, pick } from 'radash' import { clone, isEmpty, isNumber, min, pick } from 'radash'
import { RouterLink } from 'vue-router' import { RouterLink } from 'vue-router'
import arrayToTree from 'array-to-tree' import arrayToTree from 'array-to-tree'
@ -98,13 +98,11 @@ function transformAuthRoutesToMenus(userRoutes: Entity.Menu[]) {
.filter(route => route.menuVisible !== false) .filter(route => route.menuVisible !== false)
// Sort the menu according to the order size // Sort the menu according to the order size
.sort((a, b) => { .sort((a, b) => {
if (a.sort && b.sort) const aHas = isNumber(a.sort)
return a.sort - b.sort const bHas = isNumber(b.sort)
else if (a.sort) if (aHas && bHas)
return -1 return (a.sort as number) - (b.sort as number)
else if (b.sort) return 0
return 1
else return 0
}) })
// Convert to side menu data structure // Convert to side menu data structure
.map((item) => { .map((item) => {

View File

@ -6,7 +6,7 @@ import { renderProCopyableText } from 'pro-naive-ui'
// 登录日志搜索表单数据类型 // 登录日志搜索表单数据类型
export interface LoginLogSearchFormData { export interface LoginLogSearchFormData {
ipaddr?: string ipaddr?: string
userName?: string username?: string
status?: number status?: number
loginTime?: string loginTime?: string
} }
@ -47,7 +47,7 @@ export const searchColumns: ProSearchFormColumns<LoginLogSearchFormData> = [
field: 'date-time-range', field: 'date-time-range',
fieldProps: { fieldProps: {
clearable: true, clearable: true,
format: 'yyyy-MM-dd HH:mm:ss', format: 'yyyy-MM-dd',
valueFormat: 'yyyy-MM-dd HH:mm:ss', valueFormat: 'yyyy-MM-dd HH:mm:ss',
defaultTime: ['00:00:00', '23:59:59'], defaultTime: ['00:00:00', '23:59:59'],
}, },

View File

@ -152,6 +152,7 @@ defineExpose({
title="父级目录" title="父级目录"
path="parentId" path="parentId"
:field-props="{ :field-props="{
clearable: true,
options: treeData, options: treeData,
keyField: 'value', keyField: 'value',
}" }"