fix: stabilize review detail and collabora loading
This commit is contained in:
@@ -1,14 +1,27 @@
|
||||
/**
|
||||
* GET /api/v3/dify/chat-apps/my - 获取当前用户可访问的对话应用列表
|
||||
*
|
||||
* 转发请求到后端 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 normalizeApps(payload: any) {
|
||||
const apps = payload?.data?.data || payload?.data || [];
|
||||
return {
|
||||
data: Array.isArray(apps)
|
||||
? apps.map((app: any) => ({
|
||||
app_id: String(app.appId),
|
||||
app_name: app.appName,
|
||||
description: app.description || '',
|
||||
is_default: Boolean(app.isDefault),
|
||||
type: 'rag',
|
||||
created_at: '',
|
||||
updated_at: '',
|
||||
}))
|
||||
: [],
|
||||
total: Array.isArray(apps) ? apps.length : 0,
|
||||
page: 1,
|
||||
page_size: Array.isArray(apps) ? apps.length : 0,
|
||||
};
|
||||
}
|
||||
|
||||
export async function loader({ request }: LoaderFunctionArgs) {
|
||||
try {
|
||||
const { frontendJWT } = await getUserSession(request);
|
||||
@@ -20,24 +33,17 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
||||
);
|
||||
}
|
||||
|
||||
console.log('[API] Get My Chat Apps - Forwarding to backend');
|
||||
|
||||
// 转发请求到后端 - 使用正确的接口路径
|
||||
// 根据文档:GET /api/v3/dify/chat-apps
|
||||
const apiUrl = `${API_BASE_URL}/v3/dify/chat-apps`;
|
||||
const response = await fetch(apiUrl, {
|
||||
const response = await fetch(`${API_BASE_URL}/v3/rag/apps`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${frontendJWT}`,
|
||||
Authorization: `Bearer ${frontendJWT}`,
|
||||
},
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
console.log('[API] Get My Chat Apps - Backend response:', data);
|
||||
|
||||
return json(data, { status: response.status });
|
||||
|
||||
const normalized = normalizeApps(data);
|
||||
return json(normalized, { status: response.status });
|
||||
} catch (error: any) {
|
||||
console.error('[API] Get My Chat Apps - Error:', error.message);
|
||||
return json(
|
||||
|
||||
Reference in New Issue
Block a user