From a9c2bc23c4dada04330f6fc99b66cd7718220a7d Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Sun, 24 Mar 2024 15:04:38 +0800 Subject: [PATCH] fix: plugin update --- .../service/core/workflow/dispatch/plugin/run.ts | 1 - .../core/workflow/dispatch/tools/http468.ts | 5 +++-- packages/service/support/user/controller.ts | 1 - projects/app/public/locales/zh/common.json | 5 ++--- .../components/ChatBox/components/ChatItem.tsx | 3 ++- .../app/src/pages/account/components/Info.tsx | 2 +- projects/app/src/pages/api/core/plugin/update.ts | 16 ++++++++++++++-- projects/app/src/pages/price/components/FAQ.tsx | 2 +- 8 files changed, 23 insertions(+), 12 deletions(-) diff --git a/packages/service/core/workflow/dispatch/plugin/run.ts b/packages/service/core/workflow/dispatch/plugin/run.ts index c4cd78bbea61..af974e4516f3 100644 --- a/packages/service/core/workflow/dispatch/plugin/run.ts +++ b/packages/service/core/workflow/dispatch/plugin/run.ts @@ -19,7 +19,6 @@ export const dispatchRunPlugin = async (props: RunPluginProps): Promise; params: Record; }): Promise> { - const { data: response } = await axios>({ + const { data: response } = await axios({ method, baseURL: `http://${SERVICE_LOCAL_HOST}`, url, @@ -241,7 +241,8 @@ async function fetchData({ }; return { - formatResponse: parseJson(response), + formatResponse: + typeof response === 'object' && !Array.isArray(response) ? parseJson(response) : {}, rawResponse: response }; } diff --git a/packages/service/support/user/controller.ts b/packages/service/support/user/controller.ts index 5765df3a75d9..a760927704bd 100644 --- a/packages/service/support/user/controller.ts +++ b/packages/service/support/user/controller.ts @@ -39,7 +39,6 @@ export async function getUserDetail({ _id: user._id, username: user.username, avatar: user.avatar, - balance: user.balance, timezone: user.timezone, promotionRate: user.promotionRate, openaiAccount: user.openaiAccount, diff --git a/projects/app/public/locales/zh/common.json b/projects/app/public/locales/zh/common.json index 406e24bcbecd..256e4a6bbbea 100644 --- a/projects/app/public/locales/zh/common.json +++ b/projects/app/public/locales/zh/common.json @@ -582,8 +582,7 @@ "success": "开始同步" } }, - "training": { - } + "training": {} }, "data": { "Auxiliary Data": "辅助数据", @@ -1421,7 +1420,7 @@ "experience": "体验版", "experience desc": "", "free": "免费版", - "free desc": "每月均可免费使用基础功能,15天无使用记录时,将会清除知识库", + "free desc": "每月均可免费使用基础功能,30天无使用记录时,将会清除知识库", "team": "团队版" }, "type": { diff --git a/projects/app/src/components/ChatBox/components/ChatItem.tsx b/projects/app/src/components/ChatBox/components/ChatItem.tsx index 024f2714a8b3..4c9732803dee 100644 --- a/projects/app/src/components/ChatBox/components/ChatItem.tsx +++ b/projects/app/src/components/ChatBox/components/ChatItem.tsx @@ -137,6 +137,7 @@ ${JSON.stringify(questionGuides)}`; return tool.response; } })(); + return ( @@ -169,7 +170,7 @@ ${JSON.stringify(questionGuides)}`; maxH={'500px'} overflowY={'auto'} > - {toolParams && ( + {toolParams && toolParams !== '{}' && ( { {isFreeTeam && ( - 免费版用户15天无任何使用记录时,系统会自动清理账号知识库。 + 免费版用户30天无任何使用记录时,系统会自动清理账号知识库。 )} diff --git a/projects/app/src/pages/api/core/plugin/update.ts b/projects/app/src/pages/api/core/plugin/update.ts index 216bb9a249c8..1ed8bc96273d 100644 --- a/projects/app/src/pages/api/core/plugin/update.ts +++ b/projects/app/src/pages/api/core/plugin/update.ts @@ -17,6 +17,18 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< const { teamId, tmbId } = await authPluginCrud({ req, authToken: true, id, per: 'owner' }); + const updateData = { + name: props.name, + intro: props.intro, + avatar: props.avatar, + parentId: props.parentId, + ...(props.modules && + props.modules.length > 0 && { + modules: props.modules + }), + metadata: props.metadata + }; + if (props.metadata?.apiSchemaStr) { await mongoSessionRun(async (session) => { // update children @@ -26,13 +38,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< parent: body, session }); - await MongoPlugin.findByIdAndUpdate(id, props, { session }); + await MongoPlugin.findByIdAndUpdate(id, updateData, { session }); }); jsonRes(res, {}); } else { jsonRes(res, { - data: await MongoPlugin.findByIdAndUpdate(id, props) + data: await MongoPlugin.findByIdAndUpdate(id, updateData) }); } } catch (err) { diff --git a/projects/app/src/pages/price/components/FAQ.tsx b/projects/app/src/pages/price/components/FAQ.tsx index afec6fead763..9c9519ee7790 100644 --- a/projects/app/src/pages/price/components/FAQ.tsx +++ b/projects/app/src/pages/price/components/FAQ.tsx @@ -35,7 +35,7 @@ const FAQ = () => { }, { title: '免费版数据会清除么?', - desc: '免费版用户(免费版且未购买额外套餐)15天无使用记录后,系统会自动清除账号下所有知识库内容。' + desc: '免费版用户(免费版且未购买额外套餐)30天无使用记录后,系统会自动清除账号下所有知识库内容。' } ];