fix: fix merge conflicts
This commit is contained in:
commit
03b9b46ebd
114 files changed
+11408
-2996
No files matched your search
@@ -1,14 +1,16 @@
|
||||
/**
|
||||
* app/router/guards.ts
|
||||
* 全局路由守卫:认证、权限、旧 URL 兼容、document.title。
|
||||
* 依赖:vue-router、config、auth.store、i18n、adminModulePath、isPublicPath。
|
||||
* 逻辑:beforeEach 做登录/管理员校验;afterEach 将 meta.title(i18n key 或字面量)解析为浏览器标题。
|
||||
* 依赖:vue-router、config、auth.store、i18n、adminModulePath、isPublicPath、useMessage、contract-payment 权限常量。
|
||||
* 逻辑:beforeEach 做登录/管理员/功能权限校验;afterEach 将 meta.title(i18n key 或字面量)解析为浏览器标题。
|
||||
*/
|
||||
import type { Router } from 'vue-router';
|
||||
import { config } from '@/config';
|
||||
import { adminModulePath } from '@/features/admin/constants/modules';
|
||||
import { useAuthStore } from '@/features/auth/stores/auth.store';
|
||||
import { CONTRACT_PAYMENT_ACCESS_PERMISSION } from '@/features/contract-payment/constants';
|
||||
import { isPublicPath } from '@/shared/constants/routes';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
/**
|
||||
@@ -54,6 +56,11 @@ function setupChunkLoadRecovery(router: Router): void {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
注册全局 beforeEach / afterEach:登录、管理员、功能权限与页面标题。
|
||||
* 核心逻辑:requiresAdmin 仍静默回应用管理;requiresFeaturePermission 会提示后再跳转,避免用户以为入口损坏。
|
||||
* @param router - 应用根路由实例
|
||||
*/
|
||||
export function setupRouterGuards(router: Router): void {
|
||||
router.beforeEach((to, _from, next) => {
|
||||
const auth = useAuthStore();
|
||||
@@ -81,6 +88,19 @@ export function setupRouterGuards(router: Router): void {
|
||||
return;
|
||||
}
|
||||
|
||||
const requiredFeature = to.matched
|
||||
.map((record) => record.meta.requiresFeaturePermission)
|
||||
.find((key): key is string => Boolean(key));
|
||||
if (requiredFeature && !auth.hasFeaturePermission(requiredFeature)) {
|
||||
// 无专项权限时提示后再回应用管理,避免静默跳转让用户以为菜单坏了。
|
||||
const messageKey = requiredFeature === CONTRACT_PAYMENT_ACCESS_PERMISSION
|
||||
? 'errors.codes.CONTRACT_PAYMENT_FORBIDDEN'
|
||||
: 'errors.codes.AUTH_FORBIDDEN';
|
||||
useMessage().warning(String(i18n.global.t(messageKey)));
|
||||
next('/workspace/applications');
|
||||
return;
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/**
|
||||
* app/router/routes/workspace.routes.ts
|
||||
* 工作台路由表:/workspace 布局壳 + 各业务子页面懒加载。
|
||||
* 依赖:vue-router;meta.title 存 i18n key(workspace.*),由 guards 解析为 document.title。
|
||||
* 逻辑:WorkspaceLayout 嵌套应用首页、知识库、排程、反馈等子页。
|
||||
* 依赖:vue-router、contract-payment 权限常量;meta.title 存 i18n key(workspace.*),由 guards 解析为 document.title。
|
||||
* 逻辑:WorkspaceLayout 嵌套应用首页、知识库、排程、反馈等子页;合同付款子路由用 requiresFeaturePermission 而非 requiresAdmin。
|
||||
*/
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
import { CONTRACT_PAYMENT_ACCESS_PERMISSION } from '@/features/contract-payment/constants';
|
||||
|
||||
export const workspaceRoutes: RouteRecordRaw[] = [
|
||||
{
|
||||
@@ -83,6 +84,30 @@ export const workspaceRoutes: RouteRecordRaw[] = [
|
||||
component: () => import('@/features/workspace/pages/AccountingVoucherCheckPage.vue'),
|
||||
meta: { title: 'workspace.nav.accountingVoucherCheck', requiresAdmin: true },
|
||||
},
|
||||
{
|
||||
path: 'contract-payment',
|
||||
name: 'workspace-contract-payment',
|
||||
component: () => import('@/features/contract-payment/views/ContractPaymentPage.vue'),
|
||||
meta: { title: 'workspace.nav.contractPayment', requiresFeaturePermission: CONTRACT_PAYMENT_ACCESS_PERMISSION },
|
||||
},
|
||||
{
|
||||
path: 'contract-payment/review',
|
||||
name: 'workspace-contract-payment-review',
|
||||
component: () => import('@/features/contract-payment/views/ContractPaymentReviewPage.vue'),
|
||||
meta: { title: 'workspace.nav.contractPaymentReview', requiresFeaturePermission: CONTRACT_PAYMENT_ACCESS_PERMISSION },
|
||||
},
|
||||
{
|
||||
path: 'contract-payment/weekly-batches',
|
||||
name: 'workspace-contract-payment-weekly-batches',
|
||||
component: () => import('@/features/contract-payment/views/ContractPaymentWeeklyBatchesPage.vue'),
|
||||
meta: { title: 'workspace.nav.contractPaymentWeeklyBatches', requiresFeaturePermission: CONTRACT_PAYMENT_ACCESS_PERMISSION },
|
||||
},
|
||||
{
|
||||
path: 'contract-payment/contracts/:contractId',
|
||||
name: 'workspace-contract-payment-detail',
|
||||
component: () => import('@/features/contract-payment/views/ContractPaymentDetailPage.vue'),
|
||||
meta: { title: 'workspace.nav.contractPayment', requiresFeaturePermission: CONTRACT_PAYMENT_ACCESS_PERMISSION },
|
||||
},
|
||||
{
|
||||
path: 'feedback',
|
||||
name: 'workspace-feedback',
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* app/router/vue-router.d.ts
|
||||
* 用途:扩展 vue-router RouteMeta,供工作台功能权限与管理员门闩使用。
|
||||
* 依赖:vue-router。
|
||||
* 逻辑:必须带 export {} 做成模块增强,避免覆盖 vue-router 的完整类型导出。
|
||||
*/
|
||||
export {};
|
||||
|
||||
declare module 'vue-router' {
|
||||
interface RouteMeta {
|
||||
requiresAdmin?: boolean;
|
||||
requiresFeaturePermission?: string;
|
||||
title?: string;
|
||||
workspaceFocus?: string;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user