feat: 将工作流分享改为独立页面
- 新增无后台布局的工作流分享与失效路由 - 同步分享地址并保留旧链接兼容 - 补充前后端分享链路测试
This commit is contained in:
@@ -18,7 +18,7 @@ interface WorkflowShareHeaderOptions {
|
||||
requestUrl?: string;
|
||||
}
|
||||
|
||||
const WORKFLOW_DESIGN_ROUTE = '/ai/workflow/design';
|
||||
const WORKFLOW_SHARE_ROUTES = ['/share/workflow', '/ai/workflow/design'];
|
||||
const WORKFLOW_SHARE_REQUESTS = [
|
||||
['GET', '/api/v1/workflow/detail'],
|
||||
['GET', '/api/v1/workflow/getRunningParameters'],
|
||||
@@ -37,7 +37,42 @@ const WORKFLOW_SHARE_REQUESTS = [
|
||||
* 从页面地址读取工作流分享密钥,兼容 history 与 hash 路由。
|
||||
*/
|
||||
export function readWorkflowShareKey(url?: string): null | string {
|
||||
return readScopedRouteQueryParam(WORKFLOW_DESIGN_ROUTE, 'shareKey', url);
|
||||
for (const routePath of WORKFLOW_SHARE_ROUTES) {
|
||||
const shareKey = readScopedRouteQueryParam(routePath, 'shareKey', url);
|
||||
if (shareKey) {
|
||||
return shareKey;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将分享解析失败映射为失效页展示原因。
|
||||
*/
|
||||
export function resolveWorkflowShareFailureReason(
|
||||
error: unknown,
|
||||
): 'expired' | 'invalid' {
|
||||
const candidate = error as
|
||||
| undefined
|
||||
| {
|
||||
message?: unknown;
|
||||
response?: {
|
||||
data?: {
|
||||
error?: unknown;
|
||||
message?: unknown;
|
||||
};
|
||||
};
|
||||
};
|
||||
const message = [
|
||||
candidate?.response?.data?.message,
|
||||
candidate?.response?.data?.error,
|
||||
candidate?.message,
|
||||
]
|
||||
.map((value) => String(value || '').trim())
|
||||
.find(Boolean);
|
||||
return message && (message.includes('过期') || /expired/i.test(message))
|
||||
? 'expired'
|
||||
: 'invalid';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user