fix role key error

This commit is contained in:
2026-03-30 10:23:43 +08:00
parent 50d8d7267b
commit 73309d7890
3 changed files with 12 additions and 9 deletions
@@ -43,7 +43,7 @@ const methodColorMap: Record<string, string> = {
const overrideColumns = [
{ title: '方法', key: 'method', width: 80 },
{ title: '路径', dataIndex: 'path', key: 'path' },
{ title: '允许', key: 'allow', width: 80 },
{ title: '允许', key: 'allowed', width: 80 },
{ title: '操作', key: 'action', width: 80 },
]
@@ -113,7 +113,7 @@ function addOverride() {
route_id: route.id,
method: route.method,
path: route.path,
allow: true,
allowed: true,
})
addingRouteId.value = null
}
@@ -211,8 +211,8 @@ watch(
{{ record.method }}
</a-tag>
</template>
<template v-if="column.key === 'allow'">
<a-switch v-model:checked="record.allow" size="small" />
<template v-if="column.key === 'allowed'">
<a-switch v-model:checked="record.allowed" size="small" />
</template>
<template v-if="column.key === 'action'">
<a-button type="link" size="small" danger @click="removeOverride(index)">
@@ -52,7 +52,7 @@ const mockRoutes = [
]
const mockOverrides = [
{ route_id: 1, method: 'GET', path: '/api/v1/users', allow: true },
{ route_id: 1, method: 'GET', path: '/api/v1/users', allowed: true },
]
function setupMocks(overrides: {
@@ -60,7 +60,10 @@ function setupMocks(overrides: {
roleOverrides?: typeof mockOverrides
} = {}) {
vi.mocked(api.get).mockImplementation((url: string) => {
if (url.match(/\/roles\/\d+\/route-groups/)) return Promise.resolve(overrides.groupIds ?? [1, 2]) as never
if (url.match(/\/roles\/\d+\/route-groups/)) {
const ids = overrides.groupIds ?? [1, 2]
return Promise.resolve(ids.map((id) => ({ id }))) as never
}
if (url.match(/\/roles\/\d+\/route-overrides/)) return Promise.resolve(overrides.roleOverrides ?? mockOverrides) as never
if (url === '/api/v1/route-groups') return Promise.resolve(mockGroups) as never
if (url === '/api/v1/routes') return Promise.resolve(mockRoutes) as never