Skip to content

Commit

Permalink
4.8.5 test fix (#1862)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
c121914yu authored Jun 27, 2024
1 parent 9d084b6 commit a3b0ef0
Show file tree
Hide file tree
Showing 31 changed files with 8,463 additions and 10,689 deletions.
22 changes: 12 additions & 10 deletions docSite/content/zh-cn/docs/development/upgrading/485.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. 修复 - 自定义输入选择知识库引用时页面崩溃
12 changes: 9 additions & 3 deletions packages/service/common/middle/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand All @@ -22,10 +23,15 @@ export const NextEntry = ({ beforeCallback = [] }: { beforeCallback?: Promise<an
response = await handler(req, res);
}

const contentType = res.getHeader('Content-Type');

addLog.debug(`Request finish ${req.url}, time: ${Date.now() - start}ms`);
// 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');
if ((!contentType || contentType === 'application/json') && !res.writableFinished) {
return jsonRes(res, {
code: 200,
Expand Down
8 changes: 7 additions & 1 deletion packages/service/common/mongo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
})();
52 changes: 29 additions & 23 deletions packages/service/common/mongo/init.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand All @@ -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;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions packages/web/components/common/Image/PhotoView.tsx
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion packages/web/i18n/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@
"Speech speed": "语速",
"Test Listen": "试听",
"Test Listen Text": "你好,这是语音测试,如果你能听到这句话,说明语音播放功能正常",
"Web": "浏览器自带(免费)"
"Web": "浏览器自带(免费)"
},
"whisper": {
"Auto send": "自动发送",
Expand Down
11 changes: 6 additions & 5 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
Loading

0 comments on commit a3b0ef0

Please sign in to comment.