Compare commits

...
1 Commits
Author SHA1 Message Date
wc24 701ed957ef feat(role): 跳转带的 ?filter={_id} 在角色列表里自动选中那条
role 是自定义 master-detail 页(非 ShrimpTable、不做服务端过滤),原 onMounted 默认选第一个,
无视 relation 跳转带的 _id。现全量加载后按 URL filter._id 客户端选中目标角色,解析不出走默认。
2026-06-29 21:00:07 +08:00
2 changed files with 18 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "shrimp-admin", "name": "shrimp-admin",
"version": "0.3.5", "version": "0.3.6",
"private": true, "private": true,
"description": "Shrimp 框架前端 — 消费 ShrimpServer + ShrimpTable 契约的经典 Vue3 + Element Plus 实现", "description": "Shrimp 框架前端 — 消费 ShrimpServer + ShrimpTable 契约的经典 Vue3 + Element Plus 实现",
"main": "src/index.ts", "main": "src/index.ts",
+17 -1
View File
@@ -50,6 +50,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useRoute } from 'vue-router'
import { vueAdmin } from '../VueAdmin' import { vueAdmin } from '../VueAdmin'
import { IRole, IRoleProto, WithId, ILabel } from '../IShrimpType' import { IRole, IRoleProto, WithId, ILabel } from '../IShrimpType'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
@@ -61,12 +62,24 @@ interface IPowerItem {
} }
const { t } = useI18n() const { t } = useI18n()
const route = useRoute()
const props = defineProps<{ const props = defineProps<{
moduleKey: string moduleKey: string
events?: string[] events?: string[]
}>() }>()
// relation 跳转落到 role 页时带 ?filter={"_id":...}。role 是自定义 master-detail 页(非 ShrimpTable、
// 不做服务端过滤),全量加载后按这个 _id 在列表里选中那条;解析不出就走默认(选第一个)。
function jumpTargetId(): string {
try {
const f = route.query.filter ? JSON.parse(String(route.query.filter)) : null
return f && typeof f === 'object' ? String(f._id || '') : ''
} catch {
return ''
}
}
const roleApi = vueAdmin.getModule<IRoleProto>('role') const roleApi = vueAdmin.getModule<IRoleProto>('role')
const roleList = ref<WithId<IRole>[]>([]) const roleList = ref<WithId<IRole>[]>([])
@@ -138,7 +151,10 @@ async function handleDelete() {
onMounted(async () => { onMounted(async () => {
allPowers.value = await roleApi.allPower() allPowers.value = await roleApi.allPower()
await loadRoles() await loadRoles()
if (roleList.value.length > 0) { const jumpId = jumpTargetId()
if (jumpId && roleList.value.some(r => r._id === jumpId)) {
onSelect(jumpId)
} else if (roleList.value.length > 0) {
onSelect(roleList.value[0]._id) onSelect(roleList.value[0]._id)
} }
}) })