fix(knowledge): make protected file downloads WebView-safe
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user