feat: 使用 path 进行跳转

This commit is contained in:
xingyu4j
2025-10-20 15:42:23 +08:00
parent dd70dc0012
commit 03644613f3
5 changed files with 29 additions and 31 deletions

View File

@@ -41,7 +41,7 @@ const timeRangeConfig = {
const timeRangeType = ref(TimeRangeTypeEnum.DAY30); // 日期快捷选择按钮, 默认 30 天 const timeRangeType = ref(TimeRangeTypeEnum.DAY30); // 日期快捷选择按钮, 默认 30 天
/** 时间范围类型单选按钮选中 */ /** 时间范围类型单选按钮选中 */
const handleTimeRangeTypeChange = async () => { async function handleTimeRangeTypeChange() {
// 设置时间范围 // 设置时间范围
let beginTime: Dayjs; let beginTime: Dayjs;
let endTime: Dayjs; let endTime: Dayjs;
@@ -72,7 +72,7 @@ const handleTimeRangeTypeChange = async () => {
} }
// 发送时间范围选中事件 // 发送时间范围选中事件
await getMemberRegisterCountList(beginTime, endTime); await getMemberRegisterCountList(beginTime, endTime);
}; }
async function getMemberRegisterCountList(beginTime: Dayjs, endTime: Dayjs) { async function getMemberRegisterCountList(beginTime: Dayjs, endTime: Dayjs) {
loading.value = true; loading.value = true;

View File

@@ -16,56 +16,55 @@ const menuList = [
name: '用户管理', name: '用户管理',
icon: 'ep:user-filled', icon: 'ep:user-filled',
bgColor: 'bg-red-400', bgColor: 'bg-red-400',
routerName: 'MemberUser', routerPath: '/member/user',
}, },
{ {
name: '商品管理', name: '商品管理',
icon: 'fluent-mdl2:product', icon: 'fluent-mdl2:product',
bgColor: 'bg-orange-400', bgColor: 'bg-orange-400',
routerName: 'ProductSpu', routerPath: '/mall/product/spu',
}, },
{ {
name: '订单管理', name: '订单管理',
icon: 'ep:list', icon: 'ep:list',
bgColor: 'bg-yellow-500', bgColor: 'bg-yellow-500',
routerName: 'TradeOrder', routerPath: '/mall/trade/order',
}, },
{ {
name: '售后管理', name: '售后管理',
icon: 'ri:refund-2-line', icon: 'ri:refund-2-line',
bgColor: 'bg-green-600', bgColor: 'bg-green-600',
routerName: 'TradeAfterSale', routerPath: '/mall/trade/after-sale',
}, },
{ {
name: '分销管理', name: '分销管理',
icon: 'fa-solid:project-diagram', icon: 'fa-solid:project-diagram',
bgColor: 'bg-cyan-500', bgColor: 'bg-cyan-500',
routerName: 'TradeBrokerageUser', routerPath: '/mall/trade/brokerage/brokerage-user',
}, },
{ {
name: '优惠券', name: '优惠券',
icon: 'ep:ticket', icon: 'ep:ticket',
bgColor: 'bg-blue-500', bgColor: 'bg-blue-500',
routerName: 'PromotionCoupon', routerPath: '/mall/promotion/coupon/template',
}, },
{ {
name: '拼团活动', name: '拼团活动',
icon: 'fa:group', icon: 'fa:group',
bgColor: 'bg-purple-500', bgColor: 'bg-purple-500',
routerName: 'PromotionBargainActivity', routerPath: '/mall/promotion/combination/acitivity',
}, },
{ {
name: '佣金提现', name: '佣金提现',
icon: 'vaadin:money-withdraw', icon: 'vaadin:money-withdraw',
bgColor: 'bg-rose-500', bgColor: 'bg-rose-500',
routerName: 'TradeBrokerageWithdraw', routerPath: '/mall/trade/brokerage/brokerage-withdraw',
}, },
]; ];
/** 跳转到菜单对应页面 */ /** 跳转到菜单对应页面 */
// TODO @xingyu貌似通过 name 的方式,都无法跳转,找不到路由? function handleMenuClick(routerPath: string) {
function handleMenuClick(routerName: string) { router.push({ path: routerPath });
router.push({ name: routerName });
} }
</script> </script>
@@ -76,7 +75,7 @@ function handleMenuClick(routerName: string) {
v-for="menu in menuList" v-for="menu in menuList"
:key="menu.name" :key="menu.name"
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="handleMenuClick(menu.routerName)" @click="handleMenuClick(menu.routerPath)"
> >
<div <div
:class="menu.bgColor" :class="menu.bgColor"

View File

@@ -46,7 +46,7 @@ const timeRangeConfig = {
const timeRangeType = ref(TimeRangeTypeEnum.DAY30); // 日期快捷选择按钮, 默认 30 天 const timeRangeType = ref(TimeRangeTypeEnum.DAY30); // 日期快捷选择按钮, 默认 30 天
/** 时间范围类型单选按钮选中 */ /** 时间范围类型单选按钮选中 */
const handleTimeRangeTypeChange = async () => { async function handleTimeRangeTypeChange() {
// 设置时间范围 // 设置时间范围
let beginTime: Dayjs; let beginTime: Dayjs;
let endTime: Dayjs; let endTime: Dayjs;
@@ -77,7 +77,7 @@ const handleTimeRangeTypeChange = async () => {
} }
// 发送时间范围选中事件 // 发送时间范围选中事件
await getOrderCountTrendComparison(beginTime, endTime); await getOrderCountTrendComparison(beginTime, endTime);
}; }
/** 查询订单数量趋势对照数据 */ /** 查询订单数量趋势对照数据 */
async function getOrderCountTrendComparison(beginTime: Dayjs, endTime: Dayjs) { async function getOrderCountTrendComparison(beginTime: Dayjs, endTime: Dayjs) {

View File

@@ -16,56 +16,55 @@ const menuList = [
name: '用户管理', name: '用户管理',
icon: 'ep:user-filled', icon: 'ep:user-filled',
bgColor: 'bg-red-400', bgColor: 'bg-red-400',
routerName: 'MemberUser', routerPath: '/member/user',
}, },
{ {
name: '商品管理', name: '商品管理',
icon: 'fluent-mdl2:product', icon: 'fluent-mdl2:product',
bgColor: 'bg-orange-400', bgColor: 'bg-orange-400',
routerName: 'ProductSpu', routerPath: '/mall/product/spu',
}, },
{ {
name: '订单管理', name: '订单管理',
icon: 'ep:list', icon: 'ep:list',
bgColor: 'bg-yellow-500', bgColor: 'bg-yellow-500',
routerName: 'TradeOrder', routerPath: '/mall/trade/order',
}, },
{ {
name: '售后管理', name: '售后管理',
icon: 'ri:refund-2-line', icon: 'ri:refund-2-line',
bgColor: 'bg-green-600', bgColor: 'bg-green-600',
routerName: 'TradeAfterSale', routerPath: '/mall/trade/after-sale',
}, },
{ {
name: '分销管理', name: '分销管理',
icon: 'fa-solid:project-diagram', icon: 'fa-solid:project-diagram',
bgColor: 'bg-cyan-500', bgColor: 'bg-cyan-500',
routerName: 'TradeBrokerageUser', routerPath: '/mall/trade/brokerage/brokerage-user',
}, },
{ {
name: '优惠券', name: '优惠券',
icon: 'ep:ticket', icon: 'ep:ticket',
bgColor: 'bg-blue-500', bgColor: 'bg-blue-500',
routerName: 'PromotionCoupon', routerPath: '/mall/promotion/coupon/template',
}, },
{ {
name: '拼团活动', name: '拼团活动',
icon: 'fa:group', icon: 'fa:group',
bgColor: 'bg-purple-500', bgColor: 'bg-purple-500',
routerName: 'PromotionBargainActivity', routerPath: '/mall/promotion/combination/acitivity',
}, },
{ {
name: '佣金提现', name: '佣金提现',
icon: 'vaadin:money-withdraw', icon: 'vaadin:money-withdraw',
bgColor: 'bg-rose-500', bgColor: 'bg-rose-500',
routerName: 'TradeBrokerageWithdraw', routerPath: '/mall/trade/brokerage/brokerage-withdraw',
}, },
]; ];
/** 跳转到菜单对应页面 */ /** 跳转到菜单对应页面 */
// TODO @xingyu貌似通过 name 的方式,都无法跳转,找不到路由? function handleMenuClick(routerPath: string) {
function handleMenuClick(routerName: string) { router.push({ path: routerPath });
router.push({ name: routerName });
} }
</script> </script>
@@ -79,7 +78,7 @@ function handleMenuClick(routerName: string) {
v-for="menu in menuList" v-for="menu in menuList"
:key="menu.name" :key="menu.name"
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="handleMenuClick(menu.routerName)" @click="handleMenuClick(menu.routerPath)"
> >
<div <div
:class="menu.bgColor" :class="menu.bgColor"

View File

@@ -8,8 +8,8 @@ import { onMounted, ref } from 'vue';
import { EchartsUI, useEcharts } from '@vben/plugins/echarts'; import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import { fenToYuan } from '@vben/utils'; import { fenToYuan } from '@vben/utils';
import { ElCard, ElRadio, ElRadioGroup } from 'element-plus';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { ElCard, ElRadio, ElRadioGroup } from 'element-plus';
import * as TradeStatisticsApi from '#/api/mall/statistics/trade'; import * as TradeStatisticsApi from '#/api/mall/statistics/trade';
@@ -46,7 +46,7 @@ const timeRangeConfig = {
const timeRangeType = ref(TimeRangeTypeEnum.DAY30); // 日期快捷选择按钮, 默认 30 天 const timeRangeType = ref(TimeRangeTypeEnum.DAY30); // 日期快捷选择按钮, 默认 30 天
/** 时间范围类型单选按钮选中 */ /** 时间范围类型单选按钮选中 */
const handleTimeRangeTypeChange = async () => { async function handleTimeRangeTypeChange() {
// 设置时间范围 // 设置时间范围
let beginTime: Dayjs; let beginTime: Dayjs;
let endTime: Dayjs; let endTime: Dayjs;
@@ -77,7 +77,7 @@ const handleTimeRangeTypeChange = async () => {
} }
// 发送时间范围选中事件 // 发送时间范围选中事件
await getOrderCountTrendComparison(beginTime, endTime); await getOrderCountTrendComparison(beginTime, endTime);
}; }
/** 查询订单数量趋势对照数据 */ /** 查询订单数量趋势对照数据 */
async function getOrderCountTrendComparison(beginTime: Dayjs, endTime: Dayjs) { async function getOrderCountTrendComparison(beginTime: Dayjs, endTime: Dayjs) {