fix(auth): 企微提醒卡片深链登录后回跳原目标
- 新增 shared/utils/redirect.ts 安全回跳校验(防开放重定向) - 路由守卫未登录跳转携带 redirect 完整深链,已登录访问登录页优先回跳 - 登录成功统一按 redirect 深链落地,支持企微卡片点击直达精益培训模块
This commit is contained in:
1 parent
f1beb6fefb
commit
1034435355
15 files changed
+656
-38
No files matched your search
@@ -2,7 +2,8 @@
|
||||
* app/router/guards.ts
|
||||
* 全局路由守卫:认证、权限、旧 URL 兼容、document.title。
|
||||
* 依赖:vue-router、config、auth.store、i18n、adminModulePath、isPublicPath、useMessage、contract-payment 权限常量。
|
||||
* 逻辑:beforeEach 做登录/管理员/功能权限校验;afterEach 将 meta.title(i18n key 或字面量)解析为浏览器标题。
|
||||
* 逻辑:beforeEach 做登录/管理员/功能权限校验,未登录跳登录页时携带 redirect 深链参数(登录后原样回跳);
|
||||
* afterEach 将 meta.title(i18n key 或字面量)解析为浏览器标题。
|
||||
*/
|
||||
import type { Router } from 'vue-router';
|
||||
import { config } from '@/config';
|
||||
@@ -11,6 +12,7 @@ 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 i18n from '@/i18n';
|
||||
|
||||
/**
|
||||
@@ -57,7 +59,7 @@ function setupChunkLoadRecovery(router: Router): void {
|
||||
}
|
||||
|
||||
/**
|
||||
注册全局 beforeEach / afterEach:登录、管理员、功能权限与页面标题。
|
||||
* 注册全局 beforeEach / afterEach:登录、管理员、功能权限与页面标题。
|
||||
* 核心逻辑:requiresAdmin 仍静默回应用管理;requiresFeaturePermission 会提示后再跳转,避免用户以为入口损坏。
|
||||
* @param router - 应用根路由实例
|
||||
*/
|
||||
@@ -79,12 +81,15 @@ export function setupRouterGuards(router: Router): void {
|
||||
}
|
||||
|
||||
if (to.path === '/login' && auth.isLoggedIn) {
|
||||
next('/workspace/applications');
|
||||
// 已登录访问登录页:优先回跳 redirect 深链(如企微卡片点入),避免丢失原目标
|
||||
const redirect = resolveSafeRedirect(to.query.redirect);
|
||||
next(redirect || '/workspace/applications');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!auth.isLoggedIn && !isPublicPath(to.path)) {
|
||||
next('/login');
|
||||
// 未登录:携带完整深链(含 query)跳登录页,登录成功后原样回跳,保证企微卡片“点击直达”
|
||||
next({ path: '/login', query: { redirect: to.fullPath } });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
* features/auth/composables/useLogin.ts
|
||||
* 登录页编排层:组合认证、公告展示与 OAuth 回调,provide 给 LoginView 子组件。
|
||||
* 依赖:auth.store、linked-nav.store、useLoginAuth、useLoginLanding。
|
||||
* 逻辑:登录成功后预取关联服务侧栏入口,减少进入 Chat/工作台后的入口闪现。
|
||||
* 逻辑:登录成功后优先按守卫携带的 redirect 深链回跳(企微提醒卡片“点击直达”场景),
|
||||
* 无 redirect 时按 SSO continuation 或默认页落地;登录成功前预取关联服务侧栏入口,减少进入 Chat/工作台后的闪现。
|
||||
*/
|
||||
import { onMounted, reactive } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import type { RouteLocationRaw } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { config } from '@/config';
|
||||
import { useTheme } from '@/shared/composables/useTheme';
|
||||
@@ -16,6 +18,7 @@ import { DEFAULT_POST_LOGIN_AGENT_ID } from '@/features/workspace/types/workspac
|
||||
import { useWorkspaceLocale } from '@/features/workspace/composables/useWorkspaceLocale';
|
||||
import { continuationLocation, readSsoContinuation } from '@/features/sso';
|
||||
import { useLinkedNavStore } from '@/features/sso/stores/linked-nav.store';
|
||||
import { resolveSafeRedirect } from '@/shared/utils/redirect';
|
||||
import { useLoginAuth } from './useLoginAuth';
|
||||
import { useLoginLanding } from './useLoginLanding';
|
||||
|
||||
@@ -31,26 +34,34 @@ export function useLogin() {
|
||||
const deps = { t, locale, msg, router, route, setThemePreference, appliedTheme };
|
||||
const landing = useLoginLanding();
|
||||
|
||||
/**
|
||||
* 解析本次登录的最终落地页。
|
||||
* AI 触发时机:密码/OAuth 登录成功后、以及已登录用户访问登录页时调用。
|
||||
* 核心逻辑:优先取守卫写入的 redirect 深链(如企微精益提醒卡片 /chat/16?training_type=lean_management),
|
||||
* 保证“点卡片 → 登录 → 直达精益模块”;其次 SSO continuation;最后由调用方按登录方式给默认页。
|
||||
* redirect 已由 resolveSafeRedirect 做站内路径校验,防开放重定向(如 //evil.com)。
|
||||
* Returns:站内跳转目标(字符串路径或路由对象);无可回跳目标时返回空串。
|
||||
*/
|
||||
const resolvePostLoginLocation = (): RouteLocationRaw | '' => {
|
||||
const redirect = resolveSafeRedirect(route.query.redirect);
|
||||
if (redirect) return redirect;
|
||||
const continuation = readSsoContinuation();
|
||||
if (continuation) return continuationLocation(continuation);
|
||||
return '';
|
||||
};
|
||||
|
||||
const completePasswordLogin = async () => {
|
||||
authStore.syncFromStorage();
|
||||
void linkedNav.ensureLoaded({ force: true });
|
||||
const continuation = readSsoContinuation();
|
||||
if (continuation) {
|
||||
await router.replace(continuationLocation(continuation));
|
||||
return;
|
||||
}
|
||||
await router.replace(`/chat/${DEFAULT_POST_LOGIN_AGENT_ID}`);
|
||||
const target = resolvePostLoginLocation();
|
||||
await router.replace(target || `/chat/${DEFAULT_POST_LOGIN_AGENT_ID}`);
|
||||
};
|
||||
|
||||
const completeOAuthLogin = async () => {
|
||||
authStore.syncFromStorage();
|
||||
void linkedNav.ensureLoaded({ force: true });
|
||||
const continuation = readSsoContinuation();
|
||||
if (continuation) {
|
||||
await router.replace(continuationLocation(continuation));
|
||||
return;
|
||||
}
|
||||
await router.replace('/workspace/applications');
|
||||
const target = resolvePostLoginLocation();
|
||||
await router.replace(target || '/workspace/applications');
|
||||
};
|
||||
|
||||
const loginAuth = useLoginAuth(deps, { completePasswordLogin, completeOAuthLogin });
|
||||
@@ -75,8 +86,9 @@ export function useLogin() {
|
||||
|
||||
authStore.syncFromStorage();
|
||||
if (authStore.isLoggedIn) {
|
||||
const continuation = readSsoContinuation();
|
||||
await router.replace(continuation ? continuationLocation(continuation) : '/workspace/applications');
|
||||
// 已登录访问登录页:优先回跳 redirect 深链(如企微卡片点入),避免丢失原目标
|
||||
const target = resolvePostLoginLocation();
|
||||
await router.replace(target || '/workspace/applications');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
<!--
|
||||
features/chat/components/TrainingShareModal.vue
|
||||
用途:员工培训分享弹窗——把"当前培训模块深链 + 二维码"提供给有培训管理权限的 HR/管理员,
|
||||
供其复制链接或下载二维码后分发给员工(企微/短信/海报等渠道)。
|
||||
依赖:qrcode(前端生成二维码 dataURL)、copyTextToClipboard(shared/utils/clipboard)、useMessage。
|
||||
逻辑:由 TrainingWorkspacePanel 以 v-model:open 控制显隐;打开时按 shareUrl 生成二维码;
|
||||
接收方打开链接 → 登录 → 由面板深链逻辑自动定位到对应培训模块(见 TrainingWorkspacePanel.vue)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import QRCode from 'qrcode';
|
||||
import { Copy, Download, Share2, XCircle } from 'lucide-vue-next';
|
||||
import { copyTextToClipboard } from '@/shared/utils/clipboard';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
/** 分享深链:/chat/<agentId>?training_type=<code>,由调用方拼好完整绝对地址。 */
|
||||
shareUrl: string;
|
||||
/** 当前分享的培训模块名称,仅用于弹窗内文案展示。 */
|
||||
trainingName: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:open': [open: boolean];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
|
||||
const qrDataUrl = ref('');
|
||||
const qrGenerating = ref(false);
|
||||
|
||||
watch(
|
||||
() => [props.open, props.shareUrl] as const,
|
||||
async ([open, url]) => {
|
||||
if (!open || !url) return;
|
||||
qrGenerating.value = true;
|
||||
try {
|
||||
// 纠错级别 H:二维码可能被打印后裁剪/污损,取最高冗余保证扫码成功率。
|
||||
qrDataUrl.value = await QRCode.toDataURL(url, { width: 240, margin: 2, errorCorrectionLevel: 'H' });
|
||||
} catch {
|
||||
qrDataUrl.value = '';
|
||||
} finally {
|
||||
qrGenerating.value = false;
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
const closeModal = () => emit('update:open', false);
|
||||
|
||||
/**
|
||||
* 复制培训深链到剪贴板(兼容企微 WebView 等 clipboard API 受限环境)。
|
||||
* AI 触发时机:HR 在分享弹窗点击“复制链接”时调用;结果必须用 useMessage 明确反馈成败。
|
||||
*/
|
||||
const copyShareLink = async () => {
|
||||
const ok = await copyTextToClipboard(props.shareUrl);
|
||||
if (ok) {
|
||||
msg.success(t('chat.training.share.copied'));
|
||||
} else {
|
||||
msg.error(t('chat.training.share.copyFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 把当前二维码下载为 PNG 图片,供 HR 插入海报/群公告等离线场景。
|
||||
* AI 触发时机:HR 在分享弹窗点击“下载二维码”时调用;二维码未生成完成时禁止下载。
|
||||
*/
|
||||
const downloadQrCode = () => {
|
||||
if (!qrDataUrl.value) return;
|
||||
const link = document.createElement('a');
|
||||
link.href = qrDataUrl.value;
|
||||
link.download = `training-share-qr-${Date.now()}.png`;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-[100] flex items-center justify-center bg-slate-950/80 p-4 backdrop-blur-sm"
|
||||
@click.self="closeModal"
|
||||
>
|
||||
<div class="relative w-full max-w-md overflow-hidden rounded-3xl bg-white shadow-2xl">
|
||||
<div class="flex items-center justify-between border-b border-default px-6 py-4">
|
||||
<h3 class="flex items-center gap-2 text-lg font-semibold text-primary">
|
||||
<Share2 class="h-5 w-5 text-brand-600" />
|
||||
{{ $t('chat.training.share.title') }}
|
||||
</h3>
|
||||
<button
|
||||
type="button"
|
||||
class="flex h-8 w-8 items-center justify-center rounded-full bg-surface-soft text-secondary transition hover:bg-surface hover:text-primary"
|
||||
:aria-label="$t('chat.training.share.close')"
|
||||
@click="closeModal"
|
||||
>
|
||||
<XCircle class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-4 px-6 py-5">
|
||||
<p class="text-sm leading-6 text-secondary">
|
||||
{{ $t('chat.training.share.description', { name: trainingName }) }}
|
||||
</p>
|
||||
|
||||
<!-- 培训链接:只读展示 + 一键复制,避免长链接被截断导致复制不全。 -->
|
||||
<div>
|
||||
<div class="text-xs font-medium text-secondary">{{ $t('chat.training.share.linkLabel') }}</div>
|
||||
<div class="mt-1.5 flex items-center gap-2">
|
||||
<input
|
||||
type="text"
|
||||
readonly
|
||||
:value="shareUrl"
|
||||
class="input-field h-9 min-w-0 flex-1 truncate text-xs"
|
||||
@focus="($event.target as HTMLInputElement).select()"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex h-9 shrink-0 items-center gap-1.5 rounded-xl bg-brand-600 px-3.5 text-xs font-medium text-white transition hover:bg-brand-700"
|
||||
@click="copyShareLink"
|
||||
>
|
||||
<Copy class="h-4 w-4" />
|
||||
{{ $t('chat.training.share.copyLink') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 培训二维码:扫码与链接等价,未登录用户扫码后先登录再自动直达对应模块。 -->
|
||||
<div>
|
||||
<div class="text-xs font-medium text-secondary">{{ $t('chat.training.share.qrLabel') }}</div>
|
||||
<div class="mt-1.5 flex items-center gap-4">
|
||||
<div class="flex h-40 w-40 shrink-0 items-center justify-center rounded-2xl border border-default bg-surface-soft">
|
||||
<img
|
||||
v-if="qrDataUrl"
|
||||
:src="qrDataUrl"
|
||||
:alt="$t('chat.training.share.qrLabel')"
|
||||
class="h-36 w-36"
|
||||
/>
|
||||
<span v-else class="text-xs text-secondary">{{ qrGenerating ? '...' : '--' }}</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex h-9 items-center gap-1.5 rounded-xl border border-default bg-white px-3.5 text-xs font-medium text-secondary transition hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="!qrDataUrl"
|
||||
@click="downloadQrCode"
|
||||
>
|
||||
<Download class="h-4 w-4" />
|
||||
{{ $t('chat.training.share.downloadQr') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
FileText,
|
||||
PlayCircle,
|
||||
RefreshCcw,
|
||||
Share2,
|
||||
ShieldCheck,
|
||||
Target,
|
||||
User,
|
||||
@@ -30,6 +31,7 @@ import {
|
||||
} from 'lucide-vue-next';
|
||||
import { useTrainingWorkspace } from '@/features/chat/composables/useTrainingWorkspace';
|
||||
import FilePreviewModal from '@/shared/components/FilePreviewModal.vue';
|
||||
import TrainingShareModal from './TrainingShareModal.vue';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { resolveTrainingExamPdfGuide, type TrainingGuideLike } from '@/features/chat/training/trainingWorkspace.utils';
|
||||
import { getMyTrainingConfig } from '@/features/chat/api/training.api';
|
||||
@@ -293,33 +295,52 @@ const openWorkspaceView = (view: typeof workspace.activeView) => {
|
||||
setWorkspaceExpanded(true, true);
|
||||
};
|
||||
|
||||
// [STEP] 企微提醒卡片深链支持:/chat/<agentId>?training_type=lean_management&weekly_task_id=<id>
|
||||
// AI 触发时机:员工/HR 从企微“和信AI智能工作台”精益提醒卡片点入时,自动展开精益培训对应页签
|
||||
// (管理员进管理端看板、学员进学员侧学习页),无需手动点页签,保证卡片“点击直达”体验。
|
||||
// [STEP] 培训深链支持:/chat/<agentId>?training_type=<培训类型code>
|
||||
// 来源 1:企微“和信AI智能工作台”精益提醒卡片(training_type=lean_management&weekly_task_id=<id>)
|
||||
// 来源 2:员工培训分享链接(HR 在分享弹窗复制/生成二维码,员工扫码或点击后进入)
|
||||
// AI 触发时机:员工/HR 从企微卡片或分享链接点入时,自动展开并定位到对应培训模块,
|
||||
// 无需手动点页签,保证“点击直达”体验;精益卡片的管理员仍直达管理端精益看板。
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
let leanJumpConsumed = false;
|
||||
let trainingDeepLinkConsumed = false;
|
||||
watch(
|
||||
() => [workspace.isTrainingAgent, Boolean(props.currentUser), workspace.canManageTrainingWorkspace] as const,
|
||||
([isTraining, loggedIn]) => {
|
||||
// 仅在培训 Agent 且登录态就绪后消费一次,避免身份权限异步未加载时误判视图归属
|
||||
if (!isTraining || !loggedIn || leanJumpConsumed) return;
|
||||
leanJumpConsumed = true;
|
||||
if (route.query.training_type !== 'lean_management') return;
|
||||
if (workspace.canManageTrainingWorkspace) {
|
||||
if (!isTraining || !loggedIn || trainingDeepLinkConsumed) return;
|
||||
const targetTrainingType = String(route.query.training_type || '').trim();
|
||||
if (!targetTrainingType) return;
|
||||
trainingDeepLinkConsumed = true;
|
||||
if (targetTrainingType === 'lean_management' && workspace.canManageTrainingWorkspace) {
|
||||
// 兼容企微精益提醒卡片:管理员直达管理端精益看板,学员进学员侧精益学习页。
|
||||
workspace.activeView = 'admin';
|
||||
workspace.hrTrainingTab = 'lean';
|
||||
} else {
|
||||
// 分享链接与其余培训类型:统一进员工培训页并定位到目标模块
|
||||
//(learnerTab 直接赋值即可,loadTrainingTypes 拉取后若类型有效会保留)。
|
||||
workspace.activeView = 'learner';
|
||||
workspace.learnerTab = 'lean_management';
|
||||
workspace.learnerTab = targetTrainingType;
|
||||
}
|
||||
setWorkspaceExpanded(true, true);
|
||||
// 消费后清理深链参数,避免刷新或分享链接时重复自动展开
|
||||
// 消费后清理深链参数,避免刷新或二次分享时重复自动展开
|
||||
void router.replace({ query: { ...route.query, training_type: undefined, weekly_task_id: undefined } });
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
/**
|
||||
* 组装当前培训模块的分享深链(绝对地址),供分享弹窗展示链接与生成二维码。
|
||||
* AI 触发时机:有培训管理权限的用户点击“分享”时使用;必须带上 training_type 参数,
|
||||
* 接收方登录后会自动定位到当前正在查看的培训模块。
|
||||
*/
|
||||
const shareModalOpen = ref(false);
|
||||
const trainingShareUrl = computed(() => {
|
||||
const agentId = workspace.currentTrainingAgentId;
|
||||
if (!agentId) return '';
|
||||
return `${window.location.origin}/chat/${agentId}?training_type=${encodeURIComponent(workspace.learnerTab)}`;
|
||||
});
|
||||
const trainingShareName = computed(() => workspace.resolveTrainingTypeName(workspace.learnerTab));
|
||||
|
||||
/**
|
||||
* 收起培训工作区并回到纯聊天页面。
|
||||
* AI 触发时机:点击“收起工作区”时,必须立即恢复聊天消息区与输入栏,而不是仅折叠局部内容。
|
||||
@@ -811,7 +832,7 @@ const currentSafetyStageText = computed(() => {
|
||||
|
||||
<div v-if="!isCompactMode && workspace.activeView === 'learner'" :class="learnerWorkspaceGridClass">
|
||||
<!-- 已发布培训类型由后端配置动态提供。 -->
|
||||
<div class="col-span-full mb-1">
|
||||
<div class="col-span-full mb-1 flex flex-wrap items-center justify-between gap-2">
|
||||
<div class="inline-flex flex-wrap rounded-xl border border-default bg-surface-soft p-1">
|
||||
<button
|
||||
v-for="trainingType in workspace.trainingTypes"
|
||||
@@ -826,6 +847,16 @@ const currentSafetyStageText = computed(() => {
|
||||
{{ trainingType.name }}
|
||||
</button>
|
||||
</div>
|
||||
<!-- [STEP 1] 分享入口:仅培训管理权限可见,分享当前培训类型深链 -->
|
||||
<button
|
||||
v-if="workspace.canManageTrainingWorkspace"
|
||||
type="button"
|
||||
class="inline-flex flex-shrink-0 items-center gap-1.5 rounded-full bg-brand-600 px-4 py-2 text-sm font-semibold text-white shadow-md transition-all hover:bg-brand-700 hover:shadow-lg active:scale-95"
|
||||
@click="shareModalOpen = true"
|
||||
>
|
||||
<Share2 class="h-4 w-4" />
|
||||
{{ $t('chat.training.share.button') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="workspace.trainingConfigLoading" class="col-span-full rounded-2xl border border-default bg-white px-6 py-16 text-center text-secondary">
|
||||
@@ -1906,6 +1937,13 @@ const currentSafetyStageText = computed(() => {
|
||||
:required-duration="workspace.currentViewingMaterialRequiredDuration"
|
||||
@update:modelValue="handlePreviewClose"
|
||||
/>
|
||||
|
||||
<!-- 员工培训分享弹窗:复制链接 / 下载二维码,接收方登录后自动定位到对应培训模块。 -->
|
||||
<TrainingShareModal
|
||||
v-model:open="shareModalOpen"
|
||||
:share-url="trainingShareUrl"
|
||||
:training-name="trainingShareName"
|
||||
/>
|
||||
|
||||
<div v-if="reportModalVisible" class="fixed inset-0 z-[100] flex items-center justify-center bg-slate-950/80 p-4 backdrop-blur-sm" @click.self="closeReport">
|
||||
<div class="relative w-full max-w-4xl max-h-[90vh] flex flex-col overflow-hidden rounded-3xl bg-white shadow-2xl">
|
||||
|
||||
@@ -25,7 +25,9 @@ const msg = useMessage();
|
||||
const downloading = ref(false);
|
||||
const downloadingAnnotated = ref(false);
|
||||
const latestReview = ref<ContractReviewRow | null>(null);
|
||||
let refreshTimer: ReturnType<typeof window.setTimeout> | undefined;
|
||||
// 浏览器端 window.setTimeout 返回 number;勿用 ReturnType<typeof window.setTimeout>,
|
||||
// 其在 @types/node 与 DOM lib 混用时会解析为 NodeJS.Timeout 导致 TS2322。
|
||||
let refreshTimer: number | undefined;
|
||||
let refreshing = false;
|
||||
let disposed = false;
|
||||
|
||||
|
||||
@@ -446,9 +446,11 @@ export function useShippingOrderReview(options: {
|
||||
const workflowProgressPolling = ref(false);
|
||||
let contextConversationId = '';
|
||||
let contextItemNo = '';
|
||||
let progressPollTimer: ReturnType<typeof window.setInterval> | null = null;
|
||||
let stpCreatePollTimer: ReturnType<typeof window.setInterval> | null = null;
|
||||
let reparseCaseRefreshTimer: ReturnType<typeof window.setInterval> | null = null;
|
||||
// 浏览器端 window.setInterval 返回 number;勿用 ReturnType<typeof window.setInterval>,
|
||||
// 其在 @types/node 与 DOM lib 混用时会解析为 NodeJS.Timeout 导致 TS2322。
|
||||
let progressPollTimer: number | null = null;
|
||||
let stpCreatePollTimer: number | null = null;
|
||||
let reparseCaseRefreshTimer: number | null = null;
|
||||
|
||||
/**
|
||||
* 应用后端返回的完整 Case 快照。
|
||||
|
||||
@@ -65,7 +65,9 @@ export function useShippingProcessingWorkItem(
|
||||
const projection = ref<ShippingProcessingProjection | null>(null);
|
||||
const loading = ref(false);
|
||||
const error = ref<string | null>(null);
|
||||
let timer: ReturnType<typeof window.setTimeout> | null = null;
|
||||
// 浏览器端 window.setTimeout 返回 number;勿用 ReturnType<typeof window.setTimeout>,
|
||||
// 其在 @types/node 与 DOM lib 混用时会解析为 NodeJS.Timeout 导致 TS2322。
|
||||
let timer: number | null = null;
|
||||
let generation = 0;
|
||||
let stopped = false;
|
||||
let refreshInFlight: { no: string; promise: Promise<void> } | null = null;
|
||||
|
||||
@@ -997,6 +997,18 @@
|
||||
"collapseWorkspace": "Collapse Workspace",
|
||||
"viewExamPdf": "View Exam PDF"
|
||||
},
|
||||
"share": {
|
||||
"button": "Share",
|
||||
"title": "Share Training",
|
||||
"description": "Copy the link or download the QR code to share with employees. After signing in, they will land directly on the \"{name}\" training module.",
|
||||
"linkLabel": "Training link",
|
||||
"qrLabel": "Training QR code",
|
||||
"copyLink": "Copy link",
|
||||
"copied": "Link copied",
|
||||
"copyFailed": "Copy failed. Please copy manually",
|
||||
"downloadQr": "Download QR code",
|
||||
"close": "Close"
|
||||
},
|
||||
"steps": {
|
||||
"video": "Watch Video",
|
||||
"summary": "Review Key Points",
|
||||
|
||||
@@ -997,6 +997,18 @@
|
||||
"collapseWorkspace": "ย่อพื้นที่ทำงาน",
|
||||
"viewExamPdf": "ดู PDF ข้อสอบ"
|
||||
},
|
||||
"share": {
|
||||
"button": "แชร์",
|
||||
"title": "แชร์การอบรม",
|
||||
"description": "คัดลอกลิงก์หรือดาวน์โหลดคิวอาร์โค้ดเพื่อแชร์ให้พนักงาน เมื่อเข้าสู่ระบบแล้วจะไปยังโมดูลการอบรม \"{name}\" โดยอัตโนมัติ",
|
||||
"linkLabel": "ลิงก์การอบรม",
|
||||
"qrLabel": "คิวอาร์โค้ดการอบรม",
|
||||
"copyLink": "คัดลอกลิงก์",
|
||||
"copied": "คัดลอกลิงก์แล้ว",
|
||||
"copyFailed": "คัดลอกไม่สำเร็จ โปรดคัดลอกด้วยตนเอง",
|
||||
"downloadQr": "ดาวน์โหลดคิวอาร์โค้ด",
|
||||
"close": "ปิด"
|
||||
},
|
||||
"steps": {
|
||||
"video": "ดูวิดีโอ",
|
||||
"summary": "ทบทวนความรู้",
|
||||
|
||||
@@ -1031,6 +1031,18 @@
|
||||
"collapseWorkspace": "收起工作区",
|
||||
"viewExamPdf": "查看试题 PDF"
|
||||
},
|
||||
"share": {
|
||||
"button": "分享",
|
||||
"title": "分享培训",
|
||||
"description": "复制链接或下载二维码发给员工,对方登录后自动进入「{name}」培训模块。",
|
||||
"linkLabel": "培训链接",
|
||||
"qrLabel": "培训二维码",
|
||||
"copyLink": "复制链接",
|
||||
"copied": "链接已复制",
|
||||
"copyFailed": "复制失败,请手动复制",
|
||||
"downloadQr": "下载二维码",
|
||||
"close": "关闭"
|
||||
},
|
||||
"steps": {
|
||||
"video": "观看视频",
|
||||
"summary": "复盘知识点",
|
||||
|
||||
@@ -997,6 +997,18 @@
|
||||
"collapseWorkspace": "收起工作區",
|
||||
"viewExamPdf": "查看試題 PDF"
|
||||
},
|
||||
"share": {
|
||||
"button": "分享",
|
||||
"title": "分享培訓",
|
||||
"description": "複製連結或下載二維碼發給員工,對方登入後自動進入「{name}」培訓模組。",
|
||||
"linkLabel": "培訓連結",
|
||||
"qrLabel": "培訓二維碼",
|
||||
"copyLink": "複製連結",
|
||||
"copied": "連結已複製",
|
||||
"copyFailed": "複製失敗,請手動複製",
|
||||
"downloadQr": "下載二維碼",
|
||||
"close": "關閉"
|
||||
},
|
||||
"steps": {
|
||||
"video": "觀看影片",
|
||||
"summary": "複盤知識點",
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* shared/utils/redirect.ts
|
||||
* 登录回跳目标解析:企微提醒卡片等深链场景下,登录页按 redirect 参数原样回跳。
|
||||
* 依赖:无。被 app/router/guards.ts(守卫放行/跳转)与 features/auth(登录成功后回跳)共用。
|
||||
*/
|
||||
|
||||
/**
|
||||
* 校验并解析登录后回跳目标(企微提醒卡片等深链场景)。
|
||||
* AI 触发时机:路由守卫拦截未登录访问时,以及密码/OAuth 登录成功后决定跳转目标时调用。
|
||||
* 核心逻辑:仅接受站内相对路径(以 / 开头且不以 // 开头),拒绝外链与协议相对地址,防开放重定向。
|
||||
* @param raw - 待校验的 redirect 参数(可能为 string | string[] | undefined)
|
||||
* @returns 安全的站内路径;不合法时返回 null
|
||||
*/
|
||||
export function resolveSafeRedirect(raw: unknown): string | null {
|
||||
const value = Array.isArray(raw) ? String(raw[0] ?? '') : String(raw ?? '');
|
||||
if (!value.startsWith('/') || value.startsWith('//')) return null;
|
||||
return value;
|
||||
}
|
||||
Reference in new issue
Block a user