fix: router push

This commit is contained in:
xingyu4j
2025-10-20 15:36:06 +08:00
parent 95bda979a1
commit dd70dc0012
9 changed files with 131 additions and 90 deletions

View File

@@ -19,39 +19,59 @@ const router = useRouter();
interface DataItem { interface DataItem {
name: string; name: string;
value: number; value: number;
routerName: string; routerPath: string;
prefix?: string; prefix?: string;
decimals?: number; decimals?: number;
} }
/** 数据 */ /** 数据 */
const data = reactive({ const data = reactive({
orderUndelivered: { name: '待发货订单', value: 0, routerName: 'TradeOrder' }, orderUndelivered: {
name: '待发货订单',
value: 0,
routerPath: '/mall/trade/order',
},
orderAfterSaleApply: { orderAfterSaleApply: {
name: '退款中订单', name: '退款中订单',
value: 0, 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: { withdrawAuditing: {
name: '提现待审核', name: '提现待审核',
value: 0, value: 0,
routerName: 'TradeBrokerageWithdraw', routerPath: '/mall/trade/brokerage/brokerage-withdraw',
}, },
rechargePrice: { rechargePrice: {
name: '账户充值', name: '账户充值',
value: 0, value: 0,
prefix: '¥', prefix: '¥',
decimals: 2, decimals: 2,
routerName: 'PayWalletRecharge', routerPath: '/pay/wallet/wallet-balance',
}, },
}); });
/** 查询订单数据 */ /** 查询订单数据 */
const getOrderData = async () => { async function getOrderData() {
const orderCount = await TradeStatisticsApi.getOrderCount(); const orderCount = await TradeStatisticsApi.getOrderCount();
if (orderCount.undelivered) { if (orderCount.undelivered) {
data.orderUndelivered.value = orderCount.undelivered; data.orderUndelivered.value = orderCount.undelivered;
@@ -65,27 +85,26 @@ const getOrderData = async () => {
if (orderCount.auditingWithdraw) { if (orderCount.auditingWithdraw) {
data.withdrawAuditing.value = orderCount.auditingWithdraw; data.withdrawAuditing.value = orderCount.auditingWithdraw;
} }
}; }
/** 查询商品数据 */ /** 查询商品数据 */
const getProductData = async () => { async function getProductData() {
const productCount = await ProductSpuApi.getTabsCount(); const productCount = await ProductSpuApi.getTabsCount();
data.productForSale.value = productCount['0'] || 0; data.productForSale.value = productCount['0'] || 0;
data.productInWarehouse.value = productCount['1'] || 0; data.productInWarehouse.value = productCount['1'] || 0;
data.productAlertStock.value = productCount['3'] || 0; data.productAlertStock.value = productCount['3'] || 0;
}; }
/** 查询钱包充值数据 */ /** 查询钱包充值数据 */
const getWalletRechargeData = async () => { async function getWalletRechargeData() {
const paySummary = await PayStatisticsApi.getWalletRechargePrice(); const paySummary = await PayStatisticsApi.getWalletRechargePrice();
data.rechargePrice.value = paySummary.rechargePrice; data.rechargePrice.value = paySummary.rechargePrice;
}; }
/** 跳转到对应页面 */ /** 跳转到对应页面 */
// TODO @xingyu貌似通过 name 的方式,都无法跳转,找不到路由? function handleClick(routerPath: string) {
const handleClick = (routerName: string) => { router.push({ path: routerPath });
router.push({ name: routerName }); }
};
/** 激活时 */ /** 激活时 */
onActivated(() => { onActivated(() => {
@@ -109,7 +128,7 @@ onMounted(() => {
v-for="(item, key) in data" v-for="(item, key) in data"
:key="key" :key="key"
class="flex h-20 w-[20%] cursor-pointer flex-col items-center justify-center gap-2" class="flex h-20 w-[20%] cursor-pointer flex-col items-center justify-center gap-2"
@click="handleClick(item.routerName)" @click="handleClick(item.routerPath)"
> >
<CountTo <CountTo
:decimals="(item as DataItem).decimals ?? 0" :decimals="(item as DataItem).decimals ?? 0"

View File

@@ -44,6 +44,7 @@
"@vben/types": "workspace:*", "@vben/types": "workspace:*",
"@vben/utils": "workspace:*", "@vben/utils": "workspace:*",
"@vueuse/core": "catalog:", "@vueuse/core": "catalog:",
"@vueuse/integrations": "catalog:",
"cropperjs": "catalog:", "cropperjs": "catalog:",
"dayjs": "catalog:", "dayjs": "catalog:",
"element-plus": "catalog:", "element-plus": "catalog:",

View File

@@ -7,6 +7,7 @@ import { IFrame } from '@vben/common-ui';
import { IconifyIcon } from '@vben/icons'; import { IconifyIcon } from '@vben/icons';
import { cloneDeep, isEmpty, isString } from '@vben/utils'; import { cloneDeep, isEmpty, isString } from '@vben/utils';
import { useQRCode } from '@vueuse/integrations/useQRCode';
import { import {
ElAside, ElAside,
ElButtonGroup, ElButtonGroup,
@@ -32,7 +33,6 @@ import ComponentContainer from './components/component-container.vue';
import ComponentLibrary from './components/component-library.vue'; import ComponentLibrary from './components/component-library.vue';
import { component as NAVIGATION_BAR_COMPONENT } from './components/mobile/navigation-bar/config'; import { component as NAVIGATION_BAR_COMPONENT } from './components/mobile/navigation-bar/config';
import { component as TAB_BAR_COMPONENT } from './components/mobile/tab-bar/config'; import { component as TAB_BAR_COMPONENT } from './components/mobile/tab-bar/config';
/** 页面装修详情页 */ /** 页面装修详情页 */
defineOptions({ defineOptions({
name: 'DiyPageDetail', name: 'DiyPageDetail',
@@ -58,6 +58,11 @@ const props = defineProps({
// 工具栏操作 // 工具栏操作
const emits = defineEmits(['reset', 'preview', 'save', 'update:modelValue']); const emits = defineEmits(['reset', 'preview', 'save', 'update:modelValue']);
const qrcode = useQRCode(props.previewUrl, {
errorCorrectionLevel: 'H',
margin: 4,
});
// 左侧组件库 // 左侧组件库
const componentLibrary = ref(); const componentLibrary = ref();
// 页面设置组件 // 页面设置组件
@@ -497,7 +502,8 @@ onMounted(() => {
/> />
<div class="flex flex-col"> <div class="flex flex-col">
<ElText>手机扫码预览</ElText> <ElText>手机扫码预览</ElText>
<Qrcode :text="previewUrl" logo="/logo.gif" /> <img :src="qrcode" alt="qrcode" class="w-1/2" />
<!-- <Qrcode :text="previewUrl" logo="/logo.gif" /> -->
</div> </div>
</div> </div>
</ElDialog> </ElDialog>

View File

@@ -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;

View File

@@ -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; export default routes;

View File

@@ -19,39 +19,59 @@ const router = useRouter();
interface DataItem { interface DataItem {
name: string; name: string;
value: number; value: number;
routerName: string; routerPath: string;
prefix?: string; prefix?: string;
decimals?: number; decimals?: number;
} }
/** 数据 */ /** 数据 */
const data = reactive({ const data = reactive({
orderUndelivered: { name: '待发货订单', value: 0, routerName: 'TradeOrder' }, orderUndelivered: {
name: '待发货订单',
value: 0,
routerPath: '/mall/trade/order',
},
orderAfterSaleApply: { orderAfterSaleApply: {
name: '退款中订单', name: '退款中订单',
value: 0, 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: { withdrawAuditing: {
name: '提现待审核', name: '提现待审核',
value: 0, value: 0,
routerName: 'TradeBrokerageWithdraw', routerPath: '/mall/trade/brokerage/brokerage-withdraw',
}, },
rechargePrice: { rechargePrice: {
name: '账户充值', name: '账户充值',
value: 0, value: 0,
prefix: '¥', prefix: '¥',
decimals: 2, decimals: 2,
routerName: 'PayWalletRecharge', routerPath: '/pay/wallet/wallet-balance',
}, },
}); });
/** 查询订单数据 */ /** 查询订单数据 */
const getOrderData = async () => { async function getOrderData() {
const orderCount = await TradeStatisticsApi.getOrderCount(); const orderCount = await TradeStatisticsApi.getOrderCount();
if (orderCount.undelivered) { if (orderCount.undelivered) {
data.orderUndelivered.value = orderCount.undelivered; data.orderUndelivered.value = orderCount.undelivered;
@@ -65,27 +85,26 @@ const getOrderData = async () => {
if (orderCount.auditingWithdraw) { if (orderCount.auditingWithdraw) {
data.withdrawAuditing.value = orderCount.auditingWithdraw; data.withdrawAuditing.value = orderCount.auditingWithdraw;
} }
}; }
/** 查询商品数据 */ /** 查询商品数据 */
const getProductData = async () => { async function getProductData() {
const productCount = await ProductSpuApi.getTabsCount(); const productCount = await ProductSpuApi.getTabsCount();
data.productForSale.value = productCount['0'] || 0; data.productForSale.value = productCount['0'] || 0;
data.productInWarehouse.value = productCount['1'] || 0; data.productInWarehouse.value = productCount['1'] || 0;
data.productAlertStock.value = productCount['3'] || 0; data.productAlertStock.value = productCount['3'] || 0;
}; }
/** 查询钱包充值数据 */ /** 查询钱包充值数据 */
const getWalletRechargeData = async () => { async function getWalletRechargeData() {
const paySummary = await PayStatisticsApi.getWalletRechargePrice(); const paySummary = await PayStatisticsApi.getWalletRechargePrice();
data.rechargePrice.value = paySummary.rechargePrice; data.rechargePrice.value = paySummary.rechargePrice;
}; }
/** 跳转到对应页面 */ /** 跳转到对应页面 */
// TODO @xingyu貌似通过 name 的方式,都无法跳转,找不到路由? function handleClick(routerPath: string) {
const handleClick = (routerName: string) => { router.push({ path: routerPath });
router.push({ name: routerName }); }
};
/** 激活时 */ /** 激活时 */
onActivated(() => { onActivated(() => {
@@ -112,7 +131,7 @@ onMounted(() => {
v-for="(item, key) in data" v-for="(item, key) in data"
:key="key" :key="key"
class="flex h-20 w-[20%] cursor-pointer flex-col items-center justify-center gap-2" class="flex h-20 w-[20%] cursor-pointer flex-col items-center justify-center gap-2"
@click="handleClick(item.routerName)" @click="handleClick(item.routerPath)"
> >
<CountTo <CountTo
:decimals="(item as DataItem).decimals ?? 0" :decimals="(item as DataItem).decimals ?? 0"

View File

@@ -39,7 +39,6 @@ function handleEdit(row: MallDiyPageApi.DiyPage) {
formModalApi.setData(row).open(); formModalApi.setData(row).open();
} }
// TODO @霖:貌似跳转不过去;
/** 装修页面 */ /** 装修页面 */
function handleDecorate(row: MallDiyPageApi.DiyPage) { function handleDecorate(row: MallDiyPageApi.DiyPage) {
push({ name: 'DiyPageDecorate', params: { id: row.id } }); push({ name: 'DiyPageDecorate', params: { id: row.id } });

View File

@@ -7,6 +7,7 @@ import { useRoute } from 'vue-router';
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
import * as DiyPageApi from '#/api/mall/promotion/diy/page'; import * as DiyPageApi from '#/api/mall/promotion/diy/page';
import DiyEditor from '#/components/diy-editor/index.vue';
import { PAGE_LIBS } from '#/components/diy-editor/util'; import { PAGE_LIBS } from '#/components/diy-editor/util';
/** 装修页面表单 */ /** 装修页面表单 */
@@ -17,17 +18,17 @@ const formData = ref<MallDiyPageApi.DiyPage>();
const formRef = ref(); // 表单 Ref const formRef = ref(); // 表单 Ref
// 获取详情 // 获取详情
const getPageDetail = async (id: any) => { async function getPageDetail(id: any) {
formLoading.value = true; formLoading.value = true;
try { try {
formData.value = await DiyPageApi.getDiyPageProperty(id); formData.value = await DiyPageApi.getDiyPageProperty(id);
} finally { } finally {
formLoading.value = false; formLoading.value = false;
} }
}; }
// 提交表单 // 提交表单
const submitForm = async () => { async function submitForm() {
// 校验表单 // 校验表单
if (!formRef.value) return; if (!formRef.value) return;
// 提交请求 // 提交请求
@@ -38,10 +39,10 @@ const submitForm = async () => {
} finally { } finally {
formLoading.value = false; formLoading.value = false;
} }
}; }
// 重置表单 // 重置表单
const resetForm = () => { function resetForm() {
formData.value = { formData.value = {
id: undefined, id: undefined,
templateId: undefined, templateId: undefined,
@@ -51,7 +52,7 @@ const resetForm = () => {
property: '', property: '',
} as MallDiyPageApi.DiyPage; } as MallDiyPageApi.DiyPage;
formRef.value?.resetFields(); formRef.value?.resetFields();
}; }
/** 初始化 */ /** 初始化 */
const route = useRoute(); const route = useRoute();

3
pnpm-lock.yaml generated
View File

@@ -911,6 +911,9 @@ importers:
'@vueuse/core': '@vueuse/core':
specifier: 'catalog:' specifier: 'catalog:'
version: 13.9.0(vue@3.5.22(typescript@5.9.3)) 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: cropperjs:
specifier: 'catalog:' specifier: 'catalog:'
version: 1.6.2 version: 1.6.2