Skip to content

Commit a03bfdb

Browse files
committed
feat:fastgpt
1 parent e505f17 commit a03bfdb

18 files changed

Lines changed: 1503 additions & 780 deletions

File tree

build/server

34.5 KB
Binary file not shown.

config/vars.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type GlobalConfig struct {
2222

2323
type FastGPT struct {
2424
BaseURL string `yaml:"BaseURL"`
25+
APIKey string `yaml:"APIKey"` // 默认 API Key(用于非聊天功能)
2526
}
2627

2728
type OAuth struct {

frontend/src/api/fastgpt.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import axios from 'axios';
2+
import { BASE_URL } from './config';
3+
4+
const getAuthHeader = (token) => ({ Authorization: `Bearer ${token}` });
5+
6+
export const getAppList = (token, page = 1, pageSize = 10) => {
7+
return axios.post(`${BASE_URL}/fastgpt/apps/list`, {
8+
page,
9+
pageSize
10+
}, {
11+
headers: getAuthHeader(token)
12+
});
13+
};
14+
15+
export const createApp = (token, data) => {
16+
return axios.post(`${BASE_URL}/fastgpt/apps/create`, data, {
17+
headers: getAuthHeader(token)
18+
});
19+
};
20+
21+
export const updateApp = (token, data) => {
22+
return axios.post(`${BASE_URL}/fastgpt/apps/update`, data, {
23+
headers: getAuthHeader(token)
24+
});
25+
};
26+
27+
export const deleteApp = (token, id) => {
28+
return axios.post(`${BASE_URL}/fastgpt/apps/delete`, { id }, {
29+
headers: getAuthHeader(token)
30+
});
31+
};

frontend/src/api/index.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,57 @@ export const updateUserSubject = (data, token) =>
238238
headers: { Authorization: `Bearer ${token}` },
239239
});
240240

241+
// ============ FastGPT App 管理 API ============
242+
243+
/**
244+
* 获取 FastGPT 应用列表
245+
* @param {string} token - 管理员 token
246+
* @param {number} page
247+
* @param {number} pageSize
248+
* @returns {Promise}
249+
*/
250+
export const getFastgptAppList = (token, page = 1, pageSize = 10) => {
251+
return axios.post(`${BASE_URL}/fastgpt/apps/list`, {
252+
page,
253+
pageSize
254+
}, {
255+
headers: { Authorization: `Bearer ${token}` }
256+
});
257+
};
258+
259+
/**
260+
* 创建 FastGPT 应用
261+
* @param {Object} data - { appId, appName, apiKey, description }
262+
* @param {string} token
263+
* @returns {Promise}
264+
*/
265+
export const createFastgptApp = (data, token) => {
266+
return axios.post(`${BASE_URL}/fastgpt/apps/create`, data, {
267+
headers: { Authorization: `Bearer ${token}` }
268+
});
269+
};
270+
271+
/**
272+
* 更新 FastGPT 应用
273+
* @param {Object} data - { id, appName, apiKey, description, status }
274+
* @param {string} token
275+
* @returns {Promise}
276+
*/
277+
export const updateFastgptApp = (data, token) => {
278+
return axios.post(`${BASE_URL}/fastgpt/apps/update`, data, {
279+
headers: { Authorization: `Bearer ${token}` }
280+
});
281+
};
282+
283+
/**
284+
* 删除 FastGPT 应用
285+
* @param {number} id
286+
* @param {string} token
287+
* @returns {Promise}
288+
*/
289+
export const deleteFastgptApp = (id, token) => {
290+
return axios.post(`${BASE_URL}/fastgpt/apps/delete`, { id }, {
291+
headers: { Authorization: `Bearer ${token}` }
292+
});
293+
};
294+

0 commit comments

Comments
 (0)