fix: stabilize review detail and collabora loading

This commit is contained in:
wren
2026-05-08 10:59:04 +08:00
parent 7fdb7386ee
commit 3da2a8d088
20 changed files with 319 additions and 284 deletions
+17 -17
View File
@@ -1,14 +1,21 @@
/**
* GET /api/v3/dify/chat-apps/default - 获取默认对话应用
*
* 转发请求到后端 API,后端从配置文件读取默认对话应用
* 参考文档:docs/new-dify/dify_api_doc.md - 对话应用多实例支持
*/
import { LoaderFunctionArgs, json } from '@remix-run/node';
import { API_BASE_URL } from '~/config/api-config';
import { getUserSession } from '~/api/login/auth.server';
function normalizeApp(payload: any) {
const app = payload?.data?.data || payload?.data || null;
if (!app) return null;
return {
app_id: String(app.appId),
app_name: app.appName,
description: app.description || '',
is_default: Boolean(app.isDefault),
type: 'rag',
created_at: '',
updated_at: '',
};
}
export async function loader({ request }: LoaderFunctionArgs) {
try {
const { frontendJWT } = await getUserSession(request);
@@ -20,23 +27,16 @@ export async function loader({ request }: LoaderFunctionArgs) {
);
}
console.log('[API] Get Default Chat App - Forwarding to backend');
// 转发请求到后端
const apiUrl = `${API_BASE_URL}/v3/dify/chat-apps/default`;
const response = await fetch(apiUrl, {
const response = await fetch(`${API_BASE_URL}/v3/rag/apps/default`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${frontendJWT}`,
Authorization: `Bearer ${frontendJWT}`,
},
});
const data = await response.json();
console.log('[API] Get Default Chat App - Backend response:', data);
return json(data, { status: response.status });
return json({ data: normalizeApp(data) }, { status: response.status });
} catch (error: any) {
console.error('[API] Get Default Chat App - Error:', error.message);
return json(