mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-21 19:54:11 +00:00
4.8.5 test fix (#1862)
* app list ui * feat: photo view * perf: app dataset filter * perf: app dataset filter * fix: chat recently apps * perf: workflow header phone * default templates * default templates * fix: input guide phone * fix: i18n * team chat history * remove code * perf: mongo connection * log level
This commit is contained in:
@@ -48,13 +48,15 @@ curl --location --request POST 'https://{{host}}/api/admin/init/485' \
|
||||
2. 新增 - 应用创建副本功能
|
||||
3. 新增 - 应用创建模板
|
||||
4. 新增 - 支持代码运行结果作为工具输出。
|
||||
5. 优化 - 原文件编码存取
|
||||
6. 优化 - 文件夹读取,支持单个文件夹超出 100 个文件
|
||||
7. 优化 - 问答拆分/手动录入,当有`a`字段时,自动将`q`作为补充索引。
|
||||
8. 优化 - 对话框页面代码
|
||||
9. 修复 - SSR渲染
|
||||
10. 优化 - 工作流新节点自动增加序号名
|
||||
11. 修复 - 定时任务无法实际关闭
|
||||
12. 修复 - 输入引导特殊字符导致正则报错
|
||||
13. 修复 - 文件包含特殊字符`%`,且为转义时会导致页面崩溃
|
||||
14. 修复 - 自定义输入选择知识库引用时页面崩溃
|
||||
5. 新增 - Markdown 图片输出,支持移动端放大缩放。
|
||||
6. 优化 - 原文件编码存取
|
||||
7. 优化 - 知识库删除后,简易模式会过滤掉删除的知识库,避免错误判断。
|
||||
8. 优化 - 文件夹读取,支持单个文件夹超出 100 个文件
|
||||
9. 优化 - 问答拆分/手动录入,当有`a`字段时,自动将`q`作为补充索引。
|
||||
10. 优化 - 对话框页面代码
|
||||
11. 修复 - SSR渲染
|
||||
12. 优化 - 工作流新节点自动增加序号名
|
||||
13. 修复 - 定时任务无法实际关闭
|
||||
14. 修复 - 输入引导特殊字符导致正则报错
|
||||
15. 修复 - 文件包含特殊字符`%`,且为转义时会导致页面崩溃
|
||||
16. 修复 - 自定义输入选择知识库引用时页面崩溃
|
@@ -14,6 +14,7 @@ export const NextEntry = ({ beforeCallback = [] }: { beforeCallback?: Promise<an
|
||||
return async function api(req: ApiRequestProps, res: NextApiResponse) {
|
||||
const start = Date.now();
|
||||
addLog.debug(`Request start ${req.url}`);
|
||||
|
||||
try {
|
||||
await Promise.all([withNextCors(req, res), ...beforeCallback]);
|
||||
|
||||
@@ -22,10 +23,15 @@ export const NextEntry = ({ beforeCallback = [] }: { beforeCallback?: Promise<an
|
||||
response = await handler(req, res);
|
||||
}
|
||||
|
||||
// Get request duration
|
||||
const duration = Date.now() - start;
|
||||
if (duration < 2000) {
|
||||
addLog.debug(`Request finish ${req.url}, time: ${duration}ms`);
|
||||
} else {
|
||||
addLog.warn(`Request finish ${req.url}, time: ${duration}ms`);
|
||||
}
|
||||
|
||||
const contentType = res.getHeader('Content-Type');
|
||||
|
||||
addLog.debug(`Request finish ${req.url}, time: ${Date.now() - start}ms`);
|
||||
|
||||
if ((!contentType || contentType === 'application/json') && !res.writableFinished) {
|
||||
return jsonRes(res, {
|
||||
code: 200,
|
||||
|
@@ -3,4 +3,10 @@ import mongoose from 'mongoose';
|
||||
export default mongoose;
|
||||
export * from 'mongoose';
|
||||
|
||||
export const connectionMongo = global.mongodb || mongoose;
|
||||
export const connectionMongo = (() => {
|
||||
if (!global.mongodb) {
|
||||
global.mongodb = mongoose;
|
||||
}
|
||||
|
||||
return global.mongodb;
|
||||
})();
|
||||
|
@@ -1,4 +1,8 @@
|
||||
import mongoose from './index';
|
||||
import { addLog } from '../system/log';
|
||||
import { connectionMongo } from './index';
|
||||
import type { Mongoose } from 'mongoose';
|
||||
|
||||
const maxConnecting = Math.max(30, Number(process.env.DB_MAX_LINK || 20));
|
||||
|
||||
/**
|
||||
* connect MongoDB and init data
|
||||
@@ -8,20 +12,27 @@ export async function connectMongo({
|
||||
afterHook
|
||||
}: {
|
||||
beforeHook?: () => any;
|
||||
afterHook?: () => any;
|
||||
}): Promise<void> {
|
||||
if (global.mongodb) {
|
||||
return;
|
||||
afterHook?: () => Promise<any>;
|
||||
}): Promise<Mongoose> {
|
||||
if (connectionMongo.connection.readyState !== 0) {
|
||||
return connectionMongo;
|
||||
}
|
||||
global.mongodb = mongoose;
|
||||
|
||||
beforeHook && (await beforeHook());
|
||||
beforeHook && beforeHook();
|
||||
|
||||
console.log('mongo start connect');
|
||||
try {
|
||||
mongoose.set('strictQuery', true);
|
||||
const maxConnecting = Math.max(30, Number(process.env.DB_MAX_LINK || 20));
|
||||
await mongoose.connect(process.env.MONGODB_URI as string, {
|
||||
connectionMongo.set('strictQuery', true);
|
||||
|
||||
connectionMongo.connection.on('error', (error) => {
|
||||
console.log('mongo error', error);
|
||||
connectionMongo.disconnect();
|
||||
});
|
||||
connectionMongo.connection.on('disconnected', () => {
|
||||
console.log('mongo disconnected');
|
||||
});
|
||||
|
||||
await connectionMongo.connect(process.env.MONGODB_URI as string, {
|
||||
bufferCommands: true,
|
||||
maxConnecting: maxConnecting,
|
||||
maxPoolSize: maxConnecting,
|
||||
@@ -34,22 +45,17 @@ export async function connectMongo({
|
||||
retryReads: true
|
||||
});
|
||||
|
||||
mongoose.connection.on('error', (error) => {
|
||||
console.log('mongo error', error);
|
||||
global.mongodb?.disconnect();
|
||||
global.mongodb = undefined;
|
||||
});
|
||||
mongoose.connection.on('disconnected', () => {
|
||||
console.log('mongo disconnected');
|
||||
global.mongodb = undefined;
|
||||
});
|
||||
|
||||
console.log('mongo connected');
|
||||
} catch (error) {
|
||||
connectionMongo.disconnect();
|
||||
addLog.error('mongo connect error', error);
|
||||
}
|
||||
|
||||
try {
|
||||
afterHook && (await afterHook());
|
||||
} catch (error) {
|
||||
global.mongodb.disconnect();
|
||||
console.log('error->', 'mongo connect error', error);
|
||||
global.mongodb = undefined;
|
||||
addLog.error('mongo connect after hook error', error);
|
||||
}
|
||||
|
||||
return connectionMongo;
|
||||
}
|
||||
|
@@ -1,3 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="17" height="18" viewBox="0 0 19 20" fill="none">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M13.15 1.98982C12.4865 1.98982 11.8501 2.2534 11.3809 2.72259L3.72259 10.3809C2.94066 11.1628 2.50138 12.2234 2.50138 13.3292C2.50138 14.435 2.94066 15.4955 3.72259 16.2774C4.50451 17.0593 5.56502 17.4986 6.67083 17.4986C7.77664 17.4986 8.83715 17.0593 9.61907 16.2774L17.2774 8.61908C17.6028 8.29364 18.1305 8.29364 18.4559 8.61908C18.7814 8.94452 18.7814 9.47216 18.4559 9.79759L10.7976 17.4559C9.7031 18.5504 8.21866 19.1653 6.67083 19.1653C5.123 19.1653 3.63856 18.5504 2.54407 17.4559C1.44959 16.3614 0.834717 14.877 0.834717 13.3292C0.834717 11.7813 1.44959 10.2969 2.54407 9.20242L10.2024 1.54408C10.9842 0.762333 12.0444 0.323151 13.15 0.323151C14.2556 0.323151 15.3158 0.762332 16.0976 1.54408C16.8793 2.32583 17.3185 3.38611 17.3185 4.49167C17.3185 5.59723 16.8793 6.65751 16.0976 7.43926L8.43092 15.0976C7.96191 15.5666 7.32579 15.8301 6.6625 15.8301C5.99921 15.8301 5.36309 15.5666 4.89407 15.0976C4.42506 14.6286 4.16157 13.9925 4.16157 13.3292C4.16157 12.6659 4.42506 12.0298 4.89407 11.5607L11.9694 4.49373C12.2951 4.16849 12.8227 4.1688 13.1479 4.49443C13.4732 4.82006 13.4729 5.34769 13.1472 5.67294L6.07259 12.7393C5.91635 12.8957 5.82824 13.1081 5.82824 13.3292C5.82824 13.5504 5.91613 13.7626 6.07259 13.9191C6.22904 14.0755 6.44124 14.1634 6.6625 14.1634C6.88376 14.1634 7.09595 14.0755 7.25241 13.9191L14.9191 6.26075C15.3881 5.79159 15.6519 5.15505 15.6519 4.49167C15.6519 3.82814 15.3883 3.19178 14.9191 2.72259C14.4499 2.2534 13.8135 1.98982 13.15 1.98982Z" fill="#485058"/>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 19 20">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M13.15 1.98982C12.4865 1.98982 11.8501 2.2534 11.3809 2.72259L3.72259 10.3809C2.94066 11.1628 2.50138 12.2234 2.50138 13.3292C2.50138 14.435 2.94066 15.4955 3.72259 16.2774C4.50451 17.0593 5.56502 17.4986 6.67083 17.4986C7.77664 17.4986 8.83715 17.0593 9.61907 16.2774L17.2774 8.61908C17.6028 8.29364 18.1305 8.29364 18.4559 8.61908C18.7814 8.94452 18.7814 9.47216 18.4559 9.79759L10.7976 17.4559C9.7031 18.5504 8.21866 19.1653 6.67083 19.1653C5.123 19.1653 3.63856 18.5504 2.54407 17.4559C1.44959 16.3614 0.834717 14.877 0.834717 13.3292C0.834717 11.7813 1.44959 10.2969 2.54407 9.20242L10.2024 1.54408C10.9842 0.762333 12.0444 0.323151 13.15 0.323151C14.2556 0.323151 15.3158 0.762332 16.0976 1.54408C16.8793 2.32583 17.3185 3.38611 17.3185 4.49167C17.3185 5.59723 16.8793 6.65751 16.0976 7.43926L8.43092 15.0976C7.96191 15.5666 7.32579 15.8301 6.6625 15.8301C5.99921 15.8301 5.36309 15.5666 4.89407 15.0976C4.42506 14.6286 4.16157 13.9925 4.16157 13.3292C4.16157 12.6659 4.42506 12.0298 4.89407 11.5607L11.9694 4.49373C12.2951 4.16849 12.8227 4.1688 13.1479 4.49443C13.4732 4.82006 13.4729 5.34769 13.1472 5.67294L6.07259 12.7393C5.91635 12.8957 5.82824 13.1081 5.82824 13.3292C5.82824 13.5504 5.91613 13.7626 6.07259 13.9191C6.22904 14.0755 6.44124 14.1634 6.6625 14.1634C6.88376 14.1634 7.09595 14.0755 7.25241 13.9191L14.9191 6.26075C15.3881 5.79159 15.6519 5.15505 15.6519 4.49167C15.6519 3.82814 15.3883 3.19178 14.9191 2.72259C14.4499 2.2534 13.8135 1.98982 13.15 1.98982Z" />
|
||||
</svg>
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
24
packages/web/components/common/Image/PhotoView.tsx
Normal file
24
packages/web/components/common/Image/PhotoView.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import React from 'react';
|
||||
import { PhotoProvider, PhotoView } from 'react-photo-view';
|
||||
import 'react-photo-view/dist/react-photo-view.css';
|
||||
import { Box, Image, ImageProps } from '@chakra-ui/react';
|
||||
import { useSystem } from '../../../hooks/useSystem';
|
||||
import Loading from '../MyLoading';
|
||||
|
||||
const MyPhotoView = (props: ImageProps) => {
|
||||
const { isPc } = useSystem();
|
||||
return (
|
||||
<PhotoProvider
|
||||
maskOpacity={0.6}
|
||||
bannerVisible={!isPc}
|
||||
photoClosable
|
||||
loadingElement={<Loading fixed={false} />}
|
||||
>
|
||||
<PhotoView src={props.src}>
|
||||
<Image cursor={'pointer'} {...props} />
|
||||
</PhotoView>
|
||||
</PhotoProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export default MyPhotoView;
|
@@ -387,7 +387,7 @@
|
||||
"Speech speed": "语速",
|
||||
"Test Listen": "试听",
|
||||
"Test Listen Text": "你好,这是语音测试,如果你能听到这句话,说明语音播放功能正常",
|
||||
"Web": "浏览器自带(免费)"
|
||||
"Web": "浏览器自带(免费)"
|
||||
},
|
||||
"whisper": {
|
||||
"Auto send": "自动发送",
|
||||
|
@@ -16,7 +16,6 @@
|
||||
"@lexical/selection": "^0.14.5",
|
||||
"@lexical/text": "0.12.6",
|
||||
"@lexical/utils": "0.12.6",
|
||||
"react-hook-form": "7.43.1",
|
||||
"@monaco-editor/react": "^4.6.0",
|
||||
"@tanstack/react-query": "^4.24.10",
|
||||
"ahooks": "^3.7.11",
|
||||
@@ -28,17 +27,19 @@
|
||||
"next-i18next": "15.2.0",
|
||||
"papaparse": "^5.4.1",
|
||||
"react": "18.3.1",
|
||||
"use-context-selector": "^1.4.4",
|
||||
"react-beautiful-dnd": "^13.1.1",
|
||||
"react-day-picker": "^8.7.1",
|
||||
"react-dom": "18.3.1",
|
||||
"react-hook-form": "7.43.1",
|
||||
"react-i18next": "13.5.0",
|
||||
"react-beautiful-dnd": "^13.1.1"
|
||||
"react-photo-view": "^1.2.6",
|
||||
"use-context-selector": "^1.4.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash": "^4.14.191",
|
||||
"@types/papaparse": "^5.3.7",
|
||||
"@types/react": "18.3.0",
|
||||
"@types/react-dom": "18.3.0",
|
||||
"@types/react-beautiful-dnd": "^13.1.8"
|
||||
"@types/react-beautiful-dnd": "^13.1.8",
|
||||
"@types/react-dom": "18.3.0"
|
||||
}
|
||||
}
|
||||
|
18528
pnpm-lock.yaml
generated
18528
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
15
projects/app/public/imgs/app/avatar/httpPlugin.svg
Normal file
15
projects/app/public/imgs/app/avatar/httpPlugin.svg
Normal file
@@ -0,0 +1,15 @@
|
||||
<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="28" height="28" rx="6" fill="url(#paint0_linear_6365_1422)"/>
|
||||
<g clip-path="url(#clip0_6365_1422)">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.62256 15.2352C4.62256 18.2369 6.94193 20.6969 9.8863 20.9208V20.931H10.0517C10.1422 20.9353 10.2332 20.9374 10.3248 20.9374C10.4163 20.9374 10.5074 20.9353 10.5979 20.931H18.0737C18.1588 20.9353 18.2445 20.9374 18.3306 20.9374C21.118 20.9374 23.3775 18.6778 23.3775 15.8905C23.3775 13.846 22.1618 12.0855 20.4138 11.2923C19.8013 8.85951 17.6496 7.06262 15.0892 7.06262C13.1975 7.06262 11.5289 8.04346 10.5393 9.53692C10.4681 9.53429 10.3966 9.53296 10.3248 9.53296C7.17553 9.53296 4.62256 12.0859 4.62256 15.2352ZM7.35971 16.8711C7.43337 16.9448 7.53771 16.9816 7.67275 16.9816C7.81392 16.9816 7.9198 16.9448 7.99039 16.8711C8.06098 16.7944 8.09627 16.687 8.09627 16.5489V15.642H9.43588V16.5489C9.43588 16.687 9.47118 16.7944 9.54176 16.8711C9.61542 16.9448 9.7213 16.9816 9.85941 16.9816C9.99444 16.9816 10.0973 16.9448 10.1678 16.8711C10.2415 16.7944 10.2783 16.687 10.2783 16.5489V14.086C10.2783 13.9448 10.2415 13.8374 10.1678 13.7638C10.0973 13.6901 9.99444 13.6533 9.85941 13.6533C9.7213 13.6533 9.61542 13.6901 9.54176 13.7638C9.47118 13.8374 9.43588 13.9448 9.43588 14.086V14.9469H8.09627V14.086C8.09627 13.9448 8.05944 13.8374 7.98579 13.7638C7.9152 13.6901 7.81085 13.6533 7.67275 13.6533C7.53771 13.6533 7.43337 13.6901 7.35971 13.7638C7.28606 13.8374 7.24923 13.9448 7.24923 14.086V16.5489C7.24923 16.687 7.28606 16.7944 7.35971 16.8711ZM12.1111 16.8711C12.1848 16.9448 12.2891 16.9816 12.4242 16.9816C12.5653 16.9816 12.6712 16.9448 12.7418 16.8711C12.8124 16.7944 12.8477 16.6885 12.8477 16.5535V14.3852H13.5704C13.684 14.3852 13.7699 14.3561 13.8282 14.2978C13.8896 14.2364 13.9203 14.1505 13.9203 14.04C13.9203 13.9264 13.8896 13.8405 13.8282 13.7822C13.7699 13.7239 13.684 13.6947 13.5704 13.6947H11.2779C11.1643 13.6947 11.0769 13.7239 11.0155 13.7822C10.9572 13.8405 10.928 13.9264 10.928 14.04C10.928 14.1505 10.9572 14.2364 11.0155 14.2978C11.0769 14.3561 11.1643 14.3852 11.2779 14.3852H12.0006V16.5535C12.0006 16.6885 12.0375 16.7944 12.1111 16.8711ZM15.818 16.9816C15.6829 16.9816 15.5786 16.9448 15.5049 16.8711C15.4313 16.7944 15.3945 16.6885 15.3945 16.5535V14.3852H14.6717C14.5582 14.3852 14.4707 14.3561 14.4093 14.2978C14.351 14.2364 14.3218 14.1505 14.3218 14.04C14.3218 13.9264 14.351 13.8405 14.4093 13.7822C14.4707 13.7239 14.5582 13.6947 14.6717 13.6947H16.9642C17.0778 13.6947 17.1637 13.7239 17.222 13.7822C17.2834 13.8405 17.3141 13.9264 17.3141 14.04C17.3141 14.1505 17.2834 14.2364 17.222 14.2978C17.1637 14.3561 17.0778 14.3852 16.9642 14.3852H16.2415V16.5535C16.2415 16.6885 16.2062 16.7944 16.1356 16.8711C16.065 16.9448 15.9591 16.9816 15.818 16.9816ZM18.0716 16.8711C18.1453 16.9448 18.2496 16.9816 18.3847 16.9816C18.5258 16.9816 18.6317 16.9448 18.7023 16.8711C18.7729 16.7944 18.8082 16.6885 18.8082 16.5535V15.8215H19.5217C19.89 15.8215 20.1739 15.7279 20.3734 15.5407C20.5759 15.3504 20.6772 15.0896 20.6772 14.7581C20.6772 14.4267 20.5759 14.1673 20.3734 13.9801C20.1739 13.7899 19.89 13.6947 19.5217 13.6947H18.3893C18.2542 13.6947 18.1484 13.7315 18.0716 13.8052C17.998 13.8789 17.9611 13.9847 17.9611 14.1228V16.5535C17.9611 16.6885 17.998 16.7944 18.0716 16.8711ZM19.3744 15.1724H18.8082V14.3438H19.3744C19.534 14.3438 19.6568 14.3776 19.7427 14.4451C19.8286 14.5126 19.8716 14.6169 19.8716 14.7581C19.8716 14.8962 19.8286 15.0006 19.7427 15.0712C19.6568 15.1387 19.534 15.1724 19.3744 15.1724Z" fill="white"/>
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_6365_1422" x1="14" y1="0" x2="4.27778" y2="25.6667" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FBA8E9"/>
|
||||
<stop offset="1" stop-color="#FF718A"/>
|
||||
</linearGradient>
|
||||
<clipPath id="clip0_6365_1422">
|
||||
<rect width="19.6" height="19.6" fill="white" transform="translate(4.20001 4.20001)"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 3.9 KiB |
10
projects/app/public/imgs/app/avatar/plugin.svg
Normal file
10
projects/app/public/imgs/app/avatar/plugin.svg
Normal file
@@ -0,0 +1,10 @@
|
||||
<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="28" height="28" rx="6" fill="url(#paint0_linear_6017_13715)"/>
|
||||
<path d="M17.2473 22.1667H13.9979V20.497C13.9979 20.421 13.991 20.3449 13.9772 20.2689C13.9634 20.1928 13.9392 20.1203 13.9081 20.0477C13.877 19.9751 13.8424 19.9094 13.7975 19.8472C13.7525 19.7849 13.7041 19.7262 13.6488 19.6709C13.3688 19.3943 12.9609 19.2388 12.5357 19.2457C12.4424 19.2457 12.3491 19.2561 12.2557 19.2733C12.1624 19.2906 12.0725 19.3148 11.9826 19.3494C11.8928 19.384 11.8098 19.422 11.7268 19.4704C11.6439 19.5188 11.5678 19.5741 11.4987 19.6363C11.3086 19.8057 11.0839 20.0926 11.0839 20.5282V22.1667H7.85869C7.79301 22.1667 7.72733 22.1632 7.66165 22.1563C7.59597 22.1494 7.53029 22.139 7.46461 22.1287C7.39893 22.1148 7.33671 22.101 7.27103 22.0803C7.20881 22.0595 7.14659 22.0388 7.08437 22.0146C7.02214 21.9904 6.96338 21.9593 6.90461 21.9282C6.84585 21.897 6.79054 21.8625 6.73523 21.8245C6.67992 21.7864 6.62807 21.7484 6.57622 21.7069C6.52437 21.6654 6.47597 21.6205 6.42758 21.5721C6.37918 21.5237 6.3377 21.4753 6.29276 21.4235C6.25128 21.3716 6.2098 21.3198 6.17523 21.2645C6.13721 21.2091 6.10264 21.1538 6.07153 21.0951C6.04042 21.0363 6.01276 20.9775 5.98511 20.9153C5.96091 20.8531 5.93671 20.7909 5.91943 20.7287C5.89869 20.6664 5.88486 20.6008 5.87103 20.5351C5.85721 20.4694 5.84684 20.4037 5.84338 20.338C5.83646 20.2724 5.83301 20.2067 5.83301 20.141V16.9193H7.49918C7.83449 16.9193 8.15943 16.7775 8.41523 16.5183C8.48782 16.4457 8.55004 16.3696 8.60535 16.2832C8.66066 16.2003 8.70906 16.1104 8.74708 16.017C8.78511 15.9237 8.81276 15.8269 8.8335 15.7267C8.85424 15.6264 8.86116 15.5262 8.86116 15.4259C8.84733 14.6516 8.21128 13.9983 7.46807 13.9983H5.83301V10.742C5.83301 10.6106 5.84683 10.4793 5.87103 10.3479C5.89869 10.2166 5.93671 10.0921 5.98856 9.97112C6.04042 9.85013 6.10264 9.7326 6.17869 9.62544C6.25474 9.51482 6.34116 9.41458 6.43449 9.3247C6.52782 9.23482 6.63153 9.15186 6.74214 9.07927C6.85276 9.00668 6.97029 8.94791 7.09128 8.89952C7.21227 8.85112 7.34017 8.8131 7.46807 8.7889C7.59597 8.7647 7.72733 8.75087 7.85869 8.75433H10.1644V8.22199C10.1644 8.18396 10.1644 8.14248 10.1678 8.10445C10.1713 8.06643 10.1713 8.02495 10.1782 7.98692C10.1816 7.9489 10.1886 7.90742 10.192 7.86939C10.1989 7.83137 10.2058 7.78989 10.2128 7.75186C10.2197 7.71384 10.23 7.67581 10.2404 7.63779L10.2715 7.52371C10.2819 7.48569 10.2957 7.44766 10.3096 7.40964C10.3234 7.37162 10.3372 7.33705 10.351 7.29902C10.3649 7.261 10.3821 7.22643 10.3994 7.19186C10.4167 7.15729 10.434 7.11927 10.4547 7.0847C10.472 7.05013 10.4928 7.01557 10.5135 6.981C10.5342 6.94643 10.555 6.91532 10.5792 6.88075C10.5999 6.84964 10.6241 6.81507 10.6483 6.78396L10.7209 6.69063C10.7451 6.65952 10.7728 6.63186 10.8004 6.60075C10.8281 6.5731 10.8557 6.54199 10.8834 6.51433C10.911 6.48668 10.9421 6.45902 10.9698 6.43483C11.0009 6.40717 11.0286 6.38297 11.0597 6.35878L11.153 6.28618C11.1841 6.26199 11.2187 6.24124 11.2498 6.2205C11.2809 6.19976 11.3155 6.17902 11.35 6.15828C11.3846 6.13754 11.4192 6.12026 11.4537 6.09952C11.4883 6.08223 11.5229 6.06495 11.5609 6.04766C11.5955 6.03038 11.6335 6.01655 11.6715 6.00273C11.7096 5.9889 11.7441 5.97507 11.7821 5.96124C11.8202 5.94742 11.8582 5.93705 11.8962 5.92668L12.0103 5.89557C12.0483 5.8852 12.0863 5.87828 12.1278 5.87137C12.1693 5.86445 12.2073 5.85754 12.2454 5.85408C12.2834 5.85063 12.3249 5.84371 12.3629 5.84026C12.4009 5.8368 12.4424 5.83334 12.4804 5.83334H12.5979C13.8908 5.85754 14.9451 6.93952 14.9451 8.2531V8.75087H17.2473C17.313 8.75087 17.3787 8.75433 17.4444 8.75779C17.51 8.7647 17.5757 8.77161 17.6379 8.78544C17.7036 8.79927 17.7658 8.8131 17.8281 8.83038C17.8903 8.84766 17.9525 8.87186 18.0147 8.89606C18.077 8.92026 18.1357 8.94791 18.1945 8.97902C18.2533 9.01013 18.3086 9.0447 18.3639 9.07927C18.4192 9.11384 18.471 9.15532 18.5229 9.1968C18.5747 9.23828 18.6231 9.28322 18.6681 9.32816C18.713 9.3731 18.7579 9.42495 18.7994 9.47334C18.8409 9.5252 18.8789 9.57705 18.917 9.63236C18.955 9.68766 18.9861 9.74297 19.0172 9.80174C19.0483 9.8605 19.076 9.91927 19.1002 9.98149C19.1244 10.0437 19.1451 10.1059 19.1658 10.1682C19.1831 10.2304 19.2004 10.2961 19.2108 10.3583C19.2246 10.424 19.2315 10.4862 19.2384 10.5519C19.2454 10.6175 19.2454 10.6832 19.2454 10.7489V13.0546H19.7431C21.0775 13.0546 22.1629 14.1124 22.1629 15.4121C22.1629 16.7464 21.0913 17.8319 19.7742 17.8319H19.2454V20.1375C19.2488 21.2541 18.35 22.1667 17.2473 22.1667Z" fill="white"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_6017_13715" x1="14" y1="0" x2="4.27778" y2="25.6667" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#61D2C4"/>
|
||||
<stop offset="1" stop-color="#40CAA1"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 4.6 KiB |
12
projects/app/public/imgs/app/avatar/simple.svg
Normal file
12
projects/app/public/imgs/app/avatar/simple.svg
Normal file
@@ -0,0 +1,12 @@
|
||||
<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="28" height="28" rx="6" fill="url(#paint0_linear_6017_13061)"/>
|
||||
<path d="M13.2532 5.44599C13.6438 5.22048 14.2771 5.22048 14.6678 5.44599L20.6364 8.89201C21.4176 9.34304 21.4176 10.0743 20.6364 10.5253L14.7463 13.926C14.3557 14.1515 13.7224 14.1515 13.3318 13.926L7.36312 10.48C6.58191 10.029 6.58191 9.29769 7.36312 8.84666L13.2532 5.44599Z" fill="white"/>
|
||||
<path d="M6.28687 12.5464C6.28687 11.915 6.73017 11.6591 7.27702 11.9748L12.7943 15.1602C13.1068 15.3406 13.3601 15.7794 13.3601 16.1402V21.973C13.3601 22.6045 12.9168 22.8604 12.37 22.5447L6.85267 19.3593C6.54018 19.1789 6.28687 18.7401 6.28687 18.3793V12.5464Z" fill="white"/>
|
||||
<path d="M14.6388 16.1842C14.6388 15.8234 14.8921 15.3846 15.2046 15.2042L20.7228 12.0183C21.2697 11.7026 21.713 11.9585 21.713 12.59V18.4221C21.713 18.7829 21.4597 19.2217 21.1472 19.4021L15.629 22.588C15.0821 22.9038 14.6388 22.6478 14.6388 22.0164V16.1842Z" fill="white"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_6017_13061" x1="14" y1="0" x2="4.27778" y2="25.6667" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#67BFFF"/>
|
||||
<stop offset="1" stop-color="#5BA6FF"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
17
projects/app/public/imgs/app/avatar/workflow.svg
Normal file
17
projects/app/public/imgs/app/avatar/workflow.svg
Normal file
@@ -0,0 +1,17 @@
|
||||
<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="28" height="28" rx="6" fill="url(#paint0_linear_6017_13553)"/>
|
||||
<path d="M10.2988 15.4908C10.2988 15.922 9.94929 16.2715 9.51813 16.2715C9.08697 16.2715 8.73744 15.922 8.73744 15.4908L8.73744 12.5091C8.73744 12.0779 9.08697 11.7284 9.51813 11.7284C9.94929 11.7284 10.2988 12.0779 10.2988 12.5091L10.2988 15.4908Z" fill="white"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.51813 11.2818C10.4922 11.2818 11.2818 10.4922 11.2818 9.51813C11.2818 8.5441 10.4922 7.75449 9.51813 7.75449C8.5441 7.75449 7.75449 8.5441 7.75449 9.51813C7.75449 10.4922 8.5441 11.2818 9.51813 11.2818ZM9.51813 12.8431C11.3545 12.8431 12.8431 11.3545 12.8431 9.51813C12.8431 7.68177 11.3545 6.19312 9.51813 6.19312C7.68177 6.19312 6.19312 7.68177 6.19312 9.51813C6.19312 11.3545 7.68177 12.8431 9.51813 12.8431Z" fill="white"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M13.707 8.76916C13.707 8.338 14.0565 7.98847 14.4877 7.98847C15.3118 7.98847 16.1288 8.14166 16.8924 8.44025C17.6561 8.73887 18.3528 9.17763 18.9417 9.73354C19.5307 10.2895 20.0004 10.9521 20.3218 11.6845C20.6433 12.4172 20.8094 13.2041 20.8094 14C20.8094 14.4311 20.4599 14.7807 20.0287 14.7807C19.5975 14.7807 19.248 14.4311 19.248 14C19.248 13.422 19.1275 12.8486 18.892 12.3119C18.6565 11.7751 18.31 11.2844 17.8699 10.8689C17.4297 10.4534 16.9047 10.1215 16.3238 9.89441C15.7429 9.66725 15.1189 9.54984 14.4877 9.54984C14.0565 9.54984 13.707 9.20032 13.707 8.76916Z" fill="white"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.51813 20.2455C10.4922 20.2455 11.2818 19.4558 11.2818 18.4818C11.2818 17.5078 10.4922 16.7182 9.51813 16.7182C8.5441 16.7182 7.75449 17.5078 7.75449 18.4818C7.75449 19.4558 8.5441 20.2455 9.51813 20.2455ZM9.51813 21.8068C11.3545 21.8068 12.8431 20.3182 12.8431 18.4818C12.8431 16.6455 11.3545 15.1568 9.51813 15.1568C7.68177 15.1568 6.19312 16.6455 6.19312 18.4818C6.19312 20.3182 7.68177 21.8068 9.51813 21.8068Z" fill="white"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.293 16.9858H17.9383C17.4675 16.9858 17.2098 16.9871 17.0248 17.0024C17.0176 17.003 17.0107 17.0036 17.0043 17.0043C17.0037 17.0107 17.003 17.0176 17.0024 17.0248C16.9871 17.2098 16.9858 17.4675 16.9858 17.9383V19.293C16.9858 19.7638 16.9871 20.0214 17.0024 20.2064C17.003 20.2137 17.0037 20.2205 17.0043 20.227C17.0107 20.2276 17.0176 20.2282 17.0248 20.2288C17.2098 20.2442 17.4675 20.2454 17.9383 20.2454H19.293C19.7638 20.2454 20.0214 20.2442 20.2064 20.2288C20.2137 20.2282 20.2205 20.2276 20.227 20.227C20.2276 20.2205 20.2282 20.2137 20.2288 20.2064C20.2442 20.0214 20.2455 19.7638 20.2455 19.293V17.9383C20.2455 17.4675 20.2442 17.2098 20.2288 17.0248C20.2282 17.0176 20.2276 17.0107 20.227 17.0043C20.2205 17.0036 20.2137 17.003 20.2064 17.0024C20.0214 16.9871 19.7638 16.9858 19.293 16.9858ZM15.6002 16.2661C15.4245 16.6045 15.4245 17.0491 15.4245 17.9383V19.293C15.4245 20.1822 15.4245 20.6268 15.6002 20.9652C15.7484 21.2504 15.9809 21.4829 16.2661 21.631C16.6045 21.8068 17.0491 21.8068 17.9383 21.8068H19.293C20.1822 21.8068 20.6268 21.8068 20.9652 21.631C21.2504 21.4829 21.4829 21.2504 21.631 20.9652C21.8068 20.6268 21.8068 20.1822 21.8068 19.293V17.9383C21.8068 17.0491 21.8068 16.6045 21.631 16.2661C21.4829 15.9809 21.2504 15.7484 20.9652 15.6002C20.6268 15.4244 20.1822 15.4244 19.293 15.4244H17.9383C17.0491 15.4244 16.6045 15.4244 16.2661 15.6002C15.9809 15.7484 15.7484 15.9809 15.6002 16.2661Z" fill="white"/>
|
||||
<path d="M11.2818 9.51813C11.2818 10.4922 10.4922 11.2818 9.51813 11.2818C8.5441 11.2818 7.75449 10.4922 7.75449 9.51813C7.75449 8.5441 8.5441 7.75449 9.51813 7.75449C10.4922 7.75449 11.2818 8.5441 11.2818 9.51813Z" fill="white"/>
|
||||
<path d="M11.2818 18.4818C11.2818 19.4558 10.4922 20.2455 9.51813 20.2455C8.5441 20.2455 7.75449 19.4558 7.75449 18.4818C7.75449 17.5078 8.5441 16.7182 9.51813 16.7182C10.4922 16.7182 11.2818 17.5078 11.2818 18.4818Z" fill="white"/>
|
||||
<path d="M17.9383 16.9858H19.293C19.7638 16.9858 20.0214 16.9871 20.2064 17.0024L20.227 17.0043L20.2288 17.0248C20.2442 17.2098 20.2455 17.4675 20.2455 17.9383V19.293C20.2455 19.7638 20.2442 20.0214 20.2288 20.2064L20.227 20.227L20.2064 20.2288C20.0214 20.2442 19.7638 20.2454 19.293 20.2454H17.9383C17.4675 20.2454 17.2098 20.2442 17.0248 20.2288L17.0043 20.227L17.0024 20.2064C16.9871 20.0214 16.9858 19.7638 16.9858 19.293V17.9383C16.9858 17.4675 16.9871 17.2098 17.0024 17.0248L17.0043 17.0043L17.0248 17.0024C17.2098 16.9871 17.4675 16.9858 17.9383 16.9858Z" fill="white"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_6017_13553" x1="14" y1="0" x2="4.27778" y2="25.6667" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#7895FE"/>
|
||||
<stop offset="1" stop-color="#7177FF"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 4.7 KiB |
@@ -1,251 +1,34 @@
|
||||
import React, { WheelEventHandler, useState, MouseEventHandler, TouchEventHandler, useRef } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Image,
|
||||
Modal,
|
||||
ModalCloseButton,
|
||||
ModalContent,
|
||||
ModalOverlay,
|
||||
Skeleton,
|
||||
useDisclosure
|
||||
} from '@chakra-ui/react';
|
||||
import React from 'react';
|
||||
import { Skeleton } from '@chakra-ui/react';
|
||||
import MyPhotoView from '@fastgpt/web/components/common/Image/PhotoView';
|
||||
import { useBoolean } from 'ahooks';
|
||||
|
||||
const MdImage = ({ src }: { src?: string }) => {
|
||||
const imgRef = useRef<HTMLImageElement>(null);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [succeed, setSucceed] = useState(false);
|
||||
const { isOpen, onOpen, onClose } = useDisclosure();
|
||||
const [scale, setScale] = useState(1);
|
||||
|
||||
const [positionLeft, setPositionLeft] = useState(0)
|
||||
const [positionTop, setPositionTop] = useState(0)
|
||||
const [store] = useState({
|
||||
scale: 1,
|
||||
moveable: false,
|
||||
pageX: 0,
|
||||
pageY: 0,
|
||||
pageX2: 0,
|
||||
pageY2: 0,
|
||||
originScale: 1
|
||||
})
|
||||
|
||||
// 自定义Modal关闭事件
|
||||
const customOnClose = (): void => {
|
||||
setPositionLeft(0)
|
||||
setPositionTop(0)
|
||||
setScale(1)
|
||||
onClose()
|
||||
}
|
||||
|
||||
const handleWheel: WheelEventHandler<HTMLImageElement> = (e) => {
|
||||
setScale((prevScale) => {
|
||||
const newScale = prevScale + e.deltaY * 0.5 * -0.01;
|
||||
if (newScale < 0.5) return 0.5;
|
||||
if (newScale > 10) return 10;
|
||||
return newScale;
|
||||
});
|
||||
};
|
||||
|
||||
const handleTouchStart: TouchEventHandler<HTMLImageElement> = (event) => {
|
||||
let touches = event.touches;
|
||||
let events = touches[0];//单指
|
||||
let events2 = touches[1];//双指
|
||||
if (touches.length == 1) {// 单指操作
|
||||
store.pageX = events.pageX
|
||||
store.pageY = events.pageY
|
||||
store.moveable = true;
|
||||
} else {
|
||||
// 第一个触摸点的坐标
|
||||
store.pageX = events.pageX;
|
||||
store.pageY = events.pageY;
|
||||
store.moveable = true;
|
||||
if (events2) {
|
||||
store.pageX2 = events2.pageX;
|
||||
store.pageY2 = events2.pageY;
|
||||
}
|
||||
store.originScale = store.scale || 1;
|
||||
}
|
||||
}
|
||||
|
||||
const handleTouchMove: TouchEventHandler<HTMLImageElement> = (event) => {
|
||||
if (!store.moveable) {
|
||||
return;
|
||||
}
|
||||
let touches = event.touches;
|
||||
let events = touches[0];
|
||||
let events2 = touches[1];
|
||||
//最大移动距离
|
||||
let moveMaxWith = (Number(imgRef.current?.width) * scale - window.innerWidth) / 2;
|
||||
let moveMaxHeight = (Number(imgRef.current?.height) * scale - window.innerHeight) / 2;
|
||||
|
||||
if (touches.length == 1) {
|
||||
//未放大,不移动图片
|
||||
if (scale <= 1)
|
||||
return;
|
||||
|
||||
let pageX = store.pageX;
|
||||
let pageY = store.pageY
|
||||
let pageX2 = events.pageX;
|
||||
let pageY2 = events.pageY;
|
||||
|
||||
let newLeft = positionLeft + pageX2 / 20 - pageX / 20;
|
||||
let newTop = positionTop + pageY2 / 20 - pageY / 20;
|
||||
if (Math.abs(newLeft) > moveMaxWith) {
|
||||
if (newLeft > 0) {
|
||||
newLeft = moveMaxWith;
|
||||
}
|
||||
else {
|
||||
newLeft = 0 - moveMaxWith;
|
||||
}
|
||||
}
|
||||
// 放大倍数没超过屏高
|
||||
if (moveMaxHeight < 0) {
|
||||
newTop = 0;
|
||||
}
|
||||
else if (Math.abs(newTop) > moveMaxHeight) {
|
||||
if (newTop > 0) {
|
||||
newTop = moveMaxHeight;
|
||||
}
|
||||
else {
|
||||
newTop = 0 - moveMaxHeight;
|
||||
}
|
||||
}
|
||||
|
||||
//控制图片移动
|
||||
setPositionLeft(newLeft)
|
||||
setPositionTop(newTop)
|
||||
} else {
|
||||
// 双指移动
|
||||
if (events2) {
|
||||
// 第2个指头坐标在touchmove时候获取
|
||||
store.pageX2 = events2.pageX;
|
||||
store.pageY2 = events2.pageY;
|
||||
|
||||
// 获取坐标之间的距离
|
||||
let getDistance = function (start: any, stop: any) {
|
||||
//用到三角函数
|
||||
return Math.hypot(stop.x - start.x,
|
||||
stop.y - start.y);
|
||||
};
|
||||
// 双指缩放比例计算
|
||||
let zoom = getDistance({
|
||||
x: events.pageX,
|
||||
y: events.pageY
|
||||
}, {
|
||||
x: events2.pageX,
|
||||
y: events2.pageY
|
||||
}) / getDistance({
|
||||
x: store.pageX,
|
||||
y: store.pageY
|
||||
}, {
|
||||
x: store.pageX2,
|
||||
y: store.pageY2
|
||||
});
|
||||
// 应用在元素上的缩放比例
|
||||
let newScale = store.originScale * zoom;
|
||||
|
||||
// 缩放比例限制
|
||||
if (newScale > 10) {
|
||||
newScale = 10;
|
||||
}
|
||||
if (newScale <= 1) {
|
||||
newScale = 1;
|
||||
}
|
||||
|
||||
store.scale = newScale;
|
||||
// 图像应用缩放效果
|
||||
setScale(newScale);
|
||||
// 如果是缩小图片,则限制移动的距离
|
||||
if (Math.abs(positionLeft) > moveMaxWith) {
|
||||
if (positionLeft > 0) {
|
||||
setPositionLeft(moveMaxWith);
|
||||
}
|
||||
else {
|
||||
setPositionLeft(0 - moveMaxWith);
|
||||
}
|
||||
}
|
||||
|
||||
if (moveMaxHeight < 0) {
|
||||
setPositionTop(0);
|
||||
}
|
||||
else if (Math.abs(positionTop) > moveMaxHeight) {
|
||||
if (positionTop > 0) {
|
||||
setPositionTop(moveMaxHeight);
|
||||
}
|
||||
else {
|
||||
setPositionTop(0 - moveMaxHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const handleTouchEnd: TouchEventHandler<HTMLImageElement> = (e) => {
|
||||
store.moveable = false;
|
||||
store.pageX2 = 0;
|
||||
store.pageY2 = 0;
|
||||
}
|
||||
|
||||
const handleTouchCancel: TouchEventHandler<HTMLImageElement> = (e) => {
|
||||
store.moveable = false;
|
||||
store.pageX2 = 0;
|
||||
store.pageY2 = 0;
|
||||
}
|
||||
const [isLoaded, { setTrue }] = useBoolean(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Image
|
||||
<Skeleton isLoaded={isLoaded}>
|
||||
<MyPhotoView
|
||||
borderRadius={'md'}
|
||||
src={src}
|
||||
alt={''}
|
||||
fallbackSrc={'/imgs/errImg.png'}
|
||||
fallbackStrategy={'onError'}
|
||||
cursor={succeed ? 'pointer' : 'default'}
|
||||
loading="lazy"
|
||||
objectFit={'contain'}
|
||||
referrerPolicy="no-referrer"
|
||||
minW={'120px'}
|
||||
minH={'120px'}
|
||||
maxH={'500px'}
|
||||
my={1}
|
||||
onLoad={() => {
|
||||
setIsLoading(false);
|
||||
setSucceed(true);
|
||||
setTrue();
|
||||
}}
|
||||
onError={() => setIsLoading(false)}
|
||||
onClick={() => {
|
||||
if (!succeed) return;
|
||||
onOpen();
|
||||
onError={() => {
|
||||
setTrue();
|
||||
}}
|
||||
/>
|
||||
<Modal isOpen={isOpen} onClose={customOnClose} isCentered>
|
||||
<ModalOverlay />
|
||||
<ModalContent boxShadow={'none'} maxW={'auto'} w="auto" bg={'transparent'}>
|
||||
<Image
|
||||
ref={imgRef}
|
||||
transform={`scale(${scale})`}
|
||||
borderRadius={'md'}
|
||||
src={src}
|
||||
alt={''}
|
||||
w={'100%'}
|
||||
maxH={'80vh'}
|
||||
referrerPolicy="no-referrer"
|
||||
fallbackSrc={'/imgs/errImg.png'}
|
||||
fallbackStrategy={'onError'}
|
||||
objectFit={'contain'}
|
||||
position={'relative'}
|
||||
top={positionTop + 'px'}
|
||||
left={positionLeft + "px"}
|
||||
onWheel={handleWheel}
|
||||
onTouchStart={handleTouchStart}
|
||||
onTouchMove={handleTouchMove}
|
||||
onTouchEnd={handleTouchEnd}
|
||||
onTouchCancel={handleTouchCancel}
|
||||
/>
|
||||
</ModalContent>
|
||||
<ModalCloseButton bg={'myWhite.500'} zIndex={999999} />
|
||||
</Modal>
|
||||
</>
|
||||
</Skeleton>
|
||||
);
|
||||
};
|
||||
|
||||
|
@@ -106,8 +106,9 @@ const InputGuideConfig = ({
|
||||
iconSrc="core/app/inputGuides"
|
||||
isOpen={isOpen}
|
||||
onClose={onClose}
|
||||
w={'500px'}
|
||||
>
|
||||
<ModalBody px={[5, 16]} py={[4, 8]} w={'500px'}>
|
||||
<ModalBody px={[5, 16]} py={[4, 8]}>
|
||||
<Flex justifyContent={'space-between'} alignItems={'center'}>
|
||||
<FormLabel>{t('Is open')}</FormLabel>
|
||||
<Switch
|
||||
|
@@ -11,10 +11,12 @@ const PermissionIconText = ({
|
||||
defaultPermission,
|
||||
w = '1rem',
|
||||
fontSize = 'mini',
|
||||
iconColor = 'myGray.500',
|
||||
...props
|
||||
}: {
|
||||
permission?: `${PermissionTypeEnum}`;
|
||||
defaultPermission?: PermissionValueType;
|
||||
iconColor?: string;
|
||||
} & StackProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@@ -31,7 +33,7 @@ const PermissionIconText = ({
|
||||
|
||||
return PermissionTypeMap[per] ? (
|
||||
<HStack spacing={1} fontSize={fontSize} {...props}>
|
||||
<MyIcon name={PermissionTypeMap[per]?.iconLight as any} w={w} />
|
||||
<MyIcon name={PermissionTypeMap[per]?.iconLight as any} w={w} color={iconColor} />
|
||||
<Box lineHeight={1}>{t(PermissionTypeMap[per]?.label)}</Box>
|
||||
</HStack>
|
||||
) : null;
|
||||
|
@@ -37,7 +37,7 @@ async function handler(req: NextApiRequest) {
|
||||
fileId,
|
||||
isQAImport: true
|
||||
});
|
||||
console.log(rawText);
|
||||
|
||||
// 2. split chunks
|
||||
const chunks = rawText2Chunks({
|
||||
rawText,
|
||||
|
@@ -96,16 +96,6 @@ const AppCard = () => {
|
||||
>
|
||||
{t('core.Chat')}
|
||||
</Button>
|
||||
{appDetail.permission.hasWritePer && feConfigs?.show_team_chat && (
|
||||
<Button
|
||||
size={['sm', 'md']}
|
||||
variant={'whitePrimary'}
|
||||
leftIcon={<DragHandleIcon w={'16px'} />}
|
||||
onClick={() => setTeamTagsSet(appDetail)}
|
||||
>
|
||||
{t('common.Team Tags Set')}
|
||||
</Button>
|
||||
)}
|
||||
{appDetail.permission.hasManagePer && (
|
||||
<Button
|
||||
size={['sm', 'md']}
|
||||
@@ -133,7 +123,16 @@ const AppCard = () => {
|
||||
icon: 'core/app/type/workflow',
|
||||
label: appT('Transition to workflow'),
|
||||
onClick: () => setTransitionCreateNew(true)
|
||||
}
|
||||
},
|
||||
...(appDetail.permission.hasWritePer && feConfigs?.show_team_chat
|
||||
? [
|
||||
{
|
||||
icon: 'core/chat/fileSelect',
|
||||
label: t('common.Team Tags Set'),
|
||||
onClick: () => setTeamTagsSet(appDetail)
|
||||
}
|
||||
]
|
||||
: [])
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@@ -59,12 +59,18 @@ const Edit = ({
|
||||
borderRadius={'lg'}
|
||||
overflowY={['auto', 'unset']}
|
||||
>
|
||||
<Box className={styles.EditAppBox} pr={[0, 1]} overflowY={'auto'} minW={'580px'} flex={'1'}>
|
||||
<Box
|
||||
className={styles.EditAppBox}
|
||||
pr={[0, 1]}
|
||||
overflowY={'auto'}
|
||||
minW={['auto', '580px']}
|
||||
flex={'1'}
|
||||
>
|
||||
<Box {...cardStyles} boxShadow={'2'}>
|
||||
<AppCard />
|
||||
</Box>
|
||||
|
||||
<Box mt={4} {...cardStyles} boxShadow={'3.5'} w={'auto'}>
|
||||
<Box mt={4} {...cardStyles} boxShadow={'3.5'}>
|
||||
<EditForm appForm={appForm} setAppForm={setAppForm} />
|
||||
</Box>
|
||||
</Box>
|
||||
|
@@ -57,6 +57,7 @@ const BoxStyles: BoxProps = {
|
||||
};
|
||||
const LabelStyles: BoxProps = {
|
||||
w: ['60px', '100px'],
|
||||
whiteSpace: 'nowrap',
|
||||
flexShrink: 0,
|
||||
fontSize: 'xs'
|
||||
};
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
import { Box, Flex, Button, IconButton } from '@chakra-ui/react';
|
||||
import { Box, Flex, Button, IconButton, HStack } from '@chakra-ui/react';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import dynamic from 'next/dynamic';
|
||||
|
||||
@@ -79,9 +79,10 @@ const Header = () => {
|
||||
pl={[2, 4]}
|
||||
pr={[2, 6]}
|
||||
borderBottom={'base'}
|
||||
alignItems={'center'}
|
||||
alignItems={['flex-start', 'center']}
|
||||
userSelect={'none'}
|
||||
h={'67px'}
|
||||
h={['auto', '67px']}
|
||||
flexWrap={'wrap'}
|
||||
{...(currentTab === TabEnum.appEdit
|
||||
? {
|
||||
bg: 'myGray.25'
|
||||
@@ -115,10 +116,9 @@ const Header = () => {
|
||||
<Box flex={1} />
|
||||
|
||||
{currentTab === TabEnum.appEdit && (
|
||||
<>
|
||||
<HStack flexDirection={['column', 'row']} spacing={[2, 3]}>
|
||||
{!historiesDefaultData && (
|
||||
<IconButton
|
||||
mr={[2, 4]}
|
||||
icon={<MyIcon name={'history'} w={'18px'} />}
|
||||
aria-label={''}
|
||||
size={'sm'}
|
||||
@@ -157,7 +157,6 @@ const Header = () => {
|
||||
<Box>
|
||||
<MyTooltip label={t('core.app.Publish app tip')}>
|
||||
<Button
|
||||
ml={[2, 4]}
|
||||
size={'sm'}
|
||||
leftIcon={<MyIcon name={'common/publishFill'} w={['14px', '16px']} />}
|
||||
>
|
||||
@@ -169,7 +168,7 @@ const Header = () => {
|
||||
onConfirm={() => onclickPublish()}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
</HStack>
|
||||
)}
|
||||
</Flex>
|
||||
{historiesDefaultData && (
|
||||
|
@@ -27,7 +27,10 @@ const SelectAppModal = ({
|
||||
|
||||
const getAppList = useCallback(
|
||||
async ({ parentId }: GetResourceFolderListProps) => {
|
||||
return getMyApps({ parentId }).then((res) =>
|
||||
return getMyApps({
|
||||
parentId,
|
||||
type: [AppTypeEnum.folder, AppTypeEnum.simple, AppTypeEnum.workflow]
|
||||
}).then((res) =>
|
||||
res
|
||||
.filter((item) => !filterAppIds.includes(item._id))
|
||||
.map<GetResourceListItemResponse>((item) => ({
|
||||
|
@@ -50,15 +50,18 @@ const CreateModal = ({ onClose, type }: { type: CreateAppType; onClose: () => vo
|
||||
[AppTypeEnum.simple]: {
|
||||
icon: 'core/app/simpleBot',
|
||||
title: appT('type.Create simple bot'),
|
||||
avatar: '/imgs/app/avatar/simple.svg',
|
||||
templates: simpleBotTemplates
|
||||
},
|
||||
[AppTypeEnum.workflow]: {
|
||||
icon: 'core/app/type/workflowFill',
|
||||
avatar: '/imgs/app/avatar/workflow.svg',
|
||||
title: appT('type.Create workflow bot'),
|
||||
templates: workflowTemplates
|
||||
},
|
||||
[AppTypeEnum.plugin]: {
|
||||
icon: 'core/app/type/pluginFill',
|
||||
avatar: '/imgs/app/avatar/plugin.svg',
|
||||
title: appT('type.Create plugin bot'),
|
||||
templates: pluginTemplates
|
||||
}
|
||||
@@ -67,7 +70,7 @@ const CreateModal = ({ onClose, type }: { type: CreateAppType; onClose: () => vo
|
||||
|
||||
const { register, setValue, watch, handleSubmit } = useForm<FormType>({
|
||||
defaultValues: {
|
||||
avatar: '',
|
||||
avatar: typeData.avatar,
|
||||
name: '',
|
||||
templateId: typeData.templates[0].id
|
||||
}
|
||||
@@ -146,7 +149,7 @@ const CreateModal = ({ onClose, type }: { type: CreateAppType; onClose: () => vo
|
||||
w={['28px', '32px']}
|
||||
h={['28px', '32px']}
|
||||
cursor={'pointer'}
|
||||
borderRadius={'md'}
|
||||
borderRadius={'sm'}
|
||||
onClick={onOpenSelectFile}
|
||||
/>
|
||||
</MyTooltip>
|
||||
|
@@ -180,8 +180,8 @@ const ListItem = () => {
|
||||
})}
|
||||
>
|
||||
<HStack>
|
||||
<Avatar src={app.avatar} borderRadius={'md'} w={'1.5rem'} />
|
||||
<Box flex={'1 0 0'} fontSize={'1.125rem'}>
|
||||
<Avatar src={app.avatar} borderRadius={'sm'} w={'1.5rem'} />
|
||||
<Box flex={'1 0 0'} color={'myGray.900'}>
|
||||
{app.name}
|
||||
</Box>
|
||||
<Box mr={'-1.25rem'}>
|
||||
@@ -189,7 +189,7 @@ const ListItem = () => {
|
||||
</Box>
|
||||
</HStack>
|
||||
<Box
|
||||
flex={['1 0 60px', '1 0 80px']}
|
||||
flex={['1 0 60px', '1 0 72px']}
|
||||
mt={3}
|
||||
pr={8}
|
||||
textAlign={'justify'}
|
||||
@@ -209,21 +209,26 @@ const ListItem = () => {
|
||||
<HStack spacing={3.5}>
|
||||
{owner && (
|
||||
<HStack spacing={1}>
|
||||
<Avatar src={owner.avatar} w={'0.875rem'} />
|
||||
<Avatar src={owner.avatar} w={'0.875rem'} borderRadius={'50%'} />
|
||||
<Box maxW={'150px'} className="textEllipsis">
|
||||
{owner.memberName}
|
||||
</Box>
|
||||
</HStack>
|
||||
)}
|
||||
|
||||
<PermissionIconText defaultPermission={app.defaultPermission} w={'0.875rem'} />
|
||||
<PermissionIconText
|
||||
defaultPermission={app.defaultPermission}
|
||||
color={'myGray.500'}
|
||||
iconColor={'myGray.400'}
|
||||
w={'0.875rem'}
|
||||
/>
|
||||
</HStack>
|
||||
|
||||
<HStack>
|
||||
{isPc && (
|
||||
<HStack spacing={0.5} className="time">
|
||||
<MyIcon name={'history'} w={'0.85rem'} />
|
||||
<Box>{formatTimeToChatTime(app.updateTime)}</Box>
|
||||
<MyIcon name={'history'} w={'0.85rem'} color={'myGray.400'} />
|
||||
<Box color={'myGray.500'}>{formatTimeToChatTime(app.updateTime)}</Box>
|
||||
</HStack>
|
||||
)}
|
||||
{app.permission.hasManagePer && (
|
||||
@@ -292,17 +297,21 @@ const ListItem = () => {
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
children: [
|
||||
{
|
||||
icon: 'core/chat/chatLight',
|
||||
label: appT('Go to chat'),
|
||||
onClick: () => {
|
||||
router.push(`/chat?appId=${app._id}`);
|
||||
...([AppTypeEnum.simple, AppTypeEnum.workflow].includes(app.type)
|
||||
? [
|
||||
{
|
||||
children: [
|
||||
{
|
||||
icon: 'core/chat/chatLight',
|
||||
label: appT('Go to chat'),
|
||||
onClick: () => {
|
||||
router.push(`/chat?appId=${app._id}`);
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(app.permission.isOwner
|
||||
? [
|
||||
{
|
||||
|
@@ -165,7 +165,7 @@ const ChatHistorySlider = ({
|
||||
}}
|
||||
list={[
|
||||
{ label: t('core.chat.Recent use'), value: TabEnum.recently },
|
||||
{ label: t('App'), value: TabEnum.app },
|
||||
...(!isTeamChat ? [{ label: t('App'), value: TabEnum.app }] : []),
|
||||
{ label: t('core.chat.History'), value: TabEnum.history }
|
||||
]}
|
||||
value={currentTab}
|
||||
|
@@ -23,7 +23,10 @@ const SliderApps = ({ apps, activeAppId }: { apps: AppListItemType[]; activeAppI
|
||||
const isTeamChat = router.pathname === '/chat/team';
|
||||
|
||||
const getAppList = useCallback(async ({ parentId }: GetResourceFolderListProps) => {
|
||||
return getMyApps({ parentId }).then((res) =>
|
||||
return getMyApps({
|
||||
parentId,
|
||||
type: [AppTypeEnum.folder, AppTypeEnum.simple, AppTypeEnum.workflow]
|
||||
}).then((res) =>
|
||||
res.map<GetResourceListItemResponse>((item) => ({
|
||||
id: item._id,
|
||||
name: item.name,
|
||||
|
@@ -73,6 +73,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
|
||||
avatar: template.avatar,
|
||||
name: t(template.name),
|
||||
modules: template.modules,
|
||||
edges: template.edges,
|
||||
type: template.type
|
||||
});
|
||||
});
|
||||
|
@@ -16,17 +16,16 @@ import { systemStartCb } from '@fastgpt/service/common/system/tools';
|
||||
/**
|
||||
* connect MongoDB and init data
|
||||
*/
|
||||
export function connectToDatabase(): Promise<void> {
|
||||
export function connectToDatabase() {
|
||||
return connectMongo({
|
||||
beforeHook: () => {
|
||||
initGlobal();
|
||||
},
|
||||
afterHook: async () => {
|
||||
systemStartCb();
|
||||
// init system config
|
||||
getInitConfig();
|
||||
//init vector database, init root user
|
||||
await Promise.all([initVectorStore(), initRootUser()]);
|
||||
|
||||
//init system config;init vector database;init root user
|
||||
await Promise.all([getInitConfig(), initVectorStore(), initRootUser()]);
|
||||
|
||||
startMongoWatch();
|
||||
// cron
|
||||
|
@@ -23,7 +23,7 @@ export const simpleBotTemplates: TemplateType = [
|
||||
{
|
||||
id: 'simpleChat',
|
||||
avatar: '/imgs/workflow/AI.png',
|
||||
name: '简易模板',
|
||||
name: '简易机器人',
|
||||
intro: '一个极其简单的 AI 应用,你可以绑定知识库或工具。',
|
||||
type: AppTypeEnum.simple,
|
||||
modules: [
|
||||
@@ -3048,4 +3048,9 @@ export const pluginTemplates: TemplateType = [
|
||||
}
|
||||
];
|
||||
|
||||
export const defaultAppTemplates = simpleBotTemplates.concat(workflowTemplates[0]);
|
||||
export const defaultAppTemplates = [
|
||||
simpleBotTemplates[0],
|
||||
simpleBotTemplates[1],
|
||||
workflowTemplates[0],
|
||||
workflowTemplates[1]
|
||||
];
|
||||
|
@@ -17,6 +17,7 @@ import { StoreEdgeItemType } from '@fastgpt/global/core/workflow/type/edge';
|
||||
import { EditorVariablePickerType } from '@fastgpt/web/components/common/Textarea/PromptEditor/type';
|
||||
import { TFunction } from 'next-i18next';
|
||||
import { ToolModule } from '@fastgpt/global/core/workflow/template/system/tools';
|
||||
import { useDatasetStore } from '../dataset/store/dataset';
|
||||
|
||||
type WorkflowType = {
|
||||
nodes: StoreNodeItemType[];
|
||||
@@ -26,6 +27,12 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType & {
|
||||
chatConfig: AppChatConfigType;
|
||||
} {
|
||||
const workflowStartNodeId = 'workflowStartNodeId';
|
||||
|
||||
const allDatasets = useDatasetStore.getState().allDatasets;
|
||||
const selectedDatasets = data.dataset.datasets.filter((item) =>
|
||||
allDatasets.some((ds) => ds._id === item.datasetId)
|
||||
);
|
||||
|
||||
function systemConfigTemplate(formData: AppSimpleEditFormType): StoreNodeItemType {
|
||||
return {
|
||||
nodeId: 'userGuide',
|
||||
@@ -351,7 +358,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType & {
|
||||
FlowNodeInputTypeEnum.reference
|
||||
],
|
||||
label: 'core.module.input.label.Select dataset',
|
||||
value: formData.dataset.datasets,
|
||||
value: selectedDatasets,
|
||||
valueType: WorkflowIOValueTypeEnum.selectDataset,
|
||||
list: [],
|
||||
required: true
|
||||
@@ -447,7 +454,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType & {
|
||||
const datasetNodeId = getNanoid(6);
|
||||
|
||||
const datasetTool: WorkflowType | null =
|
||||
formData.dataset.datasets.length > 0
|
||||
selectedDatasets.length > 0
|
||||
? {
|
||||
nodes: [
|
||||
{
|
||||
@@ -470,7 +477,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType & {
|
||||
FlowNodeInputTypeEnum.reference
|
||||
],
|
||||
label: 'core.module.input.label.Select dataset',
|
||||
value: formData.dataset.datasets,
|
||||
value: selectedDatasets,
|
||||
valueType: WorkflowIOValueTypeEnum.selectDataset,
|
||||
list: [],
|
||||
required: true
|
||||
@@ -690,7 +697,7 @@ export function form2AppWorkflow(data: AppSimpleEditFormType): WorkflowType & {
|
||||
|
||||
const workflow = (() => {
|
||||
if (data.selectedTools.length > 0) return toolTemplates(data);
|
||||
if (data.dataset.datasets.length > 0) return datasetTemplate(data);
|
||||
if (selectedDatasets.length > 0) return datasetTemplate(data);
|
||||
return simpleChatTemplate(data);
|
||||
})();
|
||||
|
||||
|
@@ -12,7 +12,6 @@ type State = {
|
||||
loadAllDatasets: () => Promise<DatasetSimpleItemType[]>;
|
||||
myDatasets: DatasetListItemType[];
|
||||
loadMyDatasets: (parentId?: string) => Promise<any>;
|
||||
setMyDatasets(val: DatasetListItemType[]): void;
|
||||
};
|
||||
|
||||
export const useDatasetStore = create<State>()(
|
||||
@@ -34,11 +33,6 @@ export const useDatasetStore = create<State>()(
|
||||
state.myDatasets = res;
|
||||
});
|
||||
return res;
|
||||
},
|
||||
setMyDatasets(val) {
|
||||
set((state) => {
|
||||
state.myDatasets = val;
|
||||
});
|
||||
}
|
||||
})),
|
||||
{
|
||||
|
Reference in New Issue
Block a user