feat:使用 router name 进行跳转

This commit is contained in:
YunaiV
2025-10-20 19:14:00 +08:00
parent 2b15a1835d
commit fba34d6ceb
7 changed files with 49 additions and 89 deletions

View File

@@ -197,7 +197,7 @@ async function handleSubmit(values: Recordable<any>) {
await smsResetPassword({ mobile, code, password });
message.success($t('authentication.resetPasswordSuccess'));
// 重置成功后跳转到首页
router.push('/');
await router.push('/');
} catch (error) {
console.error('重置密码失败:', error);
} finally {

View File

@@ -118,7 +118,7 @@ async function handleSave() {
// 保存成功,提示并跳转到列表页
message.success('保存成功');
tabs.closeCurrentTab();
await tabs.closeCurrentTab();
await router.push({ name: 'AiWorkflow' });
} catch (error: any) {
console.error('保存失败:', error);

View File

@@ -320,7 +320,7 @@ async function handleSave() {
// 返回列表页(排除更新的情况)
if (actionType !== 'update') {
router.push({ path: '/bpm/manager/model' });
await router.push({ path: '/bpm/manager/model' });
}
} catch (error: any) {
console.error('保存失败:', error);

View File

@@ -19,54 +19,34 @@ const router = useRouter();
interface DataItem {
name: string;
value: number;
routerPath: string;
routerName: string;
prefix?: string;
decimals?: number;
}
/** 数据 */
const data = reactive({
orderUndelivered: {
name: '待发货订单',
value: 0,
routerPath: '/mall/trade/order',
},
orderUndelivered: { name: '待发货订单', value: 0, routerName: 'TradeOrder' },
orderAfterSaleApply: {
name: '退款中订单',
value: 0,
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',
routerName: 'TradeAfterSale',
},
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,
routerPath: '/mall/trade/brokerage/brokerage-withdraw',
routerName: 'TradeBrokerageWithdraw',
},
rechargePrice: {
name: '账户充值',
value: 0,
prefix: '¥',
decimals: 2,
routerPath: '/pay/wallet/wallet-balance',
routerName: 'PayWalletRecharge',
},
});
@@ -102,8 +82,8 @@ async function getWalletRechargeData() {
}
/** 跳转到对应页面 */
function handleClick(routerPath: string) {
router.push({ path: routerPath });
function handleClick(routerName: string) {
router.push({ name: routerName });
}
/** 激活时 */
@@ -128,7 +108,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.routerPath)"
@click="handleClick(item.routerName)"
>
<CountTo
:decimals="(item as DataItem).decimals ?? 0"

View File

@@ -16,55 +16,55 @@ const menuList = [
name: '用户管理',
icon: 'ep:user-filled',
bgColor: 'bg-red-400',
routerPath: '/member/user',
routerName: 'MemberUser',
},
{
name: '商品管理',
icon: 'fluent-mdl2:product',
bgColor: 'bg-orange-400',
routerPath: '/mall/product/spu',
routerName: 'ProductSpu',
},
{
name: '订单管理',
icon: 'ep:list',
bgColor: 'bg-yellow-500',
routerPath: '/mall/trade/order',
routerName: 'TradeOrder',
},
{
name: '售后管理',
icon: 'ri:refund-2-line',
bgColor: 'bg-green-600',
routerPath: '/mall/trade/after-sale',
routerName: 'TradeAfterSale',
},
{
name: '分销管理',
icon: 'fa-solid:project-diagram',
bgColor: 'bg-cyan-500',
routerPath: '/mall/trade/brokerage/brokerage-user',
routerName: 'TradeBrokerageUser',
},
{
name: '优惠券',
icon: 'ep:ticket',
bgColor: 'bg-blue-500',
routerPath: '/mall/promotion/coupon/template',
routerName: 'PromotionCoupon',
},
{
name: '拼团活动',
icon: 'fa:group',
bgColor: 'bg-purple-500',
routerPath: '/mall/promotion/combination/acitivity',
routerName: 'PromotionBargainActivity',
},
{
name: '佣金提现',
icon: 'vaadin:money-withdraw',
bgColor: 'bg-rose-500',
routerPath: '/mall/trade/brokerage/brokerage-withdraw',
routerName: 'TradeBrokerageWithdraw',
},
];
/** 跳转到菜单对应页面 */
function handleMenuClick(routerPath: string) {
router.push({ path: routerPath });
function handleMenuClick(routerName: string) {
router.push({ name: routerName });
}
</script>
@@ -75,7 +75,7 @@ function handleMenuClick(routerPath: string) {
v-for="menu in menuList"
:key="menu.name"
class="flex h-20 w-[20%] cursor-pointer flex-col items-center justify-center gap-2"
@click="handleMenuClick(menu.routerPath)"
@click="handleMenuClick(menu.routerName)"
>
<div
:class="menu.bgColor"

View File

@@ -19,54 +19,34 @@ const router = useRouter();
interface DataItem {
name: string;
value: number;
routerPath: string;
routerName: string;
prefix?: string;
decimals?: number;
}
/** 数据 */
const data = reactive({
orderUndelivered: {
name: '待发货订单',
value: 0,
routerPath: '/mall/trade/order',
},
orderUndelivered: { name: '待发货订单', value: 0, routerName: 'TradeOrder' },
orderAfterSaleApply: {
name: '退款中订单',
value: 0,
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',
routerName: 'TradeAfterSale',
},
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,
routerPath: '/mall/trade/brokerage/brokerage-withdraw',
routerName: 'TradeBrokerageWithdraw',
},
rechargePrice: {
name: '账户充值',
value: 0,
prefix: '¥',
decimals: 2,
routerPath: '/pay/wallet/wallet-balance',
routerName: 'PayWalletRecharge',
},
});
@@ -102,8 +82,8 @@ async function getWalletRechargeData() {
}
/** 跳转到对应页面 */
function handleClick(routerPath: string) {
router.push({ path: routerPath });
function handleClick(routerName: string) {
router.push({ name: routerName });
}
/** 激活时 */
@@ -131,7 +111,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.routerPath)"
@click="handleClick(item.routerName)"
>
<CountTo
:decimals="(item as DataItem).decimals ?? 0"

View File

@@ -16,55 +16,55 @@ const menuList = [
name: '用户管理',
icon: 'ep:user-filled',
bgColor: 'bg-red-400',
routerPath: '/member/user',
routerName: 'MemberUser',
},
{
name: '商品管理',
icon: 'fluent-mdl2:product',
bgColor: 'bg-orange-400',
routerPath: '/mall/product/spu',
routerName: 'ProductSpu',
},
{
name: '订单管理',
icon: 'ep:list',
bgColor: 'bg-yellow-500',
routerPath: '/mall/trade/order',
routerName: 'TradeOrder',
},
{
name: '售后管理',
icon: 'ri:refund-2-line',
bgColor: 'bg-green-600',
routerPath: '/mall/trade/after-sale',
routerName: 'TradeAfterSale',
},
{
name: '分销管理',
icon: 'fa-solid:project-diagram',
bgColor: 'bg-cyan-500',
routerPath: '/mall/trade/brokerage/brokerage-user',
routerName: 'TradeBrokerageUser',
},
{
name: '优惠券',
icon: 'ep:ticket',
bgColor: 'bg-blue-500',
routerPath: '/mall/promotion/coupon/template',
routerName: 'PromotionCoupon',
},
{
name: '拼团活动',
icon: 'fa:group',
bgColor: 'bg-purple-500',
routerPath: '/mall/promotion/combination/acitivity',
routerName: 'PromotionBargainActivity',
},
{
name: '佣金提现',
icon: 'vaadin:money-withdraw',
bgColor: 'bg-rose-500',
routerPath: '/mall/trade/brokerage/brokerage-withdraw',
routerName: 'TradeBrokerageWithdraw',
},
];
/** 跳转到菜单对应页面 */
function handleMenuClick(routerPath: string) {
router.push({ path: routerPath });
function handleMenuClick(routerName: string) {
router.push({ name: routerName });
}
</script>
@@ -78,7 +78,7 @@ function handleMenuClick(routerPath: string) {
v-for="menu in menuList"
:key="menu.name"
class="flex h-20 w-[20%] cursor-pointer flex-col items-center justify-center gap-2"
@click="handleMenuClick(menu.routerPath)"
@click="handleMenuClick(menu.routerName)"
>
<div
:class="menu.bgColor"