fix(knowledge): make protected file downloads WebView-safe

This commit is contained in:
2026-07-24 13:31:30 +08:00
parent 83c497c5f1
commit 442ba66848
9 changed files with 233 additions and 20 deletions
+11
View File
@@ -167,6 +167,17 @@ export const queryKnowledgeTool = async (
return normalizeUnifiedResponse(response);
};
export const requestKnowledgeResourceDownloadLink = async (attachmentId: number) => {
const response = await apiRequest<{ url: string }>({
url: `/api/knowledge/resources/${encodeURIComponent(String(attachmentId))}/download-link`,
method: 'POST'
});
if (!response.url?.startsWith('/api/knowledge/resources/')) {
throw new Error('资料下载链接无效');
}
return apiUrl(response.url);
};
const normalizeUnifiedResponse = (response: UnifiedKnowledgeResponse): KnowledgeSearchResponse => {
const legacy = response.legacy || ({} as KnowledgeSearchResponse);
const citationSnippets = (response.citations || []).map((item) => normalizeSnippet({