From dd70dc0012259c6a4d453afc0ccb16902e6dfb51 Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Mon, 20 Oct 2025 15:36:06 +0800 Subject: [PATCH] fix: router push --- .../mall/home/modules/operation-data-card.vue | 59 ++++++++++++------- apps/web-ele/package.json | 1 + .../src/components/diy-editor/index.vue | 10 +++- apps/web-ele/src/router/routes/modules/diy.ts | 41 ------------- .../web-ele/src/router/routes/modules/mall.ts | 34 +++++++++++ .../mall/home/modules/operation-data-card.vue | 59 ++++++++++++------- .../views/mall/promotion/diy/page/index.vue | 1 - .../promotion/diy/page/modules/decorate.vue | 13 ++-- pnpm-lock.yaml | 3 + 9 files changed, 131 insertions(+), 90 deletions(-) delete mode 100644 apps/web-ele/src/router/routes/modules/diy.ts diff --git a/apps/web-antd/src/views/mall/home/modules/operation-data-card.vue b/apps/web-antd/src/views/mall/home/modules/operation-data-card.vue index 1bca28f21..ef0cd6d25 100644 --- a/apps/web-antd/src/views/mall/home/modules/operation-data-card.vue +++ b/apps/web-antd/src/views/mall/home/modules/operation-data-card.vue @@ -19,39 +19,59 @@ const router = useRouter(); interface DataItem { name: string; value: number; - routerName: string; + routerPath: string; prefix?: string; decimals?: number; } /** 数据 */ const data = reactive({ - orderUndelivered: { name: '待发货订单', value: 0, routerName: 'TradeOrder' }, + orderUndelivered: { + name: '待发货订单', + value: 0, + routerPath: '/mall/trade/order', + }, orderAfterSaleApply: { name: '退款中订单', value: 0, - routerName: 'TradeAfterSale', + routerPath: '/mall/trade/after-sale', + }, + orderWaitePickUp: { + name: '待核销订单', + value: 0, + routerPath: '/mall/trade/delivery/pick-up-store/pick-up-order', + }, + productAlertStock: { + name: '库存预警', + value: 0, + routerPath: '/mall/product/spu', + }, + productForSale: { + name: '上架商品', + value: 0, + routerPath: '/mall/product/spu', + }, + productInWarehouse: { + name: '仓库商品', + value: 0, + routerPath: '/mall/product/spu', }, - orderWaitePickUp: { name: '待核销订单', value: 0, routerName: 'TradeOrder' }, - productAlertStock: { name: '库存预警', value: 0, routerName: 'ProductSpu' }, - productForSale: { name: '上架商品', value: 0, routerName: 'ProductSpu' }, - productInWarehouse: { name: '仓库商品', value: 0, routerName: 'ProductSpu' }, withdrawAuditing: { name: '提现待审核', value: 0, - routerName: 'TradeBrokerageWithdraw', + routerPath: '/mall/trade/brokerage/brokerage-withdraw', }, rechargePrice: { name: '账户充值', value: 0, prefix: '¥', decimals: 2, - routerName: 'PayWalletRecharge', + routerPath: '/pay/wallet/wallet-balance', }, }); /** 查询订单数据 */ -const getOrderData = async () => { +async function getOrderData() { const orderCount = await TradeStatisticsApi.getOrderCount(); if (orderCount.undelivered) { data.orderUndelivered.value = orderCount.undelivered; @@ -65,27 +85,26 @@ const getOrderData = async () => { if (orderCount.auditingWithdraw) { data.withdrawAuditing.value = orderCount.auditingWithdraw; } -}; +} /** 查询商品数据 */ -const getProductData = async () => { +async function getProductData() { const productCount = await ProductSpuApi.getTabsCount(); data.productForSale.value = productCount['0'] || 0; data.productInWarehouse.value = productCount['1'] || 0; data.productAlertStock.value = productCount['3'] || 0; -}; +} /** 查询钱包充值数据 */ -const getWalletRechargeData = async () => { +async function getWalletRechargeData() { const paySummary = await PayStatisticsApi.getWalletRechargePrice(); data.rechargePrice.value = paySummary.rechargePrice; -}; +} /** 跳转到对应页面 */ -// TODO @xingyu:貌似通过 name 的方式,都无法跳转,找不到路由? -const handleClick = (routerName: string) => { - router.push({ name: routerName }); -}; +function handleClick(routerPath: string) { + router.push({ path: routerPath }); +} /** 激活时 */ onActivated(() => { @@ -109,7 +128,7 @@ onMounted(() => { v-for="(item, key) in data" :key="key" class="flex h-20 w-[20%] cursor-pointer flex-col items-center justify-center gap-2" - @click="handleClick(item.routerName)" + @click="handleClick(item.routerPath)" > { />
手机扫码预览 - + qrcode +
diff --git a/apps/web-ele/src/router/routes/modules/diy.ts b/apps/web-ele/src/router/routes/modules/diy.ts deleted file mode 100644 index 68bccd3ca..000000000 --- a/apps/web-ele/src/router/routes/modules/diy.ts +++ /dev/null @@ -1,41 +0,0 @@ -import type { RouteRecordRaw } from 'vue-router'; - -// TODO @chihuo:这个合并到 mall.ts 里 -const routes: RouteRecordRaw[] = [ - { - path: '/diy', - name: 'DiyCenter', - meta: { - title: '营销中心', - icon: 'lucide:shopping-bag', - keepAlive: true, - hideInMenu: true, - }, - children: [ - { - path: String.raw`template/decorate/:id(\d+)`, - name: 'DiyTemplateDecorate', - meta: { - title: '模板装修', - activePath: '/mall/promotion/diy-template/diy-template', - }, - component: () => - import('#/views/mall/promotion/diy/template/modules/decorate.vue'), - }, - { - path: 'page/decorate/:id', - name: 'DiyPageDecorate', - meta: { - title: '页面装修', - noCache: false, - hidden: true, - activePath: '/mall/promotion/diy-template/diy-page', - }, - component: () => - import('#/views/mall/promotion/diy/page/modules/decorate.vue'), - }, - ], - }, -]; - -export default routes; diff --git a/apps/web-ele/src/router/routes/modules/mall.ts b/apps/web-ele/src/router/routes/modules/mall.ts index d84e1c703..6d9303943 100644 --- a/apps/web-ele/src/router/routes/modules/mall.ts +++ b/apps/web-ele/src/router/routes/modules/mall.ts @@ -80,6 +80,40 @@ const routes: RouteRecordRaw[] = [ }, ], }, + { + path: '/diy', + name: 'DiyCenter', + meta: { + title: '营销中心', + icon: 'lucide:shopping-bag', + keepAlive: true, + hideInMenu: true, + }, + children: [ + { + path: String.raw`template/decorate/:id(\d+)`, + name: 'DiyTemplateDecorate', + meta: { + title: '模板装修', + activePath: '/mall/promotion/diy-template/diy-template', + }, + component: () => + import('#/views/mall/promotion/diy/template/modules/decorate.vue'), + }, + { + path: 'page/decorate/:id', + name: 'DiyPageDecorate', + meta: { + title: '页面装修', + noCache: false, + hidden: true, + activePath: '/mall/promotion/diy-template/diy-page', + }, + component: () => + import('#/views/mall/promotion/diy/page/modules/decorate.vue'), + }, + ], + }, ]; export default routes; diff --git a/apps/web-ele/src/views/mall/home/modules/operation-data-card.vue b/apps/web-ele/src/views/mall/home/modules/operation-data-card.vue index c9d0ad078..a8a35944b 100644 --- a/apps/web-ele/src/views/mall/home/modules/operation-data-card.vue +++ b/apps/web-ele/src/views/mall/home/modules/operation-data-card.vue @@ -19,39 +19,59 @@ const router = useRouter(); interface DataItem { name: string; value: number; - routerName: string; + routerPath: string; prefix?: string; decimals?: number; } /** 数据 */ const data = reactive({ - orderUndelivered: { name: '待发货订单', value: 0, routerName: 'TradeOrder' }, + orderUndelivered: { + name: '待发货订单', + value: 0, + routerPath: '/mall/trade/order', + }, orderAfterSaleApply: { name: '退款中订单', value: 0, - routerName: 'TradeAfterSale', + routerPath: '/mall/trade/after-sale', + }, + orderWaitePickUp: { + name: '待核销订单', + value: 0, + routerPath: '/mall/trade/delivery/pick-up-store/pick-up-order', + }, + productAlertStock: { + name: '库存预警', + value: 0, + routerPath: '/mall/product/spu', + }, + productForSale: { + name: '上架商品', + value: 0, + routerPath: '/mall/product/spu', + }, + productInWarehouse: { + name: '仓库商品', + value: 0, + routerPath: '/mall/product/spu', }, - orderWaitePickUp: { name: '待核销订单', value: 0, routerName: 'TradeOrder' }, - productAlertStock: { name: '库存预警', value: 0, routerName: 'ProductSpu' }, - productForSale: { name: '上架商品', value: 0, routerName: 'ProductSpu' }, - productInWarehouse: { name: '仓库商品', value: 0, routerName: 'ProductSpu' }, withdrawAuditing: { name: '提现待审核', value: 0, - routerName: 'TradeBrokerageWithdraw', + routerPath: '/mall/trade/brokerage/brokerage-withdraw', }, rechargePrice: { name: '账户充值', value: 0, prefix: '¥', decimals: 2, - routerName: 'PayWalletRecharge', + routerPath: '/pay/wallet/wallet-balance', }, }); /** 查询订单数据 */ -const getOrderData = async () => { +async function getOrderData() { const orderCount = await TradeStatisticsApi.getOrderCount(); if (orderCount.undelivered) { data.orderUndelivered.value = orderCount.undelivered; @@ -65,27 +85,26 @@ const getOrderData = async () => { if (orderCount.auditingWithdraw) { data.withdrawAuditing.value = orderCount.auditingWithdraw; } -}; +} /** 查询商品数据 */ -const getProductData = async () => { +async function getProductData() { const productCount = await ProductSpuApi.getTabsCount(); data.productForSale.value = productCount['0'] || 0; data.productInWarehouse.value = productCount['1'] || 0; data.productAlertStock.value = productCount['3'] || 0; -}; +} /** 查询钱包充值数据 */ -const getWalletRechargeData = async () => { +async function getWalletRechargeData() { const paySummary = await PayStatisticsApi.getWalletRechargePrice(); data.rechargePrice.value = paySummary.rechargePrice; -}; +} /** 跳转到对应页面 */ -// TODO @xingyu:貌似通过 name 的方式,都无法跳转,找不到路由? -const handleClick = (routerName: string) => { - router.push({ name: routerName }); -}; +function handleClick(routerPath: string) { + router.push({ path: routerPath }); +} /** 激活时 */ onActivated(() => { @@ -112,7 +131,7 @@ onMounted(() => { v-for="(item, key) in data" :key="key" class="flex h-20 w-[20%] cursor-pointer flex-col items-center justify-center gap-2" - @click="handleClick(item.routerName)" + @click="handleClick(item.routerPath)" > (); const formRef = ref(); // 表单 Ref // 获取详情 -const getPageDetail = async (id: any) => { +async function getPageDetail(id: any) { formLoading.value = true; try { formData.value = await DiyPageApi.getDiyPageProperty(id); } finally { formLoading.value = false; } -}; +} // 提交表单 -const submitForm = async () => { +async function submitForm() { // 校验表单 if (!formRef.value) return; // 提交请求 @@ -38,10 +39,10 @@ const submitForm = async () => { } finally { formLoading.value = false; } -}; +} // 重置表单 -const resetForm = () => { +function resetForm() { formData.value = { id: undefined, templateId: undefined, @@ -51,7 +52,7 @@ const resetForm = () => { property: '', } as MallDiyPageApi.DiyPage; formRef.value?.resetFields(); -}; +} /** 初始化 */ const route = useRoute(); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d8a78fdc1..2cc3953a1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -911,6 +911,9 @@ importers: '@vueuse/core': specifier: 'catalog:' version: 13.9.0(vue@3.5.22(typescript@5.9.3)) + '@vueuse/integrations': + specifier: 'catalog:' + version: 13.9.0(async-validator@4.2.5)(axios@1.12.2)(focus-trap@7.6.5)(nprogress@0.2.0)(qrcode@1.5.4)(sortablejs@1.15.6)(vue@3.5.22(typescript@5.9.3)) cropperjs: specifier: 'catalog:' version: 1.6.2