fix: 修复分享链接路由与登录回跳

- 统一生成包含部署基路径和 Hash 路由的知识库、工作流分享地址

- 未登录访问分享页时保留目标地址,并在登录成功后自动回跳

- 限定分享密钥作用域并补充失效、加载失败及回归测试
This commit is contained in:
2026-07-24 16:00:57 +08:00
parent 41545fcef0
commit 526e16163b
15 changed files with 465 additions and 71 deletions

View File

@@ -14,7 +14,7 @@ import {getOptions, sortNodes} from '@easyflow/utils';
import {Tinyflow} from '@tinyflow-ai/vue';
import {ArrowLeft, CircleCheck, Close, Promotion,} from '@element-plus/icons-vue';
import {ElButton, ElDrawer, ElMessage, ElSkeleton,} from 'element-plus';
import {ElButton, ElDrawer, ElMessage, ElResult, ElSkeleton,} from 'element-plus';
import {api} from '#/api/request';
import CommonSelectDataModal from '#/components/commonSelectModal/CommonSelectDataModal.vue';
@@ -54,18 +54,7 @@ const { isDark } = usePreferences();
// vue
onMounted(async () => {
document.addEventListener('keydown', handleKeydown);
await resolveSharedWorkflowId();
if (!workflowId.value) {
return;
}
await Promise.all([
loadCustomNode(),
getLlmList(),
getKnowledgeList(),
getCodeEngineList(),
getWorkflowInfo(workflowId.value),
]);
showTinyFlow.value = true;
await initializeWorkflow();
});
onBeforeUnmount(() => {
captureCurrentWorkflowDraft();
@@ -83,6 +72,7 @@ onDeactivated(() => {
const tinyflowRef = ref<InstanceType<typeof Tinyflow> | null>(null);
const workflowId = ref(route.query.id);
const workflowInfo = ref<any>({});
const initializationError = ref(false);
const runParams = ref<any>(null);
const tinyFlowData = ref<any>(null);
const llmList = ref<any>([]);
@@ -109,6 +99,32 @@ async function resolveSharedWorkflowId() {
},
});
}
async function initializeWorkflow() {
initializationError.value = false;
showTinyFlow.value = false;
try {
await resolveSharedWorkflowId();
if (!workflowId.value) {
return;
}
await Promise.all([
loadCustomNode(),
getLlmList(),
getKnowledgeList(),
getCodeEngineList(),
getWorkflowInfo(workflowId.value),
]);
showTinyFlow.value = true;
} catch (error) {
console.error('Workflow initialization failed:', error);
initializationError.value = true;
}
}
function backToWorkflowList() {
router.replace({ path: '/ai/workflow' });
}
const WORKFLOW_DRAFT_WRITE_DELAY = 320;
let draftWriteTimer: ReturnType<typeof setTimeout> | undefined;
let pendingDraftContent: any = null;
@@ -870,9 +886,24 @@ function onAsyncExecute(info: any) {
</ElButton>
</div>
</div>
<ElResult
v-if="initializationError"
icon="error"
:title="$t('aiWorkflow.loadFailed')"
class="load-div"
>
<template #extra>
<ElButton @click="backToWorkflowList">
{{ $t('button.back') }}
</ElButton>
<ElButton type="primary" @click="initializeWorkflow">
{{ $t('aiWorkflow.reload') }}
</ElButton>
</template>
</ElResult>
<Tinyflow
ref="tinyflowRef"
v-if="showTinyFlow"
v-else-if="showTinyFlow"
class="tiny-flow-container"
:data="JSON.parse(JSON.stringify(tinyFlowData))"
:theme="isDark ? 'dark' : 'light'"
@@ -941,7 +972,12 @@ function onAsyncExecute(info: any) {
</div>
</div>
</transition>
<ElSkeleton v-if="!showTinyFlow" class="load-div" :rows="5" animated />
<ElSkeleton
v-if="!showTinyFlow && !initializationError"
class="load-div"
:rows="5"
animated
/>
</div>
</template>