Merge branch 'release/v0.2.8' of github.com:SuanmoSuanyangTechnology/MemoryBear into release/v0.2.8
This commit is contained in:
@@ -49,6 +49,7 @@ interface FormValues {
|
|||||||
memory?: boolean;
|
memory?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const max_file_count = 1;
|
||||||
const ChatToolbar = forwardRef<ChatToolbarRef, ChatToolbarProps>(({
|
const ChatToolbar = forwardRef<ChatToolbarRef, ChatToolbarProps>(({
|
||||||
features,
|
features,
|
||||||
extra,
|
extra,
|
||||||
@@ -136,8 +137,8 @@ const ChatToolbar = forwardRef<ChatToolbarRef, ChatToolbarProps>(({
|
|||||||
key: 'url',
|
key: 'url',
|
||||||
label: t('memoryConversation.addRemoteFile'),
|
label: t('memoryConversation.addRemoteFile'),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
if ((queryValues?.files?.length || 0) >= file_upload.max_file_count) {
|
if ((queryValues?.files?.length || 0) >= max_file_count) {
|
||||||
messageApi.warning(t('common.fileNumTip', { num: file_upload.max_file_count }))
|
messageApi.warning(t('common.fileNumTip', { num: max_file_count }))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
uploadFileListModalRef.current?.handleOpen()
|
uploadFileListModalRef.current?.handleOpen()
|
||||||
@@ -153,7 +154,7 @@ const ChatToolbar = forwardRef<ChatToolbarRef, ChatToolbarProps>(({
|
|||||||
onChange={fileChange}
|
onChange={fileChange}
|
||||||
requestConfig={uploadRequestConfig}
|
requestConfig={uploadRequestConfig}
|
||||||
featureConfig={file_upload}
|
featureConfig={file_upload}
|
||||||
disabled={(queryValues?.files?.length || 0) >= file_upload.max_file_count}
|
disabled={(queryValues?.files?.length || 0) >= max_file_count}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -185,7 +186,7 @@ const ChatToolbar = forwardRef<ChatToolbarRef, ChatToolbarProps>(({
|
|||||||
{file_upload?.audio_enabled && file_upload?.allowed_transfer_methods?.includes('local_file') && (
|
{file_upload?.audio_enabled && file_upload?.allowed_transfer_methods?.includes('local_file') && (
|
||||||
<Flex align="center">
|
<Flex align="center">
|
||||||
<AudioRecorder
|
<AudioRecorder
|
||||||
disabled={(queryValues?.files?.length || 0) >= file_upload.max_file_count}
|
disabled={(queryValues?.files?.length || 0) >= max_file_count}
|
||||||
action={uploadAction}
|
action={uploadAction}
|
||||||
requestConfig={uploadRequestConfig}
|
requestConfig={uploadRequestConfig}
|
||||||
onRecordingComplete={handleRecordingComplete}
|
onRecordingComplete={handleRecordingComplete}
|
||||||
|
|||||||
@@ -460,6 +460,7 @@ export const en = {
|
|||||||
nameInvalid: 'Name cannot start or end with a space',
|
nameInvalid: 'Name cannot start or end with a space',
|
||||||
notAllSpaces: 'Cannot be all spaces',
|
notAllSpaces: 'Cannot be all spaces',
|
||||||
view: 'View',
|
view: 'View',
|
||||||
|
callbackUrlInvalid: 'Please enter a valid URL',
|
||||||
},
|
},
|
||||||
model: {
|
model: {
|
||||||
searchPlaceholder: 'search model…',
|
searchPlaceholder: 'search model…',
|
||||||
|
|||||||
@@ -1093,6 +1093,7 @@ export const zh = {
|
|||||||
nameInvalid: '不能是空格开头或结尾',
|
nameInvalid: '不能是空格开头或结尾',
|
||||||
notAllSpaces: '不能是纯空格',
|
notAllSpaces: '不能是纯空格',
|
||||||
view: '查看',
|
view: '查看',
|
||||||
|
callbackUrlInvalid: '请输入有效的 URL',
|
||||||
},
|
},
|
||||||
model: {
|
model: {
|
||||||
searchPlaceholder: '搜索模型…',
|
searchPlaceholder: '搜索模型…',
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ interface FeaturesConfigModalProps {
|
|||||||
refresh: (value: FeaturesConfigForm) => void;
|
refresh: (value: FeaturesConfigForm) => void;
|
||||||
source?: Application['type'];
|
source?: Application['type'];
|
||||||
}
|
}
|
||||||
|
const max_file_count = 1;
|
||||||
/**
|
/**
|
||||||
* Modal for copying applications
|
* Modal for copying applications
|
||||||
*/
|
*/
|
||||||
@@ -133,7 +133,7 @@ const FeaturesConfigModal = forwardRef<FeaturesConfigModalRef, FeaturesConfigMod
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div className="rb:text-[12px] rb:text-[#5B6167] rb:py-1">{t('application.maxCount')}</div>
|
<div className="rb:text-[12px] rb:text-[#5B6167] rb:py-1">{t('application.maxCount')}</div>
|
||||||
{fu.max_file_count} {t('application.unix')}
|
{max_file_count} {t('application.unix')}
|
||||||
</div>
|
</div>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Button block onClick={handleOpenSettings}>{t('application.setting')}</Button>
|
<Button block onClick={handleOpenSettings}>{t('application.setting')}</Button>
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ const defaultValues: FileUpload = {
|
|||||||
"mp4",
|
"mp4",
|
||||||
"mov",
|
"mov",
|
||||||
],
|
],
|
||||||
max_file_count: 5,
|
max_file_count: 1,
|
||||||
allowed_transfer_methods: 'both'
|
allowed_transfer_methods: 'both'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,8 +167,8 @@ const FileUploadSettingModal = forwardRef<FileUploadSettingModalRef, FileUploadS
|
|||||||
</Radio.Group>
|
</Radio.Group>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<div className="rb:text-[12px] rb:text-[#5B6167] rb:mb-1">{t('application.maxCount')}</div>
|
{/* <div className="rb:text-[12px] rb:text-[#5B6167] rb:mb-1">{t('application.maxCount')}</div> */}
|
||||||
<Form.Item label={t('application.maxCount')} name="max_file_count">
|
<Form.Item label={t('application.maxCount')} name="max_file_count" hidden>
|
||||||
<InputNumber min={1} max={20} precision={0} className="rb:w-full!" placeholder={t('common.pleaseEnter')} />
|
<InputNumber min={1} max={20} precision={0} className="rb:w-full!" placeholder={t('common.pleaseEnter')} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,10 @@
|
|||||||
* @component
|
* @component
|
||||||
*/
|
*/
|
||||||
import { forwardRef, useImperativeHandle, useState, useMemo } from 'react';
|
import { forwardRef, useImperativeHandle, useState, useMemo } from 'react';
|
||||||
import { Form, Input, Select, Button, Flex } from 'antd';
|
import { Form, Input, Select,
|
||||||
|
// Button,
|
||||||
|
Flex
|
||||||
|
} from 'antd';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import type { UploadFileListModalRef } from '../types'
|
import type { UploadFileListModalRef } from '../types'
|
||||||
@@ -105,9 +108,11 @@ const UploadFileListModal = forwardRef<UploadFileListModalRef, UploadFileListMod
|
|||||||
onOk={handleSave}
|
onOk={handleSave}
|
||||||
confirmLoading={loading}
|
confirmLoading={loading}
|
||||||
>
|
>
|
||||||
<Form form={form} layout="vertical">
|
<Form form={form} layout="vertical" initialValues={{ files: [{ type: undefined, url: undefined }] }}>
|
||||||
<Form.List name="files">
|
<Form.List name="files">
|
||||||
{(fields, { add, remove }) => (
|
{(fields,
|
||||||
|
// { add, remove }
|
||||||
|
) => (
|
||||||
<>
|
<>
|
||||||
{/* Render each file entry with type selector and URL input */}
|
{/* Render each file entry with type selector and URL input */}
|
||||||
{fields.map(({ key, name, ...restField }) => (
|
{fields.map(({ key, name, ...restField }) => (
|
||||||
@@ -131,23 +136,23 @@ const UploadFileListModal = forwardRef<UploadFileListModalRef, UploadFileListMod
|
|||||||
name={[name, 'url']}
|
name={[name, 'url']}
|
||||||
rules={[
|
rules={[
|
||||||
{ required: true, message: t('common.pleaseEnter') },
|
{ required: true, message: t('common.pleaseEnter') },
|
||||||
{ type: 'url'}
|
{ type: 'url', message: t('common.callbackUrlInvalid') },
|
||||||
]}
|
]}
|
||||||
className="rb:mb-0! rb:flex-1!"
|
className="rb:mb-0! rb:flex-1!"
|
||||||
>
|
>
|
||||||
<Input placeholder={t('memoryConversation.fileUrl')} />
|
<Input placeholder={t('memoryConversation.fileUrl')} />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<div
|
{/* <div
|
||||||
className="rb:w-5 rb:h-5 rb:cursor-pointer rb:bg-cover rb:bg-[url('@/assets/images/delete.svg')] rb:hover:bg-[url('@/assets/images/delete_hover.svg')]"
|
className="rb:w-5 rb:h-5 rb:cursor-pointer rb:bg-cover rb:bg-[url('@/assets/images/delete.svg')] rb:hover:bg-[url('@/assets/images/delete_hover.svg')]"
|
||||||
onClick={() => remove(name)}
|
onClick={() => remove(name)}
|
||||||
></div>
|
></div> */}
|
||||||
</Flex>
|
</Flex>
|
||||||
))}
|
))}
|
||||||
<Form.Item noStyle>
|
{/* <Form.Item noStyle>
|
||||||
<Button type="dashed" onClick={() => add()} block>
|
<Button type="dashed" onClick={() => add()} block>
|
||||||
+ {t('common.add')}
|
+ {t('common.add')}
|
||||||
</Button>
|
</Button>
|
||||||
</Form.Item>
|
</Form.Item> */}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Form.List>
|
</Form.List>
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ const InitialValuePlugin: React.FC<InitialValuePluginProps> = ({ value, options
|
|||||||
const isUserInputRef = useRef(false);
|
const isUserInputRef = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 监听编辑器变化,标记是否为用户输入
|
const removeListener = editor.registerUpdateListener(({ editorState, tags }) => {
|
||||||
const removeListener = editor.registerUpdateListener(({ editorState }) => {
|
if (tags.has('programmatic')) return;
|
||||||
editorState.read(() => {
|
editorState.read(() => {
|
||||||
const root = $getRoot();
|
const root = $getRoot();
|
||||||
const textContent = root.getTextContent();
|
const textContent = root.getTextContent();
|
||||||
@@ -107,7 +107,7 @@ const InitialValuePlugin: React.FC<InitialValuePluginProps> = ({ value, options
|
|||||||
});
|
});
|
||||||
root.append(paragraph);
|
root.append(paragraph);
|
||||||
}
|
}
|
||||||
}, { discrete: true });
|
}, { discrete: true, tag: 'programmatic' });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user