Просмотр исходного кода

fix(web): 修复家庭优惠券双 admin 前缀路由与返回跳转白屏

- 路由 admin/family-coupon -> family-coupon,兼容旧链接重定向
- FamilyCouponManage 返回 /admin/families -> /families(原路径白屏)
- FamilyWorkbench 优惠券卡跳 /family-coupon
- 单测 FamilyWorkbench + FamilyCouponManage.backToList 6/6 通过
Xiaogang Liao 1 день назад
Родитель
Сommit
cfaf99d9e0

+ 1 - 1
cfc-web/.last_build_commit

@@ -1 +1 @@
-163c4dff92dc4e16b4866bdd95f11ca2c6d90cb6
+23fea0aae102411fe6561239ecc11086f3376abd

+ 1 - 1
cfc-web/src/__tests__/FamilyWorkbench.spec.js

@@ -68,7 +68,7 @@ describe("FamilyWorkbench 单家庭工作台", () => {
     await wrapper.vm.$nextTick()
     wrapper.findAll(".wb-card").at(5).trigger("click")
     expect(wrapper.vm.$router.push).toHaveBeenCalledWith(
-      expect.objectContaining({ path: expect.stringContaining("/admin/family-coupon"), query: { familyId: 5 } })
+      expect.objectContaining({ path: "/family-coupon", query: { familyId: 5 } })
     )
     wrapper.destroy()
   })

+ 3 - 3
cfc-web/src/__tests__/views/admin/FamilyCouponManage.backToList.spec.js

@@ -74,18 +74,18 @@ describe('admin.familyCoupon.backToList 返回家庭列表', () => {
     expect(header.props('back')).toBe(true)
   })
 
-  it('点击返回按钮应 router.push 回 /admin/families', async () => {
+  it('点击返回按钮应 router.push 回 /families', async () => {
     const wrapper = mount({ familyId: '7' })
     const header = wrapper.findComponent(PageHeaderStub)
     await header.find('.back-btn').trigger('click')
-    expect(pushMock).toHaveBeenCalledWith({ path: '/admin/families' })
+    expect(pushMock).toHaveBeenCalledWith({ path: '/families' })
   })
 
   it('返回列表应使用显式 router.push,而非 history.back()', async () => {
     const wrapper = mount({ familyId: '7' })
     const header = wrapper.findComponent(PageHeaderStub)
     await header.vm.$emit('back')
-    expect(pushMock).toHaveBeenCalledWith({ path: '/admin/families' })
+    expect(pushMock).toHaveBeenCalledWith({ path: '/families' })
     expect(backMock).not.toHaveBeenCalled()
   })
 })

+ 6 - 1
cfc-web/src/router/index.js

@@ -775,11 +775,16 @@ const routes = [
         meta: { title: '会员券转赠记录', perm: 'marketing:coupon' }
       },
       {
-        path: 'admin/family-coupon',
+        path: 'family-coupon',
         name: 'FamilyCouponManage',
         component: () => import('@/views/admin/FamilyCouponManage.vue'),
         meta: { title: '家庭优惠券', perm: 'marketing:coupon' }
       },
+      {
+        // 兼容历史链接:路由曾误带 admin/ 前缀,最终 URL 为 /admin/admin/family-coupon
+        path: 'admin/family-coupon',
+        redirect: to => ({ path: '/family-coupon', query: to.query })
+      },
       {
         path: 'discount-rules',
         name: 'DiscountRuleManagement',

+ 1 - 1
cfc-web/src/views/FamilyWorkbench.vue

@@ -261,7 +261,7 @@ export default {
         this.messageDrawerVisible = true
         this.loadConversations(1)
       } else if (key === "coupons") {
-        this.$router.push({ path: "/admin/family-coupon", query: { familyId: this.familyId } })
+        this.$router.push({ path: "/family-coupon", query: { familyId: this.familyId } })
       }
     },
     async loadTasks(page) {

+ 2 - 2
cfc-web/src/views/admin/FamilyCouponManage.vue

@@ -148,7 +148,7 @@ export default {
     const familyId = this.$route.query.familyId
     if (!familyId) {
       this.$message.warning('缺少家庭 ID 参数')
-      this.$router.replace({ path: '/admin/families' })
+      this.$router.replace({ path: '/families' })
       return
     }
     this.familyId = parseInt(familyId)
@@ -159,7 +159,7 @@ export default {
   methods: {
     backToList() {
       // 从家庭管理列表点优惠券进入后,返回按钮显式回家庭列表
-      this.$router.push({ path: '/admin/families' })
+      this.$router.push({ path: '/families' })
     },
     onTabClick(tab) {
       if (tab.name === 'usage') {