Merge branch 'dev' into order-delivery-reply
# Conflicts: # .env.shared # backend/app/api/chat.py # backend/app/core/config/settings.py # backend/app/models/user.py # backend/app/services/admin/permission_service.py # docs/demand.md # frontend/src/app/router/routes/workspace.routes.ts # frontend/src/features/admin/modules/users/components/UserFormModal.vue # frontend/src/features/admin/modules/users/composables/useUsersAdmin.ts # frontend/src/features/admin/types/user.types.ts # frontend/src/features/auth/stores/auth.store.ts # frontend/src/features/user/views/UserProfilePage.vue # frontend/src/locales/en/admin.json # frontend/src/locales/en/errors.json # frontend/src/locales/th/admin.json # frontend/src/locales/th/errors.json # frontend/src/locales/zh-CN/admin.json # frontend/src/locales/zh-CN/errors.json # frontend/src/locales/zh-TW/admin.json # frontend/src/locales/zh-TW/errors.json # frontend/src/shared/utils/auth.ts
This commit is contained in:
commit
616034a4cd
541 files changed
+43805
-14767
No files matched your search
@@ -1,18 +1,19 @@
|
||||
/**
|
||||
* app/router/guards.ts
|
||||
* 全局路由守卫:认证、权限、旧 URL 兼容、document.title。
|
||||
* 依赖:vue-router、config、auth.store、i18n、adminModulePath、isPublicPath、useMessage、contract-payment 权限常量。
|
||||
* 依赖:vue-router、config、auth.store、i18n、adminModulePath、isPublicPath、useMessage、chunkLoadRecovery。
|
||||
* 逻辑:beforeEach 做登录/管理员/功能权限校验,未登录跳登录页时携带 redirect 深链参数(登录后原样回跳);
|
||||
* afterEach 将 meta.title(i18n key 或字面量)解析为浏览器标题。
|
||||
* afterEach 将 meta.title(i18n key 或字面量)解析为浏览器标题;
|
||||
* 路由懒加载 404 与 Chat defineAsyncComponent 共用一次刷新自愈。
|
||||
*/
|
||||
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 { resolveSafeRedirect } from '@/shared/utils/redirect';
|
||||
import { reloadOnceOnChunkLoadError } from '@/shared/utils/chunkLoadRecovery';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
/**
|
||||
@@ -39,22 +40,15 @@ function resolveAppBaseTitle(): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* 懒加载 chunk 失败自愈。
|
||||
* 用途/触发时机:部署后若浏览器(或网关)缓存了旧版 index.html,会引用已删除的旧 hash 产物,
|
||||
* 登录等页面跳转时动态 import() 该 chunk 失败 → 报 "Failed to fetch dynamically imported module"
|
||||
* 并被登录流程误判为“登录失败”。此处检测到该类失败时做一次整页刷新(带 sessionStorage 防循环守卫),
|
||||
* 刷新后取到最新 index.html 与 chunk,用户即可正常进入,不再看到误导性报错。
|
||||
* 核心逻辑:仅匹配 chunk 加载失败错误;同一标签页会话内只刷新一次,避免服务器持续异常时无限刷新。
|
||||
* 路由级懒加载 chunk 失败自愈。
|
||||
* 用途/触发时机:部署后旧 index.html 或旧路由分包 404。Chat 内 defineAsyncComponent 不走 router.onError,
|
||||
* 由 main.ts 的 vite:preloadError 与 defineRecoverableAsyncComponent 覆盖。
|
||||
* 核心逻辑:委托 reloadOnceOnChunkLoadError,同一标签页只刷新一次。
|
||||
* @param router - Vue Router 实例
|
||||
*/
|
||||
function setupChunkLoadRecovery(router: Router): void {
|
||||
router.onError((error) => {
|
||||
const message = String((error as Error)?.message || '');
|
||||
if (!message.includes('Failed to fetch dynamically imported module')) return;
|
||||
const recoveryKey = 'hxops_chunk_load_recovery_once';
|
||||
if (sessionStorage.getItem(recoveryKey)) return;
|
||||
sessionStorage.setItem(recoveryKey, '1');
|
||||
window.location.reload();
|
||||
reloadOnceOnChunkLoadError(error);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,9 +92,7 @@ export function setupRouterGuards(router: Router): void {
|
||||
.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';
|
||||
const messageKey = 'errors.codes.AUTH_FORBIDDEN';
|
||||
useMessage().warning(String(i18n.global.t(messageKey)));
|
||||
next('/workspace/applications');
|
||||
return;
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
/**
|
||||
* app/router/routes/workspace.routes.ts
|
||||
* 工作台路由表:/workspace 布局壳 + 各业务子页面懒加载。
|
||||
* 依赖:vue-router、contract-payment 权限常量;meta.title 存 i18n key(workspace.*),由 guards 解析为 document.title。
|
||||
* 逻辑:WorkspaceLayout 嵌套应用首页、知识库、排程、反馈等子页;合同付款子路由用 requiresFeaturePermission 而非 requiresAdmin;立账凭证明细为 accounting-voucher-check/runs/:runId。
|
||||
* 依赖:vue-router;meta.title 存 i18n key(workspace.*),由 guards 解析为 document.title。
|
||||
* 逻辑:WorkspaceLayout 嵌套应用首页、知识库、排程、反馈等子页;合同付款、立账凭证旧地址重定向到 Chat Agent。
|
||||
*/
|
||||
import type { RouteRecordRaw } from 'vue-router';
|
||||
import { CONTRACT_PAYMENT_ACCESS_PERMISSION } from '@/features/contract-payment/constants';
|
||||
import { ORDER_DELIVERY_REPLY_ACCESS_PERMISSION } from '@/features/order-delivery-reply/constants';
|
||||
|
||||
// 合同付款 / 立账凭证旧工作台地址 → 聊天 Agent 重定向壳(dev 侧重构引入)。
|
||||
const contractPaymentChatRedirect = () => import('@/features/contract-payment/views/ContractPaymentChatRedirect.vue');
|
||||
const voucherCheckChatRedirect = () => import('@/features/voucher-check/views/VoucherCheckChatRedirect.vue');
|
||||
|
||||
// 订单交期回复嵌入路由:应用管理 iframe 应用的目标(无工作台布局壳,聊天壳内整页渲染)。
|
||||
export const orderDeliveryReplyEmbedRoute: RouteRecordRaw = {
|
||||
path: '/apps/order-delivery-reply',
|
||||
@@ -73,7 +76,7 @@ export const workspaceRoutes: RouteRecordRaw[] = [
|
||||
path: 'shipping-notice/customers',
|
||||
name: 'workspace-shipping-customers',
|
||||
component: () => import('@/features/shipping-notice/customers/ShippingCustomersPage.vue'),
|
||||
meta: { title: '货代客户主数据', requiresAdmin: true },
|
||||
meta: { title: '货代客户数据', requiresAdmin: true },
|
||||
},
|
||||
{
|
||||
path: 'shipping-notice/my-tasks',
|
||||
@@ -90,14 +93,14 @@ export const workspaceRoutes: RouteRecordRaw[] = [
|
||||
{
|
||||
path: 'accounting-voucher-check',
|
||||
name: 'workspace-accounting-voucher-check',
|
||||
component: () => import('@/features/workspace/pages/AccountingVoucherCheckPage.vue'),
|
||||
meta: { title: 'workspace.nav.accountingVoucherCheck', requiresAdmin: true },
|
||||
component: voucherCheckChatRedirect,
|
||||
meta: { title: 'workspace.nav.accountingVoucherCheck' },
|
||||
},
|
||||
{
|
||||
path: 'accounting-voucher-check/runs/:runId',
|
||||
name: 'workspace-accounting-voucher-check-detail',
|
||||
component: () => import('@/features/workspace/pages/AccountingVoucherCheckDetailPage.vue'),
|
||||
meta: { title: 'workspace.voucherCheck.detailTitle', requiresAdmin: true },
|
||||
component: voucherCheckChatRedirect,
|
||||
meta: { title: 'workspace.voucherCheck.detailTitle' },
|
||||
},
|
||||
{
|
||||
path: 'order-delivery-reply',
|
||||
@@ -108,26 +111,26 @@ export const workspaceRoutes: RouteRecordRaw[] = [
|
||||
{
|
||||
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 },
|
||||
component: contractPaymentChatRedirect,
|
||||
meta: { title: 'workspace.nav.contractPayment' },
|
||||
},
|
||||
{
|
||||
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 },
|
||||
component: contractPaymentChatRedirect,
|
||||
meta: { title: 'workspace.nav.contractPaymentReview' },
|
||||
},
|
||||
{
|
||||
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 },
|
||||
component: contractPaymentChatRedirect,
|
||||
meta: { title: 'workspace.nav.contractPaymentWeeklyBatches' },
|
||||
},
|
||||
{
|
||||
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 },
|
||||
component: contractPaymentChatRedirect,
|
||||
meta: { title: 'workspace.nav.contractPayment' },
|
||||
},
|
||||
{
|
||||
path: 'feedback',
|
||||
|
||||
Reference in new issue
Block a user