zhou zhou
12 小时以前 40905cbd04c2e332cd4bc2b9e0c5b3e1da9cccfa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import test from 'node:test'
import assert from 'node:assert/strict'
 
test('getFirstMenuPath skips unreleased menu routes and selects the first implemented page', async () => {
  const { getFirstMenuPath } = await import('../src/utils/navigation/route.js')
 
  const menuList = [
    {
      path: '/system',
      children: [
        {
          path: '/system/aiParam',
          component: '/system/aiParam',
          meta: { title: 'AI 参数' }
        }
      ]
    },
    {
      path: '/logs',
      children: [
        {
          path: '/logs/system/userLogin',
          component: '/system/user-login',
          meta: { title: '登录日志' }
        }
      ]
    }
  ]
 
  assert.equal(getFirstMenuPath(menuList), '/logs/system/userLogin')
})
 
test('getFirstMenuPath keeps traversing siblings when the first branch has no implemented leaf', async () => {
  const { getFirstMenuPath } = await import('../src/utils/navigation/route.js')
 
  const menuList = [
    {
      path: '/ai',
      children: [
        {
          path: '/ai/param',
          component: '/system/aiParam',
          meta: { title: 'AI 参数' }
        }
      ]
    },
    {
      path: '/permissions',
      children: [
        {
          path: '/permissions/system',
          children: [
            {
              path: '/permissions/system/role',
              component: '/system/role',
              meta: { title: '角色管理' }
            }
          ]
        }
      ]
    }
  ]
 
  assert.equal(getFirstMenuPath(menuList), '/permissions/system/role')
})