Browse Source

feat(router): 修改分组详情路由参数传递方式

- 将分组详情页的路由参数从 query 改为 params
- 更新路由配置中的路径参数定义
- 修改详情页组件中获取分组ID的方式
- 调整分组按钮跳转逻辑,使用命名路由传递参数
zhou 1 month ago
parent
commit
445f7f416e

+ 1 - 1
src/router/index.ts

@@ -182,7 +182,7 @@ export const constantRoutes: RouteRecordRaw[] = [
     hidden: true,
     children: [
       {
-        path: 'detail',
+        path: 'detail/:groupId',
         component: () => import('@/views/system/gameEventGroup/detail.vue'),
         name: 'GameEventGroupDetail',
         meta: { title: '分组详情', icon: 'view' }

+ 3 - 3
src/views/system/gameEventGroup/detail.vue

@@ -161,7 +161,7 @@ const getTeamName = (teamId: string | number | undefined) => {
 const getGroupInfo = async () => {
   try {
     loading.value = true;
-    const groupId = route.query.id;
+    const groupId = route.params.groupId;
     if (!groupId || Array.isArray(groupId)) {
       proxy?.$modal.msgError('分组ID不能为空');
       return;
@@ -183,7 +183,7 @@ const getGroupInfo = async () => {
 // 从数据库加载分组结果
 const loadGroupResultFromDB = async () => {
   try {
-    const groupId = route.query.id;
+    const groupId = route.params.groupId;
     if (!groupId || Array.isArray(groupId)) {
       proxy?.$modal.msgError('分组ID不能为空');
       return;
@@ -240,7 +240,7 @@ const generateGroupsData = async () => {
   try {
     generating.value = true;
     
-    const groupId = route.query.id;
+    const groupId = route.params.groupId;
     if (!groupId || Array.isArray(groupId)) {
       proxy?.$modal.msgError('分组ID不能为空');
       return;

+ 4 - 1
src/views/system/gameEventGroup/index.vue

@@ -726,7 +726,10 @@ const handleExport = () => {
 
 /** 分组按钮操作 */
 const handleGroup = (row: GameEventGroupVO) => {
-  router.push({ path: '/system/gameEventGroup/detail', query: { id: row.groupId } });
+  router.push({
+    name: 'GameEventGroupDetail',
+    params: { groupId: row.groupId }
+  });
 };
 
 onMounted(() => {