fix: 修复分享链接路由与登录回跳
- 统一生成包含部署基路径和 Hash 路由的知识库、工作流分享地址 - 未登录访问分享页时保留目标地址,并在登录成功后自动回跳 - 限定分享密钥作用域并补充失效、加载失败及回归测试
This commit is contained in:
@@ -20,6 +20,7 @@ import { events } from 'fetch-event-stream';
|
||||
|
||||
import { useAuthStore } from '#/store';
|
||||
import {
|
||||
isWorkflowShareRequest,
|
||||
readWorkflowShareKey,
|
||||
withWorkflowShareHeader,
|
||||
WORKFLOW_SHARE_HEADER,
|
||||
@@ -101,7 +102,10 @@ function createRequestClient(baseURL: string, options?: RequestClientOptions) {
|
||||
config.headers['easyflow-token'] = formatToken(accessStore.accessToken);
|
||||
config.headers['Accept-Language'] = preferences.app.locale;
|
||||
const workflowShareKey = readWorkflowShareKey();
|
||||
if (workflowShareKey) {
|
||||
if (
|
||||
workflowShareKey &&
|
||||
isWorkflowShareRequest(config.url, config.method)
|
||||
) {
|
||||
config.headers[WORKFLOW_SHARE_HEADER] = workflowShareKey;
|
||||
}
|
||||
return config;
|
||||
@@ -196,7 +200,7 @@ export class SseClient {
|
||||
const res = await fetch(apiURL + url, {
|
||||
method: 'POST',
|
||||
signal, // 使用局部变量 signal
|
||||
headers: this.getHeaders(options?.headers),
|
||||
headers: this.getHeaders(url, options?.headers),
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
|
||||
@@ -265,7 +269,7 @@ export class SseClient {
|
||||
}
|
||||
}
|
||||
|
||||
private getHeaders(extraHeaders?: HeadersInit) {
|
||||
private getHeaders(requestUrl: string, extraHeaders?: HeadersInit) {
|
||||
const accessStore = useAccessStore();
|
||||
const headers: Record<string, string> = {
|
||||
Accept: 'text/event-stream',
|
||||
@@ -277,7 +281,10 @@ export class SseClient {
|
||||
headers[key] = value;
|
||||
});
|
||||
}
|
||||
return withWorkflowShareHeader(headers);
|
||||
return withWorkflowShareHeader(headers, {
|
||||
requestMethod: 'POST',
|
||||
requestUrl,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user