diff --git a/docSite/content/zh-cn/docs/development/upgrading/4815.md b/docSite/content/zh-cn/docs/development/upgrading/4815.md index 74d63d47d03d..44518c10a0a5 100644 --- a/docSite/content/zh-cn/docs/development/upgrading/4815.md +++ b/docSite/content/zh-cn/docs/development/upgrading/4815.md @@ -40,6 +40,18 @@ curl --location --request POST 'https://{{host}}/api/admin/initv4815' \ 会重置应用定时执行的字段,把 null 去掉,减少索引大小。 +---- + +从任意终端,发起 1 个 HTTP 请求。其中 {{rootkey}} 替换成环境变量里的 `rootkey`;{{host}} 替换成**FastGPT 域名**。 + +```bash +curl --location --request POST 'https://{{host}}/api/admin/refreshFreeUser' \ +--header 'rootkey: {{rootkey}}' \ +--header 'Content-Type: application/json' +``` + +重新计算一次免费版用户的时长,之前有版本升级时没有重新计算时间,导致会误发通知。 + ## 完整更新内容 diff --git a/docSite/content/zh-cn/docs/development/upgrading/4816.md b/docSite/content/zh-cn/docs/development/upgrading/4816.md index d82335aba0a6..1ad3e672ead3 100644 --- a/docSite/content/zh-cn/docs/development/upgrading/4816.md +++ b/docSite/content/zh-cn/docs/development/upgrading/4816.md @@ -12,4 +12,9 @@ weight: 808 1. 2. 新增 - 商业版支持 API 知识库和链接集合定时同步。 -3. 修复 - 站点同步知识库,链接同步时未使用选择器。 \ No newline at end of file +3. 优化 - 工作流/简易模式变量初始化代码,去除监听初始化,避免因渲染顺序不一致导致的失败。 +4. 修复 - 无法自动切换默认语言。增加分享链接,强制执行一次切换默认语言。 +5. 修复 - 数组选择器自动兼容 4.8.13 以前的数据。 +6. 修复 - 站点同步知识库,链接同步时未使用选择器。 +7. 修复 - 简易模式转工作流,没有把系统配置项转化。 +8. 修复 - 插件独立运行,变量初始值未赋上。 \ No newline at end of file diff --git a/packages/global/common/string/tools.ts b/packages/global/common/string/tools.ts index bc324c804e85..9616163057f1 100644 --- a/packages/global/common/string/tools.ts +++ b/packages/global/common/string/tools.ts @@ -29,7 +29,7 @@ export const simpleText = (text = '') => { replace {{variable}} to value */ export function replaceVariable(text: any, obj: Record) { - if (!(typeof text === 'string')) return text; + if (typeof text !== 'string') return text; for (const key in obj) { const val = obj[key]; diff --git a/packages/global/core/workflow/runtime/utils.ts b/packages/global/core/workflow/runtime/utils.ts index 54e4c372bf4f..a903607df9fc 100644 --- a/packages/global/core/workflow/runtime/utils.ts +++ b/packages/global/core/workflow/runtime/utils.ts @@ -251,6 +251,7 @@ export const getReferenceVariableValue = ({ return variables[outputId]; } + // 避免 value 刚好就是二个元素的字符串数组 const node = nodes.find((node) => node.nodeId === sourceNodeId); if (!node) { return value; diff --git a/packages/web/components/common/MySelect/MultipleRowSelect.tsx b/packages/web/components/common/MySelect/MultipleRowSelect.tsx index 64ad94678cd4..20fa6c049ab2 100644 --- a/packages/web/components/common/MySelect/MultipleRowSelect.tsx +++ b/packages/web/components/common/MySelect/MultipleRowSelect.tsx @@ -193,6 +193,18 @@ export const MultipleRowArraySelect = ({ ref: ref, handler: onClose }); + const onChange = useCallback( + (val: any[][]) => { + // Filter invalid value + const validList = val.filter((item) => { + const listItem = list.find((v) => v.value === item[0]); + if (!listItem) return false; + return listItem.children?.some((v) => v.value === item[1]); + }); + onSelect(validList); + }, + [onSelect] + ); const RenderList = useCallback( ({ index, list }: { index: number; list: MultipleSelectProps['list'] }) => { @@ -213,9 +225,9 @@ export const MultipleRowArraySelect = ({ const newValue = [parentValue, item.value]; if (newValues.some((v) => v[0] === parentValue && v[1] === item.value)) { - onSelect(newValues.filter((v) => !(v[0] === parentValue && v[1] === item.value))); + onChange(newValues.filter((v) => !(v[0] === parentValue && v[1] === item.value))); } else { - onSelect([...newValues, newValue]); + onChange([...newValues, newValue]); } } }; diff --git a/packages/web/hooks/useI18n.ts b/packages/web/hooks/useI18n.ts index 1c41b1dddce5..50676971a97d 100644 --- a/packages/web/hooks/useI18n.ts +++ b/packages/web/hooks/useI18n.ts @@ -43,14 +43,16 @@ export const useI18nLng = () => { setLang(lang); await i18n?.changeLanguage?.(lang); - if (prevLang && prevLang !== lang) { + + if (!i18n.hasResourceBundle(lang, 'common') && prevLang !== lang) { window?.location?.reload?.(); } }; - const setUserDefaultLng = () => { + const setUserDefaultLng = (forceGetDefaultLng: boolean = false) => { if (!navigator || !localStorage) return; - if (getLang()) return onChangeLng(getLang() as string); + + if (getLang() && !forceGetDefaultLng) return onChangeLng(getLang() as string); const lang = languageMap[navigator.language] || 'en'; diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/VariableInput.tsx b/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/VariableInput.tsx index 65db4389fe05..589db1051b58 100644 --- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/VariableInput.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/components/VariableInput.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useMemo } from 'react'; +import React, { useEffect } from 'react'; import { Controller, UseFormReturn } from 'react-hook-form'; import { useTranslation } from 'next-i18next'; import { Box, Button, Card, Textarea } from '@chakra-ui/react'; @@ -121,21 +121,7 @@ const VariableInput = ({ const variablesForm = useContextSelector(ChatItemContext, (v) => v.variablesForm); const variableList = useContextSelector(ChatBoxContext, (v) => v.variableList); - const { setValue, handleSubmit: handleSubmitChat } = variablesForm; - - const defaultValues = useMemo(() => { - return variableList.reduce((acc: Record, item) => { - acc[item.key] = item.defaultValue; - return acc; - }, {}); - }, [variableList]); - - useEffect(() => { - const values = variablesForm.getValues('variables'); - // If form is not empty, do not reset the variables - if (Object.values(values).filter(Boolean).length > 0) return; - setValue('variables', defaultValues); - }, [defaultValues, setValue, variablesForm]); + const { handleSubmit: handleSubmitChat } = variablesForm; return ( diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx b/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx index 807047f1cb0d..d23937a698a6 100644 --- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/index.tsx @@ -805,7 +805,7 @@ const ChatBox = ({ setQuestionGuide([]); setValue('chatStarted', false); abortRequest('leave'); - }, [abortRequest, setValue]); + }, [chatId, appId, abortRequest, setValue]); // Add listener useEffect(() => { diff --git a/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/RenderInput.tsx b/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/RenderInput.tsx index a0fc4a1a6b92..240a5a3815ba 100644 --- a/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/RenderInput.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/RenderInput.tsx @@ -110,17 +110,15 @@ const RenderInput = () => { return; } - const defaultFormValues = formatPluginInputs.reduce( - (acc, input) => { - acc[input.key] = input.defaultValue; - return acc; - }, - {} as Record - ); - reset({ files: [], - variables: defaultFormValues + variables: formatPluginInputs.reduce( + (acc, input) => { + acc[input.key] = input.defaultValue; + return acc; + }, + {} as Record + ) }); return; } @@ -164,7 +162,7 @@ const RenderInput = () => { files: historyFileList }); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [histories]); + }, [histories, formatPluginInputs]); const [uploading, setUploading] = useState(false); diff --git a/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/renderPluginInput.tsx b/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/renderPluginInput.tsx index d1733625ed13..23b45caa0939 100644 --- a/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/renderPluginInput.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/PluginRunBox/components/renderPluginInput.tsx @@ -172,7 +172,6 @@ const RenderPluginInput = ({ return (