mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-01 03:48:24 +00:00
Feat: App folder and permission (#1726)
* app folder * feat: app foldere * fix: run app param error * perf: select app ux * perf: folder rerender * fix: ts * fix: parentId * fix: permission * perf: loading ux * perf: per select ux * perf: clb context * perf: query extension tip * fix: ts * perf: app detail per * perf: default per
This commit is contained in:
@@ -143,7 +143,7 @@ function request(
|
||||
): any {
|
||||
/* 去空 */
|
||||
for (const key in data) {
|
||||
if (data[key] === null || data[key] === undefined) {
|
||||
if (data[key] === undefined) {
|
||||
delete data[key];
|
||||
}
|
||||
}
|
||||
|
@@ -1,28 +1,25 @@
|
||||
import { GET, POST, DELETE, PUT } from '@/web/common/api/request';
|
||||
import type {
|
||||
AppDetailType,
|
||||
AppListItemType,
|
||||
ChatInputGuideConfigType
|
||||
} from '@fastgpt/global/core/app/type.d';
|
||||
import type { AppDetailType, AppListItemType } from '@fastgpt/global/core/app/type.d';
|
||||
import type { GetAppChatLogsParams } from '@/global/core/api/appReq.d';
|
||||
import { AppUpdateParams, CreateAppParams } from '@/global/core/app/api';
|
||||
import { PaginationProps, PaginationResponse } from '@fastgpt/web/common/fetch/type';
|
||||
import { AppUpdateParams } from '@/global/core/app/api';
|
||||
import type { CreateAppBody } from '@/pages/api/core/app/create';
|
||||
import type { ListAppBody } from '@/pages/api/core/app/list';
|
||||
|
||||
/**
|
||||
* 获取模型列表
|
||||
*/
|
||||
export const getMyApps = () => GET<AppListItemType[]>('/core/app/list');
|
||||
export const getMyApps = (data?: ListAppBody) => POST<AppListItemType[]>('/core/app/list', data);
|
||||
|
||||
/**
|
||||
* 创建一个模型
|
||||
*/
|
||||
export const postCreateApp = (data: CreateAppParams) => POST<string>('/core/app/create', data);
|
||||
export const postCreateApp = (data: CreateAppBody) => POST<string>('/core/app/create', data);
|
||||
|
||||
export const getMyAppsByTags = (data: {}) => POST(`/proApi/core/chat/team/getApps`, data);
|
||||
/**
|
||||
* 根据 ID 删除模型
|
||||
*/
|
||||
export const delModelById = (id: string) => DELETE(`/core/app/del?appId=${id}`);
|
||||
export const delAppById = (id: string) => DELETE(`/core/app/del?appId=${id}`);
|
||||
|
||||
/**
|
||||
* 根据 ID 获取模型
|
||||
|
11
projects/app/src/web/core/app/api/app.ts
Normal file
11
projects/app/src/web/core/app/api/app.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { DELETE, GET, POST } from '@/web/common/api/request';
|
||||
import type { CreateAppFolderBody } from '@/pages/api/core/app/folder/create';
|
||||
import { ParentTreePathItemType } from '@fastgpt/global/common/parentFolder/type';
|
||||
import { ParentIdType } from '@fastgpt/global/common/parentFolder/type';
|
||||
|
||||
/* folder */
|
||||
export const postCreateAppFolder = (data: CreateAppFolderBody) =>
|
||||
POST('/core/app/folder/create', data);
|
||||
|
||||
export const getAppFolderPath = (parentId: ParentIdType) =>
|
||||
GET<ParentTreePathItemType[]>(`/core/app/folder/path`, { parentId });
|
@@ -1,3 +1,4 @@
|
||||
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
|
||||
import { AppDetailType } from '@fastgpt/global/core/app/type.d';
|
||||
import type { FeishuType, OutLinkEditType } from '@fastgpt/global/support/outLink/type.d';
|
||||
import { AppPermission } from '@fastgpt/global/support/permission/app/controller';
|
||||
@@ -6,7 +7,7 @@ import { NullPermission } from '@fastgpt/global/support/permission/constant';
|
||||
export const defaultApp: AppDetailType = {
|
||||
_id: '',
|
||||
name: '应用加载中',
|
||||
type: 'simple',
|
||||
type: AppTypeEnum.simple,
|
||||
avatar: '/icon/logo.svg',
|
||||
intro: '',
|
||||
updateTime: Date.now(),
|
||||
|
@@ -1,31 +1,25 @@
|
||||
import { create } from 'zustand';
|
||||
import { devtools, persist } from 'zustand/middleware';
|
||||
import { devtools } from 'zustand/middleware';
|
||||
import { immer } from 'zustand/middleware/immer';
|
||||
import { getMyApps } from '@/web/core/app/api';
|
||||
import { AppListItemType } from '@fastgpt/global/core/app/type';
|
||||
|
||||
export type State = {
|
||||
myApps: AppListItemType[];
|
||||
loadMyApps: () => Promise<AppListItemType[]>;
|
||||
loadMyApps: (...arg: Parameters<typeof getMyApps>) => Promise<AppListItemType[]>;
|
||||
};
|
||||
|
||||
export const useAppStore = create<State>()(
|
||||
devtools(
|
||||
persist(
|
||||
immer((set, get) => ({
|
||||
myApps: [],
|
||||
async loadMyApps() {
|
||||
const res = await getMyApps();
|
||||
set((state) => {
|
||||
state.myApps = res;
|
||||
});
|
||||
return res;
|
||||
}
|
||||
})),
|
||||
{
|
||||
name: 'appStore',
|
||||
partialize: (state) => ({})
|
||||
immer((set, get) => ({
|
||||
myApps: [],
|
||||
async loadMyApps(data) {
|
||||
const res = await getMyApps(data);
|
||||
set((state) => {
|
||||
state.myApps = res;
|
||||
});
|
||||
return res;
|
||||
}
|
||||
)
|
||||
}))
|
||||
)
|
||||
);
|
||||
|
@@ -11,7 +11,7 @@ import {
|
||||
export const appTemplates: (AppItemType & {
|
||||
avatar: string;
|
||||
intro: string;
|
||||
type: `${AppTypeEnum}`;
|
||||
type: AppTypeEnum;
|
||||
})[] = [
|
||||
{
|
||||
id: 'simpleChat',
|
||||
|
@@ -15,7 +15,7 @@ export type SearchTestStoreItemType = {
|
||||
limit: number;
|
||||
usingReRank: boolean;
|
||||
similarity: number;
|
||||
usingQueryExtension: boolean;
|
||||
queryExtensionModel?: string;
|
||||
};
|
||||
|
||||
type State = {
|
||||
|
Reference in New Issue
Block a user