4.8.5 test fix (#1835)

* faq

* perf: navbar name and fix dataset selector

* feat: app tag

* perf: icon

* fix: update workflow bug

* perf: dataset ui

* perf: menu

* fix: ts

* fix: auth file and app list ui

* app list

* app list

* perf: init api

* update per

* log level
This commit is contained in:
Archer
2024-06-25 10:10:24 +08:00
committed by GitHub
parent d902d29c71
commit 5c8c7fb9f2
50 changed files with 9331 additions and 12025 deletions

View File

@@ -363,3 +363,14 @@ mongo连接失败查看mongo的运行状态**对应日志**。
### 无法导出知识库、无法使用语音输入/播报
没配置 SSL 证书,无权使用部分功能。
### 登录提示 Network Error
由于服务初始化错误,系统重启导致。
* 90%是由于配置文件写不对,导致 JSON 解析报错
* 剩下的基本是因为向量数据库连不上
### 如何修改密码
修改`docker-compose.yml`文件中`DEFAULT_ROOT_PSW`并重启即可,密码会自动更新。

View File

@@ -4,7 +4,7 @@ description: 'FastGPT V4.8.5 更新说明'
icon: 'upgrade'
draft: false
toc: true
weight: 820
weight: 819
---
## 升级指南
@@ -14,8 +14,7 @@ weight: 820
### 2. 修改镜像
- fastgpt 镜像 tag 修改成 v4.8.5-alpha
<!-- - fastgpt-sandbox 镜像 tag 修改成 v4.8.5 (选择性,无变更) -->
<!-- - 商业版镜像 tag 修改成 v4.8.5 -->
- 商业版镜像 tag 修改成 v4.8.5 -alpha
### 3. 执行初始化
@@ -29,6 +28,20 @@ curl --location --request POST 'https://{{host}}/api/admin/initv485' \
会把插件的数据表合并到应用中,插件表不会删除。
------
**商业版用户执行额外的初始化**
从任意终端,发起 1 个 HTTP 请求。其中 {{rootkey}} 替换成环境变量里的 `rootkey`{{host}} 替换成**FastGPT 商业版的域名**
```bash
curl --location --request POST 'https://{{host}}/api/admin/init/485' \
--header 'rootkey: {{rootkey}}' \
--header 'Content-Type: application/json'
```
会重置知识库权限系统。
## V4.8.5 更新说明
1. 新增 - 合并插件和应用,统一成工作台
@@ -40,4 +53,5 @@ curl --location --request POST 'https://{{host}}/api/admin/initv485' \
7. 修复 - SSR渲染
8. 修复 - 定时任务无法实际关闭
9. 修复 - 输入引导特殊字符导致正则报错
10. 修复 - 文件包含特殊字符`%`,且为转义时会导致页面崩溃
10. 修复 - 文件包含特殊字符`%`,且为转义时会导致页面崩溃
11. 修复 - 自定义输入选择知识库引用时页面崩溃

View File

@@ -161,7 +161,8 @@ services:
# oneapi
mysql:
image: mysql:8.0.36
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mysql:8.0.36 # 阿里云
# image: mysql:8.0.36
container_name: mysql
restart: always
ports:

View File

@@ -118,7 +118,8 @@ services:
# oneapi
mysql:
image: mysql:8.0.36
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mysql:8.0.36 # 阿里云
# image: mysql:8.0.36
container_name: mysql
restart: always
ports:

View File

@@ -99,7 +99,8 @@ services:
# oneapi
mysql:
image: mysql:8.0.36
image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mysql:8.0.36 # 阿里云
# image: mysql:8.0.36
container_name: mysql
restart: always
ports:

View File

@@ -21,7 +21,7 @@ export type AppSchema = {
name: string;
avatar: string;
intro: string;
updateTime: number;
updateTime: Date;
modules: StoreNodeItemType[];
edges: StoreEdgeItemType[];
@@ -44,10 +44,12 @@ export type AppSchema = {
export type AppListItemType = {
_id: string;
tmbId: string;
name: string;
avatar: string;
intro: string;
type: AppTypeEnum;
updateTime: Date;
defaultPermission: PermissionValueType;
permission: AppPermission;
pluginData?: AppSchema['pluginData'];

View File

@@ -17,4 +17,4 @@ export const DatasetPermissionList = {
}
};
export const DatasetDefaultPermission = NullPermission;
export const DatasetDefaultPermissionVal = NullPermission;

View File

@@ -13,7 +13,7 @@ export const NextEntry = ({ beforeCallback = [] }: { beforeCallback?: Promise<an
return (...args: NextApiHandler[]): NextApiHandler => {
return async function api(req: ApiRequestProps, res: NextApiResponse) {
const start = Date.now();
addLog.info(`Request start ${req.url}`);
addLog.debug(`Request start ${req.url}`);
try {
await Promise.all([withNextCors(req, res), ...beforeCallback]);
@@ -24,7 +24,7 @@ export const NextEntry = ({ beforeCallback = [] }: { beforeCallback?: Promise<an
const contentType = res.getHeader('Content-Type');
addLog.info(`Request finish ${req.url}, time: ${Date.now() - start}ms`);
addLog.debug(`Request finish ${req.url}, time: ${Date.now() - start}ms`);
if ((!contentType || contentType === 'application/json') && !res.writableFinished) {
return jsonRes(res, {

View File

@@ -12,7 +12,7 @@ import {
TeamMemberCollectionName
} from '@fastgpt/global/support/user/team/constant';
import { PermissionTypeEnum, PermissionTypeMap } from '@fastgpt/global/support/permission/constant';
import { DatasetDefaultPermission } from '@fastgpt/global/support/permission/dataset/constant';
import { DatasetDefaultPermissionVal } from '@fastgpt/global/support/permission/dataset/constant';
export const DatasetCollectionName = 'datasets';
@@ -94,7 +94,7 @@ const DatasetSchema = new Schema({
externalReadUrl: String,
defaultPermission: {
type: Number,
default: DatasetDefaultPermission
default: DatasetDefaultPermissionVal
}
});

View File

@@ -38,7 +38,7 @@ export const authAppByTmbId = async ({
return Promise.reject(AppErrEnum.unExist);
}
const isOwner = tmbPer.isOwner || String(app.tmbId) === tmbId;
const isOwner = tmbPer.isOwner || String(app.tmbId) === String(tmbId);
const Per = new AppPermission({ per: rp?.permission ?? app.defaultPermission, isOwner });
if (!Per.checkPer(per)) {

View File

@@ -1,16 +1,18 @@
import { AuthResponseType } from '@fastgpt/global/support/permission/type';
import { AuthModeType } from '../type';
import { DatasetFileSchema } from '@fastgpt/global/core/dataset/type';
import { parseHeaderCert } from '../controller';
import { getFileById } from '../../../common/file/gridfs/controller';
import { BucketNameEnum } from '@fastgpt/global/common/file/constants';
import { CommonErrEnum } from '@fastgpt/global/common/error/code/common';
import { OwnerPermissionVal, ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
import { AuthPropsType, AuthResponseType } from '../type/auth';
import { Permission } from '@fastgpt/global/support/permission/controller';
export async function authFile({
fileId,
per = 'owner',
per = OwnerPermissionVal,
...props
}: AuthModeType & {
}: AuthPropsType & {
fileId: string;
}): Promise<
AuthResponseType & {
@@ -29,14 +31,19 @@ export async function authFile({
if (file.metadata?.teamId !== teamId) {
return Promise.reject(CommonErrEnum.unAuthFile);
}
if (per === 'owner' && file.metadata?.tmbId !== tmbId) {
const permission = new Permission({
per: ReadPermissionVal,
isOwner: file.metadata?.tmbId === tmbId
});
if (!permission.checkPer(per)) {
return Promise.reject(CommonErrEnum.unAuthFile);
}
return {
...authRes,
isOwner: per === 'owner',
canWrite: per === 'owner',
permission,
file
};
}

View File

@@ -18,6 +18,7 @@ import { getFileById } from '../../../common/file/gridfs/controller';
import { BucketNameEnum } from '@fastgpt/global/common/file/constants';
import { CommonErrEnum } from '@fastgpt/global/common/error/code/common';
import { MongoDatasetData } from '../../../core/dataset/data/schema';
import { DatasetDefaultPermissionVal } from '@fastgpt/global/support/permission/dataset/constant';
export async function authDatasetByTmbId({
tmbId,
@@ -46,7 +47,7 @@ export async function authDatasetByTmbId({
return Promise.reject(DatasetErrEnum.unExist);
}
const isOwner = tmbPer.isOwner || String(dataset.tmbId) === tmbId;
const isOwner = tmbPer.isOwner || String(dataset.tmbId) === String(tmbId);
const Per = new DatasetPermission({
per: rp?.permission ?? dataset.defaultPermission,
isOwner
@@ -58,11 +59,12 @@ export async function authDatasetByTmbId({
return {
...dataset,
defaultPermission: dataset.defaultPermission ?? DatasetDefaultPermissionVal,
permission: Per
};
})();
return { dataset: dataset };
return { dataset };
}
// Auth Dataset
@@ -202,7 +204,7 @@ export async function authDatasetData({
collectionId: String(datasetData.collectionId),
sourceName: result.collection.name || '',
sourceId: result.collection?.fileId || result.collection?.rawLink,
isOwner: String(datasetData.tmbId) === result.tmbId,
isOwner: String(datasetData.tmbId) === String(result.tmbId),
canWrite: result.permission.hasWritePer
};

View File

@@ -200,6 +200,7 @@ export const iconPaths = {
'modal/setting': () => import('./icons/modal/setting.svg'),
'modal/teamPlans': () => import('./icons/modal/teamPlans.svg'),
more: () => import('./icons/more.svg'),
moreLine: () => import('./icons/moreLine.svg'),
out: () => import('./icons/out.svg'),
'phoneTabbar/me': () => import('./icons/phoneTabbar/me.svg'),
'phoneTabbar/tool': () => import('./icons/phoneTabbar/tool.svg'),

View File

@@ -1,4 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 15">
<path fill-rule="evenodd" clip-rule="evenodd"
d="M0.3018 8.09539C0.3018 10.2395 1.9585 11.9966 4.06162 12.1565V12.1638H4.17973C4.24438 12.1669 4.30942 12.1684 4.37482 12.1684C4.44022 12.1684 4.50526 12.1669 4.56991 12.1638H9.90977C9.97056 12.1669 10.0317 12.1684 10.0933 12.1684C12.0842 12.1684 13.6982 10.5544 13.6982 8.5635C13.6982 7.10314 12.8298 5.84559 11.5813 5.27905C11.1437 3.54133 9.6068 2.25784 7.77794 2.25784C6.42674 2.25784 5.23488 2.95844 4.52802 4.0252C4.47719 4.02332 4.42611 4.02237 4.37482 4.02237C2.12535 4.02237 0.3018 5.84592 0.3018 8.09539ZM2.25691 9.26391C2.30952 9.31652 2.38405 9.34283 2.48051 9.34283C2.58135 9.34283 2.65697 9.31652 2.70739 9.26391C2.75781 9.20911 2.78302 9.13239 2.78302 9.03374V8.38596H3.73989V9.03374C3.73989 9.13239 3.7651 9.20911 3.81552 9.26391C3.86813 9.31652 3.94376 9.34283 4.0424 9.34283C4.13886 9.34283 4.2123 9.31652 4.26271 9.26391C4.31533 9.20911 4.34163 9.13239 4.34163 9.03374V7.27455C4.34163 7.17371 4.31533 7.09699 4.26271 7.04437C4.2123 6.99176 4.13886 6.96546 4.0424 6.96546C3.94376 6.96546 3.86813 6.99176 3.81552 7.04437C3.7651 7.09699 3.73989 7.17371 3.73989 7.27455V7.88944H2.78302V7.27455C2.78302 7.17371 2.75672 7.09699 2.70411 7.04437C2.65369 6.99176 2.57915 6.96546 2.48051 6.96546C2.38405 6.96546 2.30952 6.99176 2.25691 7.04437C2.2043 7.09699 2.17799 7.17371 2.17799 7.27455V9.03374C2.17799 9.13239 2.2043 9.20911 2.25691 9.26391ZM5.65077 9.26391C5.70338 9.31652 5.77792 9.34283 5.87437 9.34283C5.97521 9.34283 6.05084 9.31652 6.10126 9.26391C6.15168 9.20911 6.17689 9.13348 6.17689 9.03703V7.48828H6.69313C6.77424 7.48828 6.83562 7.46746 6.87727 7.42581C6.92112 7.38196 6.94304 7.32058 6.94304 7.24167C6.94304 7.16056 6.92112 7.09918 6.87727 7.05753C6.83562 7.01588 6.77424 6.99505 6.69313 6.99505H5.05561C4.9745 6.99505 4.91202 7.01588 4.86818 7.05753C4.82653 7.09918 4.8057 7.16056 4.8057 7.24167C4.8057 7.32058 4.82653 7.38196 4.86818 7.42581C4.91202 7.46746 4.9745 7.48828 5.05561 7.48828H5.57186V9.03703C5.57186 9.13348 5.59816 9.20911 5.65077 9.26391ZM8.29852 9.34283C8.20207 9.34283 8.12754 9.31652 8.07492 9.26391C8.02231 9.20911 7.99601 9.13348 7.99601 9.03703V7.48828H7.47976C7.39865 7.48828 7.33617 7.46746 7.29233 7.42581C7.25068 7.38196 7.22986 7.32058 7.22986 7.24167C7.22986 7.16056 7.25068 7.09918 7.29233 7.05753C7.33617 7.01588 7.39865 6.99505 7.47976 6.99505H9.11729C9.19839 6.99505 9.25977 7.01588 9.30143 7.05753C9.34527 7.09918 9.36719 7.16056 9.36719 7.24167C9.36719 7.32058 9.34527 7.38196 9.30143 7.42581C9.25977 7.46746 9.19839 7.48828 9.11729 7.48828H8.60104V9.03703C8.60104 9.13348 8.57583 9.20911 8.52541 9.26391C8.47499 9.31652 8.39936 9.34283 8.29852 9.34283ZM9.90828 9.26391C9.96089 9.31652 10.0354 9.34283 10.1319 9.34283C10.2327 9.34283 10.3083 9.31652 10.3588 9.26391C10.4092 9.20911 10.4344 9.13348 10.4344 9.03703V8.5142H10.9441C11.2071 8.5142 11.4099 8.44734 11.5524 8.31362C11.6971 8.17771 11.7694 7.99138 11.7694 7.75463C11.7694 7.51788 11.6971 7.33264 11.5524 7.19892C11.4099 7.06301 11.2071 6.99505 10.9441 6.99505H10.1352C10.0387 6.99505 9.96308 7.02136 9.90828 7.07397C9.85567 7.12658 9.82936 7.20221 9.82936 7.30086V9.03703C9.82936 9.13348 9.85567 9.20911 9.90828 9.26391ZM10.8388 8.05057H10.4344V7.45869H10.8388C10.9528 7.45869 11.0405 7.4828 11.1019 7.53103C11.1633 7.57926 11.194 7.65379 11.194 7.75463C11.194 7.85327 11.1633 7.92781 11.1019 7.97823C11.0405 8.02645 10.9528 8.05057 10.8388 8.05057Z" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14" >
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.43797 7.11649C9.43734 7.12604 9.43702 7.13567 9.43702 7.14537V8.51808H9.43797V8.8255C9.43797 9.03402 9.60701 9.20306 9.81553 9.20306C10.024 9.20306 10.1931 9.03402 10.1931 8.8255V8.51808H10.4554C10.9537 8.51808 11.3577 8.11411 11.3577 7.61579C11.3577 7.11746 10.9537 6.71349 10.4554 6.71349H9.86889C9.7831 6.71349 9.70315 6.73851 9.63594 6.78165C9.51803 6.84552 9.43797 6.97033 9.43797 7.11384V7.11649ZM10.1931 7.76558V7.46599H10.4554C10.5381 7.46599 10.6052 7.53306 10.6052 7.61579C10.6052 7.69851 10.5381 7.76558 10.4554 7.76558H10.1931Z" />
<path d="M2.56416 7.11385C2.56416 6.90532 2.7332 6.73628 2.94172 6.73628C3.15024 6.73628 3.31928 6.90532 3.31928 7.11385V7.55213H3.91782V7.11385C3.91782 6.90532 4.08686 6.73628 4.29538 6.73628C4.5039 6.73628 4.67294 6.90532 4.67294 7.11385V8.8255C4.67294 9.03402 4.5039 9.20306 4.29538 9.20306C4.08686 9.20306 3.91782 9.03402 3.91782 8.8255V8.30725H3.31928V8.8255C3.31928 9.03402 3.15024 9.20306 2.94172 9.20306C2.7332 9.20306 2.56416 9.03402 2.56416 8.8255V7.11385Z" />
<path d="M6.56046 6.73628C6.76898 6.73628 6.93802 6.90532 6.93802 7.11385C6.93802 7.32237 6.76898 7.49141 6.56046 7.49141H6.27522V8.8255C6.27522 9.03402 6.10618 9.20306 5.89766 9.20306C5.68914 9.20306 5.5201 9.03402 5.5201 8.8255V7.49141H5.23489C5.02637 7.49141 4.85733 7.32237 4.85733 7.11385C4.85733 6.90532 5.02637 6.73628 5.23489 6.73628H6.56046Z" />
<path d="M8.82547 6.73628C9.03399 6.73628 9.20303 6.90532 9.20303 7.11385C9.20303 7.32237 9.03399 7.49141 8.82547 7.49141H8.54023V8.8255C8.54023 9.03402 8.37119 9.20306 8.16267 9.20306C7.95414 9.20306 7.78511 9.03402 7.78511 8.8255V7.49141H7.4999C7.29138 7.49141 7.12234 7.32237 7.12234 7.11385C7.12234 6.90532 7.29138 6.73628 7.4999 6.73628H8.82547Z" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.583374 7.84518C0.583374 9.89915 2.17044 11.5824 4.18517 11.7356V11.7426H4.29822C4.36018 11.7455 4.42252 11.747 4.4852 11.747C4.54789 11.747 4.61023 11.7455 4.67219 11.7426H9.78743C9.84569 11.7455 9.90433 11.747 9.96332 11.747C11.8706 11.747 13.4167 10.2009 13.4167 8.29361C13.4167 6.89463 12.5849 5.68995 11.3888 5.14721C10.9696 3.48253 9.49728 2.25299 7.74529 2.25299C6.45088 2.25299 5.30912 2.92414 4.63196 3.94606C4.58327 3.94426 4.53434 3.94335 4.4852 3.94335C2.33028 3.94335 0.583374 5.69026 0.583374 7.84518ZM4.32102 10.5759L4.27363 10.5723C2.8625 10.465 1.75004 9.28447 1.75004 7.84518C1.75004 6.33459 2.97461 5.11002 4.4852 5.11002C4.51994 5.11002 4.5545 5.11066 4.58885 5.11193L5.24295 5.13612L5.6045 4.59049C6.07973 3.8733 6.86712 3.41966 7.74529 3.41966C8.93072 3.41966 9.96085 4.2542 10.2574 5.43208L10.3947 5.97729L10.9067 6.20962C11.7013 6.57016 12.25 7.36904 12.25 8.29361C12.25 9.55654 11.2262 10.5803 9.96332 10.5803C9.92383 10.5803 9.88468 10.5794 9.84589 10.5774L9.81668 10.5759H4.64468L4.61721 10.5772C4.57355 10.5793 4.52954 10.5803 4.4852 10.5803C4.44087 10.5803 4.39686 10.5793 4.35319 10.5772L4.32572 10.5759H4.32102Z" />
</svg>

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -1,4 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none">
<path
d="M15.7787 21.2528H11.9977V19.31C11.9977 19.2215 11.9896 19.133 11.9735 19.0445C11.9574 18.956 11.9293 18.8716 11.8931 18.7871C11.8569 18.7026 11.8167 18.6262 11.7644 18.5538C11.7121 18.4814 11.6558 18.413 11.5914 18.3487C11.2656 18.0269 10.7909 17.8459 10.2962 17.8539C10.1876 17.8539 10.079 17.866 9.97038 17.8861C9.86178 17.9062 9.7572 17.9344 9.65261 17.9746C9.54803 18.0148 9.4515 18.0591 9.35496 18.1154C9.25842 18.1717 9.16993 18.236 9.08948 18.3084C8.86825 18.5055 8.60679 18.8394 8.60679 19.3462V21.2528H4.85391C4.77749 21.2528 4.70106 21.2488 4.62464 21.2408C4.54821 21.2327 4.47179 21.2206 4.39536 21.2086C4.31894 21.1925 4.24653 21.1764 4.17011 21.1523C4.0977 21.1281 4.0253 21.104 3.9529 21.0758C3.8805 21.0477 3.81211 21.0115 3.74373 20.9753C3.67535 20.9391 3.611 20.8989 3.54664 20.8546C3.48228 20.8104 3.42194 20.7661 3.36161 20.7179C3.30127 20.6696 3.24496 20.6173 3.18865 20.561C3.13233 20.5047 3.08406 20.4484 3.03177 20.388C2.9835 20.3277 2.93524 20.2673 2.89501 20.203C2.85077 20.1386 2.81054 20.0743 2.77434 20.0059C2.73814 19.9375 2.70596 19.8691 2.67378 19.7967C2.64562 19.7243 2.61747 19.6519 2.59736 19.5795C2.57322 19.5071 2.55713 19.4307 2.54104 19.3543C2.52495 19.2778 2.51289 19.2014 2.50886 19.125C2.50082 19.0486 2.4968 18.9721 2.4968 18.8957V15.1469H4.43558C4.82576 15.1469 5.20386 14.9819 5.50152 14.6803C5.58599 14.5958 5.65839 14.5073 5.72275 14.4067C5.7871 14.3102 5.84342 14.2056 5.88766 14.097C5.93191 13.9884 5.96409 13.8758 5.98822 13.7591C6.01236 13.6425 6.0204 13.5258 6.0204 13.4092C6.00431 12.5082 5.26419 11.7479 4.39938 11.7479H2.4968V7.95885C2.4968 7.806 2.51289 7.65315 2.54104 7.5003C2.57322 7.34745 2.61747 7.20265 2.6778 7.06186C2.73814 6.92108 2.81054 6.78432 2.89903 6.65962C2.98753 6.53091 3.08809 6.41426 3.19669 6.30968C3.30529 6.20509 3.42597 6.10856 3.55468 6.02409C3.6834 5.93962 3.82016 5.87124 3.96094 5.81492C4.10173 5.75861 4.25055 5.71436 4.39938 5.68621C4.54821 5.65805 4.70106 5.64196 4.85391 5.64598H7.53684V5.02654C7.53684 4.98229 7.53684 4.93402 7.54086 4.88978C7.54489 4.84553 7.54489 4.79726 7.55293 4.75301C7.55695 4.70877 7.565 4.6605 7.56902 4.61625C7.57706 4.57201 7.58511 4.52374 7.59315 4.47949C7.6012 4.43525 7.61327 4.391 7.62533 4.34675L7.66153 4.21402C7.6736 4.16977 7.68969 4.12552 7.70578 4.08128C7.72187 4.03703 7.73796 3.99681 7.75405 3.95256C7.77014 3.90831 7.79025 3.86809 7.81036 3.82787C7.83047 3.78764 7.85059 3.7434 7.87472 3.70317C7.89483 3.66295 7.91897 3.62273 7.9431 3.5825C7.96724 3.54228 7.99137 3.50608 8.01953 3.46585C8.04366 3.42965 8.07182 3.38943 8.09997 3.35323L8.18444 3.24462C8.2126 3.20842 8.24478 3.17624 8.27696 3.14004C8.30914 3.10786 8.34132 3.07166 8.3735 3.03948C8.40568 3.0073 8.44188 2.97512 8.47406 2.94696C8.51026 2.91479 8.54244 2.88663 8.57864 2.85847L8.68724 2.774C8.72344 2.74585 8.76367 2.72171 8.79987 2.69758C8.83607 2.67344 8.87629 2.64931 8.91652 2.62517C8.95674 2.60104 8.99697 2.58093 9.03719 2.55679C9.07741 2.53668 9.11764 2.51657 9.16188 2.49646C9.20211 2.47635 9.24635 2.46026 9.2906 2.44417C9.33485 2.42808 9.37507 2.41199 9.41932 2.3959C9.46356 2.37981 9.50781 2.36774 9.55205 2.35567L9.68479 2.31947C9.72904 2.30741 9.77329 2.29936 9.82155 2.29132C9.86982 2.28327 9.91407 2.27523 9.95832 2.2712C10.0026 2.26718 10.0508 2.25914 10.0951 2.25512C10.1393 2.25109 10.1876 2.24707 10.2318 2.24707H10.3686C11.873 2.27523 13.0998 3.53423 13.0998 5.06274V5.64196H15.7787C15.8551 5.64196 15.9316 5.64598 16.008 5.65001C16.0844 5.65805 16.1608 5.6661 16.2332 5.68218C16.3097 5.69827 16.3821 5.71436 16.4545 5.73448C16.5269 5.75459 16.5993 5.78274 16.6717 5.8109C16.7441 5.83906 16.8125 5.87124 16.8808 5.90744C16.9492 5.94364 17.0136 5.98386 17.0779 6.02409C17.1423 6.06431 17.2026 6.11258 17.263 6.16085C17.3233 6.20912 17.3796 6.26141 17.4319 6.3137C17.4842 6.36599 17.5365 6.42633 17.5848 6.48264C17.633 6.54297 17.6773 6.60331 17.7215 6.66767C17.7658 6.73203 17.802 6.79639 17.8382 6.86477C17.8744 6.93315 17.9065 7.00153 17.9347 7.07393C17.9629 7.14633 17.987 7.21873 18.0111 7.29114C18.0312 7.36354 18.0513 7.43997 18.0634 7.51237C18.0795 7.58879 18.0876 7.6612 18.0956 7.73762C18.1036 7.81405 18.1036 7.89047 18.1036 7.9669V10.6498H18.6829C20.2355 10.6498 21.4985 11.8807 21.4985 13.3931C21.4985 14.9457 20.2516 16.2088 18.7191 16.2088H18.1036V18.8917C18.1077 20.1909 17.0618 21.2528 15.7787 21.2528Z" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 15" >
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.97746 4.90437L6.94722 3.76877C6.93325 3.24427 6.50299 2.82286 5.97468 2.82286C5.44637 2.82286 5.01612 3.24427 5.00215 3.76877L4.9719 4.90437H2.625C2.46391 4.90437 2.33333 5.03496 2.33333 5.19604V6.53174C3.42082 6.57293 4.2898 7.46755 4.2898 8.56512C4.2898 9.66269 3.42082 10.5573 2.33333 10.5985V11.8618C2.33333 12.0229 2.46391 12.1535 2.625 12.1535H3.99648C4.06812 11.1234 4.92641 10.3101 5.97466 10.3101C7.02292 10.3101 7.88121 11.1234 7.95285 12.1535H9.29071C9.4518 12.1535 9.58238 12.0229 9.58238 11.8618V9.58522L10.712 9.5493C11.2403 9.53249 11.664 9.09811 11.664 8.56522C11.664 8.03233 11.2403 7.59795 10.712 7.58115L9.58238 7.54523V5.19604C9.58238 5.03496 9.4518 4.90437 9.29071 4.90437H6.97746ZM6.79103 13.3201V12.2931C6.79103 11.8422 6.42553 11.4767 5.97466 11.4767C5.5238 11.4767 5.1583 11.8422 5.1583 12.2931V13.3201H2.625C1.81958 13.3201 1.16666 12.6672 1.16666 11.8618V9.43332H2.25493C2.73443 9.43332 3.12313 9.04461 3.12313 8.56512C3.12313 8.08563 2.73443 7.69692 2.25493 7.69692L1.16666 7.69692V5.19604C1.16666 4.39063 1.81958 3.73771 2.625 3.73771H3.83589C3.86665 2.58289 4.81244 1.65619 5.97468 1.65619C7.13692 1.65619 8.08271 2.58289 8.11347 3.73771H9.29071C10.0961 3.73771 10.749 4.39063 10.749 5.19604V6.41507C11.9049 6.45184 12.8307 7.40042 12.8307 8.56522C12.8307 9.73003 11.9049 10.6786 10.749 10.7154V11.8618C10.749 12.6672 10.0961 13.3201 9.29071 13.3201H6.79103Z" />
</svg>

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -1,15 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 15" fill="none">
<g clip-path="url(#clip0_5676_3579)">
<path
d="M6.46665 1.10308C6.74565 0.941999 7.19801 0.941998 7.47701 1.10308L11.7403 3.56452C12.2984 3.88669 12.2984 4.40902 11.7403 4.73119L7.53312 7.16023C7.25411 7.32132 6.80176 7.32132 6.52275 7.16023L2.25942 4.6988C1.70141 4.37663 1.70141 3.85429 2.25941 3.53213L6.46665 1.10308Z" />
<path
d="M1.49066 6.17483C1.49066 5.7238 1.80731 5.54098 2.19792 5.7665L6.13886 8.0418C6.36206 8.17067 6.54301 8.48407 6.54301 8.74181V12.9081C6.54301 13.3592 6.22636 13.542 5.83575 13.3165L1.89481 11.0411C1.6716 10.9123 1.49066 10.5989 1.49066 10.3411V6.17483Z" />
<path
d="M7.45634 8.77325C7.45634 8.51552 7.63729 8.20212 7.86049 8.07325L11.8021 5.79758C12.1927 5.57206 12.5093 5.75488 12.5093 6.20591V10.3717C12.5093 10.6295 12.3284 10.9429 12.1052 11.0717L8.1636 13.3474C7.77299 13.5729 7.45634 13.3901 7.45634 12.9391V8.77325Z" />
</g>
<defs>
<clipPath id="clip0_5676_3579">
<rect width="14" height="14" fill="white" transform="translate(0 0.213127)" />
</clipPath>
</defs>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 13" >
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.765 0.172234C5.92006 0.140343 6.07999 0.140343 6.23505 0.172234C6.41429 0.209098 6.5745 0.298831 6.70186 0.370168C6.71373 0.376812 6.7253 0.383296 6.73658 0.389563L11.0532 2.78771C11.0652 2.79434 11.0775 2.80111 11.0901 2.80805C11.2249 2.88232 11.3944 2.97569 11.5246 3.11696C11.6372 3.2391 11.7224 3.38386 11.7745 3.54157C11.8347 3.72398 11.834 3.91751 11.8335 4.07144C11.8334 4.08583 11.8334 4.09986 11.8334 4.11352V8.8485C11.8334 8.86215 11.8334 8.87619 11.8335 8.89057C11.834 9.0445 11.8347 9.23804 11.7745 9.42045C11.7224 9.57815 11.6372 9.72291 11.5246 9.84505C11.3944 9.98632 11.2249 10.0797 11.0901 10.154C11.0775 10.1609 11.0652 10.1677 11.0532 10.1743L6.73658 12.5725C6.7253 12.5787 6.71372 12.5852 6.70186 12.5918C6.57449 12.6632 6.41429 12.7529 6.23505 12.7898C6.07999 12.8217 5.92006 12.8217 5.765 12.7898C5.58575 12.7529 5.42554 12.6632 5.29818 12.5918C5.28632 12.5852 5.27474 12.5787 5.26346 12.5725L0.946797 10.1743C0.934865 10.1677 0.92257 10.1609 0.909971 10.154C0.775143 10.0797 0.605615 9.98632 0.475427 9.84505C0.362873 9.72291 0.277694 9.57815 0.225587 9.42045C0.165319 9.23804 0.166024 9.0445 0.166585 8.89057C0.166637 8.87619 0.166688 8.86215 0.166688 8.8485V4.11352C0.166688 4.09987 0.166637 4.08583 0.166585 4.07144C0.166024 3.91752 0.165319 3.72398 0.225587 3.54157C0.277694 3.38386 0.362872 3.2391 0.475427 3.11696C0.605613 2.97569 0.775138 2.88232 0.909965 2.80806C0.922566 2.80112 0.934863 2.79434 0.946797 2.78771L5.26346 0.389563C5.27474 0.383296 5.28632 0.376813 5.29818 0.370169C5.42555 0.298831 5.58575 0.209098 5.765 0.172234ZM6.00002 1.31792C5.99913 1.31834 5.9982 1.31878 5.99723 1.31925C5.96357 1.33549 5.91845 1.3603 5.83005 1.40941L1.95119 3.56434L6 5.81368L10.0488 3.56433L6.17 1.40941C6.0816 1.3603 6.03647 1.33549 6.00281 1.31925C6.00184 1.31878 6.00091 1.31834 6.00002 1.31792ZM10.6667 4.5557V8.8485C10.6667 8.95523 10.6664 9.00986 10.6641 9.04942C10.664 9.05059 10.6639 9.0517 10.6639 9.05277C10.663 9.05335 10.662 9.05395 10.661 9.05458C10.6276 9.07587 10.58 9.10262 10.4867 9.15445L6.58335 11.323L6.58334 6.82422L10.6667 4.5557ZM5.41667 6.82422L1.33336 4.55572V8.8485C1.33336 8.95523 1.3336 9.00986 1.33598 9.04942C1.33605 9.05059 1.33612 9.0517 1.33619 9.05277C1.33709 9.05335 1.33803 9.05395 1.33901 9.05458C1.37244 9.07587 1.42007 9.10262 1.51338 9.15445L5.41669 11.323L5.41667 6.82422Z"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -1,18 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 15" fill="none">
<path
d="M4.35632 8.49118C4.35632 8.79915 4.10666 9.04881 3.79868 9.04881C3.49071 9.04881 3.24105 8.79915 3.24105 8.49118L3.24105 6.36137C3.24105 6.05339 3.49071 5.80373 3.79868 5.80373C4.10666 5.80373 4.35632 6.05339 4.35632 6.36137L4.35632 8.49118Z" />
<path fill-rule="evenodd" clip-rule="evenodd"
d="M3.79868 5.4847C4.49442 5.4847 5.05843 4.92069 5.05843 4.22495C5.05843 3.52922 4.49442 2.96521 3.79868 2.96521C3.10295 2.96521 2.53894 3.52922 2.53894 4.22495C2.53894 4.92069 3.10295 5.4847 3.79868 5.4847ZM3.79868 6.59996C5.11036 6.59996 6.17369 5.53663 6.17369 4.22495C6.17369 2.91327 5.11036 1.84995 3.79868 1.84995C2.487 1.84995 1.42368 2.91327 1.42368 4.22495C1.42368 5.53663 2.487 6.59996 3.79868 6.59996Z" />
<path fill-rule="evenodd" clip-rule="evenodd"
d="M6.79074 3.68998C6.79074 3.382 7.0404 3.13234 7.34838 3.13234C7.93704 3.13234 8.52062 3.24176 9.06606 3.45504C9.61153 3.66834 10.1092 3.98174 10.5298 4.37882C10.9505 4.77596 11.286 5.2492 11.5156 5.7724C11.7452 6.29569 11.8639 6.85778 11.8639 7.42627C11.8639 7.73424 11.6142 7.9839 11.3062 7.9839C10.9983 7.9839 10.7486 7.73424 10.7486 7.42627C10.7486 7.01345 10.6625 6.60383 10.4943 6.22051C10.3261 5.83709 10.0786 5.48655 9.76421 5.1898C9.4498 4.89299 9.07481 4.65597 8.65991 4.49373C8.24496 4.33147 7.79922 4.24761 7.34838 4.24761C7.0404 4.24761 6.79074 3.99795 6.79074 3.68998Z" />
<path fill-rule="evenodd" clip-rule="evenodd"
d="M3.79868 11.8873C4.49442 11.8873 5.05843 11.3233 5.05843 10.6276C5.05843 9.93185 4.49442 9.36785 3.79868 9.36785C3.10295 9.36785 2.53894 9.93185 2.53894 10.6276C2.53894 11.3233 3.10295 11.8873 3.79868 11.8873ZM3.79868 13.0026C5.11036 13.0026 6.17369 11.9393 6.17369 10.6276C6.17369 9.31591 5.11036 8.25258 3.79868 8.25258C2.487 8.25258 1.42368 9.31591 1.42368 10.6276C1.42368 11.9393 2.487 13.0026 3.79868 13.0026Z" />
<path fill-rule="evenodd" clip-rule="evenodd"
d="M10.7808 9.55902H9.81307C9.47678 9.55902 9.29277 9.55992 9.16063 9.57089C9.15546 9.57132 9.15056 9.57175 9.14592 9.57219C9.14549 9.57682 9.14506 9.58172 9.14463 9.58689C9.13365 9.71903 9.13276 9.90305 9.13276 10.2393V11.207C9.13276 11.5433 9.13365 11.7273 9.14463 11.8595C9.14506 11.8646 9.14549 11.8695 9.14592 11.8742C9.15056 11.8746 9.15546 11.875 9.16063 11.8755C9.29277 11.8864 9.47678 11.8873 9.81307 11.8873H10.7808C11.117 11.8873 11.3011 11.8864 11.4332 11.8755C11.4384 11.875 11.4433 11.8746 11.4479 11.8742C11.4483 11.8695 11.4488 11.8646 11.4492 11.8595C11.4602 11.7273 11.4611 11.5433 11.4611 11.207V10.2393C11.4611 9.90305 11.4602 9.71903 11.4492 9.58689C11.4488 9.58172 11.4483 9.57682 11.4479 9.57219C11.4433 9.57175 11.4384 9.57132 11.4332 9.57089C11.3011 9.55992 11.117 9.55902 10.7808 9.55902ZM8.14306 9.04491C8.01749 9.28663 8.01749 9.6042 8.01749 10.2393V11.207C8.01749 11.8421 8.01749 12.1597 8.14306 12.4014C8.24887 12.6051 8.41495 12.7712 8.61865 12.877C8.86037 13.0026 9.17794 13.0026 9.81307 13.0026H10.7808C11.4159 13.0026 11.7335 13.0026 11.9752 12.877C12.1789 12.7712 12.345 12.6051 12.4508 12.4014C12.5763 12.1597 12.5763 11.8421 12.5763 11.207V10.2393C12.5763 9.6042 12.5763 9.28663 12.4508 9.04491C12.345 8.84122 12.1789 8.67513 11.9752 8.56932C11.7335 8.44375 11.4159 8.44375 10.7808 8.44375H9.81307C9.17794 8.44375 8.86037 8.44375 8.61865 8.56932C8.41495 8.67513 8.24887 8.84122 8.14306 9.04491Z" />
<path
d="M5.05843 4.22495C5.05843 4.92069 4.49442 5.4847 3.79868 5.4847C3.10295 5.4847 2.53894 4.92069 2.53894 4.22495C2.53894 3.52922 3.10295 2.96521 3.79868 2.96521C4.49442 2.96521 5.05843 3.52922 5.05843 4.22495Z" />
<path
d="M5.05843 10.6276C5.05843 11.3233 4.49442 11.8873 3.79868 11.8873C3.10295 11.8873 2.53894 11.3233 2.53894 10.6276C2.53894 9.93185 3.10295 9.36785 3.79868 9.36785C4.49442 9.36785 5.05843 9.93185 5.05843 10.6276Z" />
<path
d="M9.81307 9.55902H10.7808C11.117 9.55902 11.3011 9.55992 11.4332 9.57089L11.4479 9.57219L11.4492 9.58689C11.4602 9.71903 11.4611 9.90305 11.4611 10.2393V11.207C11.4611 11.5433 11.4602 11.7273 11.4492 11.8595L11.4479 11.8742L11.4332 11.8755C11.3011 11.8864 11.117 11.8873 10.7808 11.8873H9.81307C9.47678 11.8873 9.29277 11.8864 9.16063 11.8755L9.14592 11.8742L9.14463 11.8595C9.13365 11.7273 9.13276 11.5433 9.13276 11.207V10.2393C9.13276 9.90305 9.13365 9.71903 9.14463 9.58689L9.14592 9.57219L9.16063 9.57089C9.29277 9.55992 9.47678 9.55902 9.81307 9.55902Z" />
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 15" >
<path d="M4.35632 8.54584C4.35632 8.85381 4.10666 9.10347 3.79868 9.10347C3.49071 9.10347 3.24105 8.85381 3.24105 8.54584L3.24105 6.41602C3.24105 6.10805 3.49071 5.85839 3.79868 5.85839C4.10666 5.85839 4.35632 6.10805 4.35632 6.41602L4.35632 8.54584Z" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.79868 5.53935C4.49442 5.53935 5.05843 4.97535 5.05843 4.27961C5.05843 3.58387 4.49442 3.01987 3.79868 3.01987C3.10295 3.01987 2.53894 3.58387 2.53894 4.27961C2.53894 4.97535 3.10295 5.53935 3.79868 5.53935ZM3.79868 6.65462C5.11036 6.65462 6.17369 5.59129 6.17369 4.27961C6.17369 2.96793 5.11036 1.9046 3.79868 1.9046C2.487 1.9046 1.42368 2.96793 1.42368 4.27961C1.42368 5.59129 2.487 6.65462 3.79868 6.65462Z" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.79074 3.74463C6.79074 3.43666 7.0404 3.187 7.34838 3.187C7.93704 3.187 8.52062 3.29642 9.06606 3.5097C9.61153 3.723 10.1092 4.0364 10.5298 4.43348C10.9505 4.83062 11.286 5.30385 11.5156 5.82705C11.7452 6.35035 11.8639 6.91244 11.8639 7.48093C11.8639 7.7889 11.6142 8.03856 11.3062 8.03856C10.9983 8.03856 10.7486 7.7889 10.7486 7.48093C10.7486 7.06811 10.6625 6.65849 10.4943 6.27517C10.3261 5.89175 10.0786 5.54121 9.76421 5.24446C9.4498 4.94765 9.07481 4.71062 8.65991 4.54838C8.24496 4.38613 7.79922 4.30227 7.34838 4.30227C7.0404 4.30227 6.79074 4.05261 6.79074 3.74463Z" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.79868 11.942C4.49442 11.942 5.05843 11.378 5.05843 10.6822C5.05843 9.98651 4.49442 9.42251 3.79868 9.42251C3.10295 9.42251 2.53894 9.98651 2.53894 10.6822C2.53894 11.378 3.10295 11.942 3.79868 11.942ZM3.79868 13.0573C5.11036 13.0573 6.17369 11.9939 6.17369 10.6822C6.17369 9.37057 5.11036 8.30724 3.79868 8.30724C2.487 8.30724 1.42368 9.37057 1.42368 10.6822C1.42368 11.9939 2.487 13.0573 3.79868 13.0573Z" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.7808 9.61368H9.81307C9.47678 9.61368 9.29277 9.61457 9.16063 9.62555C9.15546 9.62598 9.15056 9.62641 9.14592 9.62684C9.14549 9.63148 9.14506 9.63638 9.14463 9.64155C9.13365 9.77368 9.13276 9.9577 9.13276 10.294V11.2617C9.13276 11.598 9.13365 11.782 9.14463 11.9141C9.14506 11.9193 9.14549 11.9242 9.14592 11.9288C9.15056 11.9292 9.15546 11.9297 9.16063 11.9301C9.29277 11.9411 9.47678 11.942 9.81307 11.942H10.7808C11.117 11.942 11.3011 11.9411 11.4332 11.9301C11.4384 11.9297 11.4433 11.9292 11.4479 11.9288C11.4483 11.9242 11.4488 11.9193 11.4492 11.9141C11.4602 11.782 11.4611 11.598 11.4611 11.2617V10.294C11.4611 9.9577 11.4602 9.77368 11.4492 9.64155C11.4488 9.63637 11.4483 9.63148 11.4479 9.62684C11.4433 9.62641 11.4384 9.62598 11.4332 9.62555C11.3011 9.61457 11.117 9.61368 10.7808 9.61368ZM8.14306 9.09957C8.01749 9.34129 8.01749 9.65886 8.01749 10.294V11.2617C8.01749 11.8968 8.01749 12.2144 8.14306 12.4561C8.24887 12.6598 8.41495 12.8259 8.61865 12.9317C8.86037 13.0572 9.17794 13.0573 9.81307 13.0573H10.7808C11.4159 13.0573 11.7335 13.0572 11.9752 12.9317C12.1789 12.8259 12.345 12.6598 12.4508 12.4561C12.5763 12.2144 12.5763 11.8968 12.5763 11.2617V10.294C12.5763 9.65886 12.5763 9.34129 12.4508 9.09957C12.345 8.89587 12.1789 8.72979 11.9752 8.62398C11.7335 8.49841 11.4159 8.49841 10.7808 8.49841H9.81307C9.17794 8.49841 8.86037 8.49841 8.61865 8.62398C8.41495 8.72979 8.24887 8.89587 8.14306 9.09957Z" />
</svg>

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none">
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.66666 3.33333C6.66666 2.59695 7.26361 2 7.99999 2C8.73637 2 9.33332 2.59695 9.33332 3.33333C9.33332 4.06971 8.73637 4.66667 7.99999 4.66667C7.26361 4.66667 6.66666 4.06971 6.66666 3.33333ZM6.66666 8C6.66666 7.26362 7.26361 6.66667 7.99999 6.66667C8.73637 6.66667 9.33332 7.26362 9.33332 8C9.33332 8.73638 8.73637 9.33333 7.99999 9.33333C7.26361 9.33333 6.66666 8.73638 6.66666 8ZM6.66666 12.6667C6.66666 11.9303 7.26361 11.3333 7.99999 11.3333C8.73637 11.3333 9.33332 11.9303 9.33332 12.6667C9.33332 13.403 8.73637 14 7.99999 14C7.26361 14 6.66666 13.403 6.66666 12.6667Z" />
</svg>

After

Width:  |  Height:  |  Size: 709 B

View File

@@ -11,6 +11,7 @@ import {
import MyIcon from '../Icon';
import MyDivider from '../MyDivider';
import type { IconNameType } from '../Icon/type';
import { useSystem } from '../../../hooks/useSystem';
export type MenuItemType = 'primary' | 'danger';
@@ -77,10 +78,14 @@ const MyMenu = ({
alignItems: 'center',
fontSize: 'sm'
};
const { isPc } = useSystem();
const ref = useRef<HTMLDivElement>(null);
const closeTimer = useRef<any>();
const [isOpen, setIsOpen] = useState(false);
const formatTrigger = !isPc ? 'click' : trigger;
useOutsideClick({
ref: ref,
handler: () => {
@@ -103,17 +108,18 @@ const MyMenu = ({
isLazy
lazyBehavior={'keepMounted'}
placement="bottom-start"
computePositionOnMount
>
<Box
ref={ref}
onMouseEnter={() => {
if (trigger === 'hover') {
if (formatTrigger === 'hover') {
setIsOpen(true);
}
clearTimeout(closeTimer.current);
}}
onMouseLeave={() => {
if (trigger === 'hover') {
if (formatTrigger === 'hover') {
closeTimer.current = setTimeout(() => {
setIsOpen(false);
}, 100);
@@ -124,7 +130,7 @@ const MyMenu = ({
position={'relative'}
onClickCapture={(e) => {
e.stopPropagation();
if (trigger === 'click') {
if (formatTrigger === 'click') {
setIsOpen(!isOpen);
}
}}

View File

@@ -0,0 +1,7 @@
import { useMediaQuery } from '@chakra-ui/react';
export const useSystem = () => {
const [isPc] = useMediaQuery('(min-width: 900px)');
return { isPc };
};

View File

@@ -1128,8 +1128,8 @@
"Create Folder": "Create Folder",
"Create manual collection": "Create manual collection",
"Delete Dataset Error": "Delete Dataset Error",
"Edit Info": "Edit Information",
"Edit Folder": "Edit Folder",
"Edit Info": "Edit Information",
"Export": "Export",
"Export Dataset Limit Error": "Export Dataset Error",
"File Input": "File Input",
@@ -1220,6 +1220,7 @@
"Module": "Module",
"Plugin": "Plugin",
"Store": "App Store",
"Studio": "Studio",
"Tools": "Tools"
},
"permission": {

View File

@@ -1137,8 +1137,8 @@
"Create Folder": "创建文件夹",
"Create manual collection": "创建手动数据集",
"Delete Dataset Error": "删除知识库异常",
"Edit Info": "编辑信息",
"Edit Folder": "编辑文件夹",
"Edit Info": "编辑信息",
"Export": "导出",
"Export Dataset Limit Error": "导出数据失败",
"File Input": "文件导入",
@@ -1229,6 +1229,7 @@
"Module": "模块",
"Plugin": "插件",
"Store": "应用市场",
"Studio": "工作台",
"Tools": "工具"
},
"permission": {

20500
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -34,7 +34,7 @@ const Navbar = ({ unread }: { unread: number }) => {
activeLink: ['/chat']
},
{
label: t('navbar.Apps'),
label: t('navbar.Studio'),
icon: 'core/app/aiLight',
activeIcon: 'core/app/aiFill',
link: `/app/list`,

View File

@@ -21,7 +21,7 @@ const NavbarPhone = ({ unread }: { unread: number }) => {
unread: 0
},
{
label: t('navbar.Apps'),
label: t('navbar.Studio'),
icon: 'core/app/aiLight',
activeIcon: 'core/app/aiFill',
link: `/app/list`,

View File

@@ -20,6 +20,7 @@ const PageContainer = ({
overflow={'overlay'}
bg={'myGray.25'}
borderRadius={[0, '16px']}
overflowX={'hidden'}
{...insertProps}
>
{children}

View File

@@ -32,7 +32,7 @@ const PermissionIconText = ({
return PermissionTypeMap[per] ? (
<Flex alignItems={'center'} fontSize={fontSize} {...props}>
<MyIcon name={PermissionTypeMap[per]?.iconLight as any} w={w} />
<Box ml={'2px'} lineHeight={1} fontSize={'xs'}>
<Box ml={'2px'} lineHeight={1}>
{t(PermissionTypeMap[per]?.label)}
</Box>
</Flex>

View File

@@ -63,7 +63,7 @@ const Account = () => {
useQuery(['init'], initUserInfo);
return (
<Box py={[3, '28px']} px={['5vw', '64px']}>
<Box py={[3, '28px']} maxW={['95vw', '1080px']} px={[5, 10]} mx={'auto'}>
{isPc ? (
<Flex justifyContent={'center'}>
<Box flex={'0 0 330px'}>

View File

@@ -170,7 +170,7 @@ const Account = ({ currentTab }: { currentTab: TabEnum }) => {
</Box>
)}
<Box flex={'1 0 0'} h={'100%'} pb={[4, 0]}>
<Box flex={'1 0 0'} h={'100%'} pb={[4, 0]} overflow={'auto'}>
{currentTab === TabEnum.info && <UserInfo />}
{currentTab === TabEnum.promotion && <Promotion />}
{currentTab === TabEnum.usage && <UsageTable />}

View File

@@ -6,6 +6,7 @@ import { NextAPI } from '@/service/middleware/entry';
import { PluginTypeEnum } from '@fastgpt/global/core/plugin/constants';
import { mongoSessionRun } from '@fastgpt/service/common/mongo/sessionRun';
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
import { MongoAppVersion } from '@fastgpt/service/core/app/version/schema';
/*
1. 先读取 HTTP plugin 内容,并找到所有的子plugin,然后事务批量创建,最后修改 inited
@@ -16,19 +17,22 @@ let success = 0;
async function handler(req: NextApiRequest, res: NextApiResponse) {
await authCert({ req, authRoot: true });
const { teamId } = req.body as { teamId?: string };
const total = await MongoPlugin.countDocuments({
inited: { $ne: true }
});
console.log('Total plugin', total);
await initHttp();
await initPlugin();
await initHttp(teamId);
await initPlugin(teamId);
}
async function initHttp(): Promise<any> {
async function initHttp(teamId?: string): Promise<any> {
/* 读取http插件和他的children */
const plugin = await MongoPlugin.findOne({
...(teamId && { teamId }),
type: PluginTypeEnum.folder,
inited: { $ne: true }
}).lean();
@@ -52,7 +56,7 @@ async function initHttp(): Promise<any> {
avatar: plugin.avatar,
intro: plugin.intro,
metadata: plugin.metadata,
version: 'v2',
version: plugin.version,
pluginData: {
apiSchemaStr: plugin.metadata?.apiSchemaStr,
customHeaders: plugin.metadata?.customHeaders
@@ -64,9 +68,10 @@ async function initHttp(): Promise<any> {
/* 批量创建子插件 */
for await (const item of children) {
await MongoApp.create(
const [{ _id: newPluginId }] = await MongoApp.create(
[
{
_id: item._id,
parentId: _id,
teamId: item.teamId,
tmbId: item.tmbId,
@@ -74,7 +79,7 @@ async function initHttp(): Promise<any> {
name: item.name,
avatar: item.avatar,
intro: item.intro,
version: 'v2',
version: plugin.version,
modules: item.modules,
edges: item.edges,
pluginData: {
@@ -85,6 +90,18 @@ async function initHttp(): Promise<any> {
],
{ session }
);
if (item.version === 'v2') {
await MongoAppVersion.create(
[
{
appId: newPluginId,
nodes: item.modules,
edges: item.edges
}
],
{ session }
);
}
}
/* 更新插件信息 */
@@ -115,24 +132,26 @@ async function initHttp(): Promise<any> {
return initHttp();
}
async function initPlugin(): Promise<any> {
async function initPlugin(teamId?: string): Promise<any> {
const plugin = await MongoPlugin.findOne({
...(teamId && { teamId }),
type: PluginTypeEnum.custom,
inited: { $ne: true }
}).lean();
if (!plugin) return;
await mongoSessionRun(async (session) => {
await MongoApp.create(
const [{ _id: newPluginId }] = await MongoApp.create(
[
{
_id: plugin._id,
teamId: plugin.teamId,
tmbId: plugin.tmbId,
type: AppTypeEnum.plugin,
name: plugin.name,
avatar: plugin.avatar,
intro: plugin.intro,
version: 'v2',
version: plugin.version,
modules: plugin.modules,
edges: plugin.edges,
pluginData: {
@@ -143,6 +162,19 @@ async function initPlugin(): Promise<any> {
{ session }
);
if (plugin.version === 'v2') {
await MongoAppVersion.create(
[
{
appId: newPluginId,
nodes: plugin.modules,
edges: plugin.edges
}
],
{ session }
);
}
await MongoPlugin.findOneAndUpdate(
{
_id: plugin._id

View File

@@ -9,6 +9,7 @@ import { DatasetSourceReadTypeEnum } from '@fastgpt/global/core/dataset/constant
import { readDatasetSourceRawText } from '@fastgpt/service/core/dataset/read';
import { ApiRequestProps } from '@fastgpt/service/type/next';
import { authCert } from '@fastgpt/service/support/permission/auth/common';
import { OwnerPermissionVal } from '@fastgpt/global/support/permission/constant';
export type PreviewContextProps = {
type: DatasetSourceReadTypeEnum;
@@ -26,7 +27,13 @@ async function handler(req: ApiRequestProps<PreviewContextProps>, res: NextApiRe
const { teamId } = await (async () => {
if (type === DatasetSourceReadTypeEnum.fileLocal) {
return authFile({ req, authToken: true, authApiKey: true, fileId: sourceId });
return authFile({
req,
authToken: true,
authApiKey: true,
fileId: sourceId,
per: OwnerPermissionVal
});
}
return authCert({ req, authApiKey: true, authToken: true });
})();

View File

@@ -69,7 +69,10 @@ async function handler(
/* temp: get all apps and per */
const [myApps, rpList] = await Promise.all([
MongoApp.find(findAppsQuery, '_id avatar type name intro tmbId pluginData defaultPermission')
MongoApp.find(
findAppsQuery,
'_id avatar type name intro tmbId updateTime pluginData defaultPermission'
)
.sort({
updateTime: -1
})
@@ -101,10 +104,12 @@ async function handler(
return sliceApps.map((app) => ({
_id: app._id,
tmbId: app.tmbId,
avatar: app.avatar,
type: app.type,
name: app.name,
intro: app.intro,
updateTime: app.updateTime,
permission: app.permission,
defaultPermission: app.defaultPermission || AppDefaultPermissionVal,
pluginData: app.pluginData

View File

@@ -48,7 +48,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse<any>) {
...(type && { type }),
...(avatar && { avatar }),
...(intro !== undefined && { intro }),
...(defaultPermission && { defaultPermission }),
...(defaultPermission !== undefined && { defaultPermission }),
...(teamTags && { teamTags }),
...(formatNodes && {
modules: formatNodes

View File

@@ -1,14 +0,0 @@
import type { NextApiRequest } from 'next';
import { authDatasetFile } from '@fastgpt/service/support/permission/dataset/auth';
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
import { NextAPI } from '@/service/middleware/entry';
async function handler(req: NextApiRequest) {
const { fileId } = req.query as { fileId: string };
// 凭证校验
const { file } = await authDatasetFile({ req, authToken: true, fileId, per: ReadPermissionVal });
return file;
}
export default NextAPI(handler);

View File

@@ -1,10 +1,10 @@
import { authDatasetFile } from '@fastgpt/service/support/permission/dataset/auth';
import { DatasetSourceReadTypeEnum } from '@fastgpt/global/core/dataset/constants';
import { rawText2Chunks, readDatasetSourceRawText } from '@fastgpt/service/core/dataset/read';
import { authCert } from '@fastgpt/service/support/permission/auth/common';
import { NextAPI } from '@/service/middleware/entry';
import { ApiRequestProps } from '@fastgpt/service/type/next';
import { ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
import { OwnerPermissionVal, ReadPermissionVal } from '@fastgpt/global/support/permission/constant';
import { authFile } from '@fastgpt/service/support/permission/auth/file';
export type PostPreviewFilesChunksProps = {
type: DatasetSourceReadTypeEnum;
@@ -35,12 +35,12 @@ async function handler(
const { teamId } = await (async () => {
if (type === DatasetSourceReadTypeEnum.fileLocal) {
return authDatasetFile({
return authFile({
req,
authToken: true,
authApiKey: true,
fileId: sourceId,
per: ReadPermissionVal
per: OwnerPermissionVal
});
}
return authCert({ req, authApiKey: true, authToken: true });

View File

@@ -11,12 +11,14 @@ import {
ReadPermissionVal
} from '@fastgpt/global/support/permission/constant';
import { MongoResourcePermission } from '@fastgpt/service/support/permission/schema';
import { DatasetDefaultPermission } from '@fastgpt/global/support/permission/dataset/constant';
import { DatasetDefaultPermissionVal } from '@fastgpt/global/support/permission/dataset/constant';
import { ParentIdType } from '@fastgpt/global/common/parentFolder/type';
import { parseParentIdInMongo } from '@fastgpt/global/common/parentFolder/utils';
export type GetDatasetListBody = { parentId: ParentIdType; type?: DatasetTypeEnum };
async function handler(req: NextApiRequest) {
const { parentId, type } = req.body as { parentId: ParentIdType; type?: DatasetTypeEnum };
const { parentId, type } = req.body as GetDatasetListBody;
// 凭证校验
const {
teamId,
@@ -28,18 +30,6 @@ async function handler(req: NextApiRequest) {
authApiKey: true,
per: ReadPermissionVal
});
console.log(
'parentId',
parentId,
'type',
type,
'teamId',
teamId,
'tmbId',
tmbId,
'tmbPer',
tmbPer
);
const [myDatasets, rpList] = await Promise.all([
MongoDataset.find({
@@ -85,7 +75,7 @@ async function handler(req: NextApiRequest) {
type: item.type,
permission: item.permission,
vectorModel: getVectorModel(item.vectorModel),
defaultPermission: item.defaultPermission ?? DatasetDefaultPermission
defaultPermission: item.defaultPermission ?? DatasetDefaultPermissionVal
}))
);

View File

@@ -48,7 +48,7 @@ async function handler(req: NextApiRequest) {
...(status && { status }),
...(intro && { intro }),
...(externalReadUrl && { externalReadUrl }),
defaultPermission
...(defaultPermission !== undefined && { defaultPermission })
}
);
}

View File

@@ -34,10 +34,16 @@ const SelectDatasetRender = ({ inputs = [], item, nodeId }: RenderInputProps) =>
onClose: onCloseDatasetSelect
} = useDisclosure();
const selectedDatasetsValue = useMemo(() => {
if (Array.isArray(item.value)) return item.value as SelectedDatasetType;
return [] as SelectedDatasetType;
}, [item.value]);
const selectedDatasets = useMemo(() => {
const value = item.value as SelectedDatasetType;
return allDatasets.filter((dataset) => value?.find((item) => item.datasetId === dataset._id));
}, [allDatasets, item.value]);
return allDatasets.filter((dataset) =>
selectedDatasetsValue?.find((item) => item.datasetId === dataset._id)
);
}, [allDatasets, selectedDatasetsValue]);
useQuery(['loadAllDatasets'], loadAllDatasets);
@@ -95,7 +101,7 @@ const SelectDatasetRender = ({ inputs = [], item, nodeId }: RenderInputProps) =>
{isOpenDatasetSelect && (
<DatasetSelectModal
isOpen={isOpenDatasetSelect}
defaultSelectedDatasets={item.value}
defaultSelectedDatasets={selectedDatasetsValue}
onChange={(e) => {
onChangeNode({
nodeId,
@@ -120,6 +126,7 @@ const SelectDatasetRender = ({ inputs = [], item, nodeId }: RenderInputProps) =>
onCloseDatasetSelect,
onOpenDatasetSelect,
selectedDatasets,
selectedDatasetsValue,
t,
theme.borders.base
]);

View File

@@ -515,18 +515,16 @@ const WorkflowContextProvider = ({
const { nodes } = await getWorkflowStore();
// version preview / debug mode, not save
if (
appDetail.version !== 'v2' ||
historiesDefaultData ||
isSaving ||
nodes.length === 0 ||
edges.length === 0 ||
!!workflowDebugData
)
if (appDetail.version !== 'v2' || historiesDefaultData || isSaving || !!workflowDebugData)
return;
const storeWorkflow = uiWorkflow2StoreWorkflow({ nodes, edges });
// check valid
if (storeWorkflow.nodes.length === 0 || storeWorkflow.edges.length === 0) {
return;
}
try {
await updateAppDetail({
...storeWorkflow,

View File

@@ -1,5 +1,5 @@
import React, { useMemo, useState } from 'react';
import { Box, Grid, Flex, IconButton } from '@chakra-ui/react';
import { Box, Grid, Flex, IconButton, HStack } from '@chakra-ui/react';
import { useRouter } from 'next/router';
import { delAppById, putAppById } from '@/web/core/app/api';
import { useConfirm } from '@fastgpt/web/hooks/useConfirm';
@@ -28,20 +28,22 @@ import {
postUpdateAppCollaborators
} from '@/web/core/app/api/collaborator';
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
import AppTypeTag from '@/components/core/app/TypeTag';
import AppTypeTag from '@/pages/app/list/components/TypeTag';
const EditResourceModal = dynamic(() => import('@/components/common/Modal/EditResourceModal'));
const ConfigPerModal = dynamic(() => import('@/components/support/permission/ConfigPerModal'));
import type { EditHttpPluginProps } from './HttpPluginEditModal';
import { postCopyApp } from '@/web/core/app/api/app';
import { getTeamMembers } from '@/web/support/user/team/api';
import { formatTimeToChatTime } from '@fastgpt/global/common/string/time';
const HttpEditModal = dynamic(() => import('./HttpPluginEditModal'));
const ListItem = () => {
const { t } = useTranslation();
const { appT } = useI18n();
const router = useRouter();
const { myApps, loadMyApps, onUpdateApp, setMoveAppId, folderDetail, parentId } =
const { myApps, loadMyApps, onUpdateApp, setMoveAppId, folderDetail, appType } =
useContextSelector(AppListContext, (v) => v);
const [loadingAppId, setLoadingAppId] = useState<string>();
@@ -94,6 +96,10 @@ const ListItem = () => {
successToast: appT('Create copy success')
});
const { data: members = [] } = useRequest2(getTeamMembers, {
manual: false
});
return (
<>
<Grid
@@ -102,196 +108,221 @@ const ListItem = () => {
gridGap={5}
alignItems={'stretch'}
>
{myApps.map((app, index) => (
<MyTooltip
key={app._id}
h="100%"
label={
app.type === AppTypeEnum.folder
? t('common.folder.Open folder')
: app.permission.hasWritePer
? appT('Edit app')
: appT('Go to chat')
}
>
<MyBox
isLoading={loadingAppId === app._id}
lineHeight={1.5}
{myApps.map((app, index) => {
const owner = members.find((v) => v.tmbId === app.tmbId);
return (
<MyTooltip
key={app._id}
h="100%"
py={3}
px={5}
cursor={'pointer'}
border={'base'}
boxShadow={'2'}
bg={'white'}
borderRadius={'md'}
userSelect={'none'}
position={'relative'}
display={'flex'}
flexDirection={'column'}
_hover={{
borderColor: 'primary.300',
boxShadow: '1.5',
'& .more': {
display: 'flex'
},
'& .chat': {
display: 'flex'
}
}}
onClick={() => {
if (app.type === AppTypeEnum.folder || app.type === AppTypeEnum.httpPlugin) {
router.push({
query: {
...router.query,
parentId: app._id
}
});
} else if (app.permission.hasWritePer) {
router.push(`/app/detail?appId=${app._id}`);
} else {
router.push(`/chat?appId=${app._id}`);
}
}}
{...getBoxProps({
dataId: app._id,
isFolder: app.type === AppTypeEnum.folder
})}
label={
app.type === AppTypeEnum.folder
? t('common.folder.Open folder')
: app.permission.hasWritePer
? appT('Edit app')
: appT('Go to chat')
}
>
<Flex alignItems={'center'} h={'38px'}>
<Avatar src={app.avatar} borderRadius={'md'} w={'28px'} />
<Box ml={3}>{app.name}</Box>
{app.permission.hasManagePer && (
<Box
className="more"
position={'absolute'}
top={3.5}
right={4}
display={['', 'none']}
>
<MyMenu
Button={
<IconButton
size={'xsSquare'}
variant={'transparentBase'}
icon={<MyIcon name={'more'} w={'1rem'} />}
aria-label={''}
/>
<MyBox
isLoading={loadingAppId === app._id}
lineHeight={1.5}
h="100%"
pt={4}
pb={3}
px={5}
cursor={'pointer'}
border={'base'}
boxShadow={'2'}
bg={'white'}
borderRadius={'md'}
userSelect={'none'}
position={'relative'}
display={'flex'}
flexDirection={'column'}
_hover={{
borderColor: 'primary.300',
boxShadow: '1.5',
'& .more': {
display: 'flex'
},
'& .time': {
display: ['flex', 'none']
}
}}
onClick={() => {
if (app.type === AppTypeEnum.folder || app.type === AppTypeEnum.httpPlugin) {
router.push({
query: {
...router.query,
parentId: app._id
}
menuList={[
{
children: [
});
} else if (app.permission.hasWritePer) {
router.push(`/app/detail?appId=${app._id}`);
} else {
router.push(`/chat?appId=${app._id}`);
}
}}
{...getBoxProps({
dataId: app._id,
isFolder: app.type === AppTypeEnum.folder
})}
>
{/* <Box position={'absolute'} top={3.5} right={0}>
<AppTypeTag type={app.type} />
</Box> */}
<HStack>
<Avatar src={app.avatar} borderRadius={'md'} w={'1.3rem'} />
<Box flex={'1'} wordBreak={'break-all'}>
{app.name}
</Box>
<Box alignSelf={'flex-start'} mr={'-1.25rem'}>
<AppTypeTag type={app.type} />
</Box>
</HStack>
<Box
flex={'1'}
className={'textEllipsis3'}
my={2}
wordBreak={'break-all'}
fontSize={'mini'}
color={'myGray.600'}
minH={'32px'}
>
{app.intro || '还没写介绍~'}
</Box>
<Flex
h={'24px'}
alignItems={'center'}
justifyContent={'space-between'}
fontSize={'mini'}
color={'myGray.500'}
>
<HStack spacing={3.5}>
{/* {owner && (
<HStack spacing={1}>
<Avatar src={owner.avatar} w={'0.9rem'} />
<Box maxW={'150px'} className="textEllipsis">
{owner.memberName}
</Box>
</HStack>
)} */}
<PermissionIconText defaultPermission={app.defaultPermission} />
</HStack>
<HStack>
{/* <HStack spacing={0.5} className="time">
<MyIcon name={'history'} w={'0.85rem'} />
<Box>{formatTimeToChatTime(app.updateTime)}</Box>
</HStack> */}
{app.permission.hasManagePer && (
<Box className="more" display={['', 'none']}>
<MyMenu
Button={
<IconButton
size={'xsSquare'}
variant={'transparentBase'}
icon={<MyIcon name={'more'} w={'0.8rem'} />}
aria-label={''}
/>
}
menuList={[
{
icon: 'edit',
label: '编辑信息',
onClick: () => {
if (app.type === AppTypeEnum.httpPlugin) {
setEditHttpPlugin({
id: app._id,
name: app.name,
avatar: app.avatar,
intro: app.intro,
pluginData: app.pluginData
});
} else {
setEditedApp({
id: app._id,
avatar: app.avatar,
name: app.name,
intro: app.intro
});
}
}
},
...(folderDetail?.type === AppTypeEnum.httpPlugin
? []
: [
{
icon: 'common/file/move',
label: t('common.folder.Move to'),
onClick: () => setMoveAppId(app._id)
children: [
{
icon: 'edit',
label: '编辑信息',
onClick: () => {
if (app.type === AppTypeEnum.httpPlugin) {
setEditHttpPlugin({
id: app._id,
name: app.name,
avatar: app.avatar,
intro: app.intro,
pluginData: app.pluginData
});
} else {
setEditedApp({
id: app._id,
avatar: app.avatar,
name: app.name,
intro: app.intro
});
}
}
]),
...(app.permission.hasManagePer
},
...(folderDetail?.type === AppTypeEnum.httpPlugin
? []
: [
{
icon: 'common/file/move',
label: t('common.folder.Move to'),
onClick: () => setMoveAppId(app._id)
}
]),
...(app.permission.hasManagePer
? [
{
icon: 'support/team/key',
label: t('permission.Permission'),
onClick: () => setEditPerAppIndex(index)
}
]
: [])
]
},
{
children: [
{
icon: 'copy',
label: appT('Copy one app'),
onClick: () =>
openConfirmCopy(() => onclickCopy({ appId: app._id }))()
}
]
},
{
children: [
{
icon: 'core/chat/chatLight',
label: appT('Go to chat'),
onClick: () => {
router.push(`/chat?appId=${app._id}`);
}
}
]
},
...(app.permission.isOwner
? [
{
icon: 'support/team/key',
label: t('permission.Permission'),
onClick: () => setEditPerAppIndex(index)
children: [
{
type: 'danger' as 'danger',
icon: 'delete',
label: t('common.Delete'),
onClick: () =>
openConfirmDel(
() => onclickDelApp(app._id),
undefined,
app.type === AppTypeEnum.folder
? appT('Confirm delete folder tip')
: appT('Confirm Del App Tip')
)()
}
]
}
]
: [])
]
},
{
children: [
{
icon: 'copy',
label: appT('Copy one app'),
onClick: () =>
openConfirmCopy(() => onclickCopy({ appId: app._id }))()
}
]
},
{
children: [
{
icon: 'core/chat/chatLight',
label: appT('Go to chat'),
onClick: () => {
router.push(`/chat?appId=${app._id}`);
}
}
]
},
...(app.permission.isOwner
? [
{
children: [
{
type: 'danger' as 'danger',
icon: 'delete',
label: t('common.Delete'),
onClick: () =>
openConfirmDel(
() => onclickDelApp(app._id),
undefined,
app.type === AppTypeEnum.folder
? appT('Confirm delete folder tip')
: appT('Confirm Del App Tip')
)()
}
]
}
]
: [])
]}
/>
</Box>
)}
</Flex>
<Box
flex={1}
className={'textEllipsis3'}
py={2}
wordBreak={'break-all'}
fontSize={'mini'}
color={'myGray.600'}
>
{app.intro || '还没写介绍~'}
</Box>
<Flex h={'34px'} alignItems={'flex-end'}>
<Box flex={1}>
<PermissionIconText
defaultPermission={app.defaultPermission}
color={'myGray.600'}
/>
</Box>
<AppTypeTag type={app.type} />
</Flex>
</MyBox>
</MyTooltip>
))}
]}
/>
</Box>
)}
</HStack>
</Flex>
</MyBox>
</MyTooltip>
);
})}
</Grid>
{myApps.length === 0 && <EmptyTip text={'还没有应用,快去创建一个吧!'} pt={'30vh'} />}

View File

@@ -3,7 +3,7 @@ import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
import MyTag from '@fastgpt/web/components/common/Tag/index';
import { useI18n } from '@/web/context/I18n';
import MyIcon from '@fastgpt/web/components/common/Icon';
import { Box } from '@chakra-ui/react';
import { Box, Flex } from '@chakra-ui/react';
const AppTypeTag = ({ type }: { type: AppTypeEnum }) => {
const { appT } = useI18n();
@@ -11,19 +11,27 @@ const AppTypeTag = ({ type }: { type: AppTypeEnum }) => {
const map = useRef({
[AppTypeEnum.simple]: {
label: appT('type.Simple bot'),
icon: 'core/app/type/simple'
icon: 'core/app/type/simple',
bg: '#DBF3FF',
color: '#0884DD'
},
[AppTypeEnum.workflow]: {
label: appT('type.Workflow bot'),
icon: 'core/app/type/workflow'
icon: 'core/app/type/workflow',
bg: '#E4E1FC',
color: '#6F5DD7'
},
[AppTypeEnum.plugin]: {
label: appT('type.Plugin'),
icon: 'core/app/type/plugin'
icon: 'core/app/type/plugin',
bg: '#D0F5EE',
color: '#007E7C'
},
[AppTypeEnum.httpPlugin]: {
label: appT('type.Http plugin'),
icon: 'core/app/type/httpPlugin'
icon: 'core/app/type/httpPlugin',
bg: '#FFE4EE',
color: '#E82F72'
},
[AppTypeEnum.folder]: undefined
});
@@ -31,12 +39,20 @@ const AppTypeTag = ({ type }: { type: AppTypeEnum }) => {
const data = map.current[type];
return data ? (
<MyTag type="borderFill" colorSchema="gray">
<MyIcon name={data.icon as any} w={'0.8rem'} color={'myGray.500'} />
<Flex
bg={data.bg}
color={data.color}
py={0.5}
pl={2}
pr={2}
borderLeftRadius={'md'}
whiteSpace={'nowrap'}
>
<MyIcon name={data.icon as any} w={'0.8rem'} />
<Box ml={1} fontSize={'mini'}>
{data.label}
</Box>
</MyTag>
</Flex>
) : null;
};

View File

@@ -11,6 +11,7 @@ import { getErrText } from '@fastgpt/global/common/error/utils';
import { useContextSelector } from 'use-context-selector';
import { DatasetImportContext } from '../Context';
import { importType2ReadType } from '@fastgpt/global/core/dataset/read';
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
const PreviewChunks = ({
previewSource,
@@ -25,9 +26,8 @@ const PreviewChunks = ({
(v) => v
);
const { data = [], isLoading } = useQuery(
['previewSource'],
() => {
const { data = [], loading: isLoading } = useRequest2(
async () => {
if (importSource === ImportDataSourceEnum.fileCustom) {
const customSplitChar = processParamsForm.getValues('customSplitChar');
const { chunks } = splitText2Chunks({
@@ -66,12 +66,7 @@ const PreviewChunks = ({
});
},
{
onError(err) {
toast({
status: 'warning',
title: getErrText(err)
});
}
manual: false
}
);

View File

@@ -26,7 +26,7 @@ import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip';
import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel';
import DefaultPermissionList from '@/components/support/permission/DefaultPerList';
import {
DatasetDefaultPermission,
DatasetDefaultPermissionVal,
DatasetPermissionList
} from '@fastgpt/global/support/permission/dataset/constant';
import MemberManager from '../../component/MemberManager';
@@ -202,10 +202,16 @@ const Info = ({ datasetId }: { datasetId: string }) => {
{datasetDetail.type === DatasetTypeEnum.externalFile && (
<>
<Flex w={'100%'} alignItems={'center'}>
<HStack fontSize={['sm', 'md']} flex={['0 0 90px', '0 0 160px']} w={0}>
<FormLabel
display={'flex'}
flex={['0 0 90px', '0 0 160px']}
w={0}
gap={1}
alignItems={'center'}
>
<Box>{datasetT('External read url')}</Box>
<QuestionTip label={datasetT('External read url tip')} />
</HStack>
</FormLabel>
<Input
flex={[1, '0 0 320px']}
placeholder="https://test.com/read?fileId={{fileId}}"
@@ -246,6 +252,8 @@ const Info = ({ datasetId }: { datasetId: string }) => {
{datasetDetail.permission.hasManagePer && (
<>
<MyDivider my={6} h={'2px'} maxW={'500px'} />
<Flex mt={5} alignItems={'center'} w={'100%'} flexWrap={'wrap'} maxW="500px">
<FormLabel flex={['0 0 90px', '0 0 160px']} w={0}>
{commonT('permission.Default permission')}
@@ -253,7 +261,7 @@ const Info = ({ datasetId }: { datasetId: string }) => {
<DefaultPermissionList
w="320px"
per={defaultPermission}
defaultPer={DatasetDefaultPermission}
defaultPer={DatasetDefaultPermissionVal}
onChange={(v) => setValue('defaultPermission', v)}
/>
</Flex>

View File

@@ -20,7 +20,7 @@ import { MongoImageTypeEnum } from '@fastgpt/global/common/file/image/constants'
import AIModelSelector from '@/components/Select/AIModelSelector';
import { useI18n } from '@/web/context/I18n';
import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip';
import { DatasetDefaultPermission } from '@fastgpt/global/support/permission/dataset/constant';
import { DatasetDefaultPermissionVal } from '@fastgpt/global/support/permission/dataset/constant';
const CreateModal = ({ onClose, parentId }: { onClose: () => void; parentId?: string }) => {
const { t } = useTranslation();
@@ -40,7 +40,7 @@ const CreateModal = ({ onClose, parentId }: { onClose: () => void; parentId?: st
intro: '',
vectorModel: filterNotHiddenVectorModelList[0].model,
agentModel: datasetModelList[0].model,
defaultPermission: DatasetDefaultPermission
defaultPermission: DatasetDefaultPermissionVal
}
});
const avatar = watch('avatar');

View File

@@ -19,9 +19,9 @@ import { downloadFetch } from '@/web/common/system/utils';
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
import dynamic from 'next/dynamic';
import { useContextSelector } from 'use-context-selector';
import { DatasetContext } from '../context';
import { DatasetsContext } from '../context';
import {
DatasetDefaultPermission,
DatasetDefaultPermissionVal,
DatasetPermissionList
} from '@fastgpt/global/support/permission/dataset/constant';
import ConfigPerModal from '@/components/support/permission/ConfigPerModal';
@@ -49,16 +49,17 @@ function List() {
editedDataset,
setEditedDataset,
onDelDataset
} = useContextSelector(DatasetContext, (v) => v);
} = useContextSelector(DatasetsContext, (v) => v);
const [editPerDatasetIndex, setEditPerDatasetIndex] = useState<number>();
const { myDatasets, loadMyDatasets } = useDatasetStore();
const [loadingDatasetId, setLoadingDatasetId] = useState<string>();
const { getBoxProps } = useFolderDrag({
activeStyles: {
borderColor: 'primary.600'
},
onDrop: async (dragId: string, targetId: string) => {
setLoading(true);
setLoadingDatasetId(dragId);
try {
await putDatasetById({
id: dragId,
@@ -66,7 +67,7 @@ function List() {
});
refetchDatasets();
} catch (error) {}
setLoading(false);
setLoadingDatasetId(undefined);
}
});
@@ -160,6 +161,7 @@ function List() {
}
>
<MyBox
isLoading={loadingDatasetId === dataset._id}
display={'flex'}
flexDirection={'column'}
py={3}
@@ -254,18 +256,6 @@ function List() {
label: t('Move'),
onClick: () => setMoveDatasetId(dataset._id)
},
...(dataset.type != DatasetTypeEnum.folder
? [
{
icon: 'export',
label: t('Export'),
onClick: () => {
exportDataset(dataset);
}
}
]
: []),
...(dataset.permission.hasManagePer
? [
{
@@ -277,6 +267,21 @@ function List() {
: [])
]
},
...(dataset.type != DatasetTypeEnum.folder
? [
{
children: [
{
icon: 'export',
label: t('Export'),
onClick: () => {
exportDataset(dataset);
}
}
]
}
]
: []),
...(dataset.permission.hasManagePer
? [
{
@@ -361,7 +366,7 @@ function List() {
name={editPerDataset.name}
defaultPer={{
value: editPerDataset.defaultPermission,
defaultValue: DatasetDefaultPermission,
defaultValue: DatasetDefaultPermissionVal,
onChange: async (e) => {
await putDatasetById({
id: editPerDataset._id,

View File

@@ -15,13 +15,12 @@ import { useRouter } from 'next/router';
import React, { useCallback, useState } from 'react';
import { createContext } from 'use-context-selector';
import { useI18n } from '@/web/context/I18n';
import { useRequest, useRequest2 } from '@fastgpt/web/hooks/useRequest';
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
import { DatasetUpdateBody } from '@fastgpt/global/core/dataset/api';
import dynamic from 'next/dynamic';
import { DatasetTypeEnum } from '@fastgpt/global/core/dataset/constants';
import { DatasetItemType } from '@fastgpt/global/core/dataset/type';
import { EditResourceInfoFormType } from '@/components/common/Modal/EditResourceModal';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import { useTranslation } from 'react-i18next';
const MoveModal = dynamic(() => import('@/components/common/folder/MoveModal'));
@@ -39,7 +38,7 @@ export type DatasetContextType = {
onDelDataset: (id: string) => Promise<void>;
};
export const DatasetContext = createContext<DatasetContextType>({
export const DatasetsContext = createContext<DatasetContextType>({
refetchDatasets: () => {},
isFetchingDatasets: false,
setMoveDatasetId: () => {},
@@ -136,7 +135,7 @@ function DatasetContextProvider({ children }: { children: React.ReactNode }) {
};
return (
<DatasetContext.Provider value={contextValue}>
<DatasetsContext.Provider value={contextValue}>
{children}
{!!moveDatasetId && (
<MoveModal
@@ -147,7 +146,7 @@ function DatasetContextProvider({ children }: { children: React.ReactNode }) {
onConfirm={onMoveDataset}
/>
)}
</DatasetContext.Provider>
</DatasetsContext.Provider>
);
}

View File

@@ -7,7 +7,7 @@ import { serviceSideProps } from '@/web/common/utils/i18n';
import ParentPaths from '@/components/common/folder/Path';
import { useDatasetStore } from '@/web/core/dataset/store/dataset';
import List from './component/List';
import { DatasetContext } from './context';
import { DatasetsContext } from './context';
import DatasetContextProvider from './context';
import { useContextSelector } from 'use-context-selector';
import MyMenu from '@fastgpt/web/components/common/MyMenu';
@@ -22,7 +22,7 @@ import { DatasetTypeEnum } from '@fastgpt/global/core/dataset/constants';
import FolderSlideCard from '@/components/common/folder/SlideCard';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import {
DatasetDefaultPermission,
DatasetDefaultPermissionVal,
DatasetPermissionList
} from '@fastgpt/global/support/permission/dataset/constant';
import {
@@ -54,7 +54,7 @@ const Dataset = () => {
setEditedDataset,
setMoveDatasetId,
onDelDataset
} = useContextSelector(DatasetContext, (v) => v);
} = useContextSelector(DatasetsContext, (v) => v);
const { userInfo } = useUserStore();
const [editFolderData, setEditFolderData] = useState<EditFolderFormType>();
@@ -68,11 +68,11 @@ const Dataset = () => {
return (
<PageContainer
isLoading={myDatasets.length === 0 && isFetchingDatasets}
insertProps={{ px: [5, '48px'] }}
insertProps={{ px: folderDetail ? [4, 6] : [5, '10'] }}
>
<Flex pt={[8, 10]} pr={folderDetail ? [4, 6] : [4, 10]}>
<Flex pt={[4, 6]}>
<Flex flexGrow={1} flexDirection="column">
<Flex alignItems={'center'} justifyContent={'space-between'}>
<Flex alignItems={'flex-start'} justifyContent={'space-between'}>
<ParentPaths
paths={paths}
FirstPathDom={
@@ -162,7 +162,7 @@ const Dataset = () => {
}
defaultPer={{
value: folderDetail.defaultPermission,
defaultValue: DatasetDefaultPermission,
defaultValue: DatasetDefaultPermissionVal,
onChange: (e) => {
return putDatasetById({
id: folderDetail._id,

View File

@@ -10,7 +10,7 @@ export const defaultApp: AppDetailType = {
type: AppTypeEnum.simple,
avatar: '/icon/logo.svg',
intro: '',
updateTime: Date.now(),
updateTime: new Date(),
modules: [],
chatConfig: {},
teamId: '',

View File

@@ -49,9 +49,10 @@ import type {
PreviewChunksResponse
} from '@/pages/api/core/dataset/file/getPreviewChunks';
import type { readCollectionSourceResponse } from '@/pages/api/core/dataset/collection/read';
import type { GetDatasetListBody } from '@/pages/api/core/dataset/list';
/* ======================== dataset ======================= */
export const getDatasets = (data: { parentId?: ParentIdType; type?: DatasetTypeEnum }) =>
export const getDatasets = (data: GetDatasetListBody) =>
POST<DatasetListItemType[]>(`/core/dataset/list`, data);
/**

View File

@@ -8,7 +8,7 @@ import type {
DatasetCollectionItemType,
DatasetItemType
} from '@fastgpt/global/core/dataset/type.d';
import { DatasetDefaultPermission } from '@fastgpt/global/support/permission/dataset/constant';
import { DatasetDefaultPermissionVal } from '@fastgpt/global/support/permission/dataset/constant';
import { DatasetPermission } from '@fastgpt/global/support/permission/dataset/controller';
export const defaultDatasetDetail: DatasetItemType = {
@@ -26,7 +26,7 @@ export const defaultDatasetDetail: DatasetItemType = {
permission: new DatasetPermission(),
vectorModel: defaultVectorModels[0],
agentModel: defaultQAModels[0],
defaultPermission: DatasetDefaultPermission
defaultPermission: DatasetDefaultPermissionVal
};
export const defaultCollectionDetail: DatasetCollectionItemType = {
@@ -48,7 +48,7 @@ export const defaultCollectionDetail: DatasetCollectionItemType = {
permission: new DatasetPermission(),
vectorModel: defaultVectorModels[0].model,
agentModel: defaultQAModels[0].model,
defaultPermission: DatasetDefaultPermission
defaultPermission: DatasetDefaultPermissionVal
},
parentId: '',
name: '',