feat: added translation options for opening all files

This commit is contained in:
kangfenmao 2024-10-31 12:17:27 +08:00
parent 79f6d598ab
commit ca2a9ed84a
4 changed files with 16 additions and 7 deletions

View File

@ -167,7 +167,8 @@
"text": "Text",
"document": "Document",
"actions": "Actions",
"open": "Open"
"open": "Open",
"all": "All Files"
},
"agents": {
"title": "Agents",

View File

@ -167,7 +167,8 @@
"text": "文本",
"document": "文档",
"actions": "操作",
"open": "打开"
"open": "打开",
"all": "所有文件"
},
"agents": {
"title": "智能体",
@ -284,7 +285,7 @@
"provider.search_placeholder": "搜索模型 ID 或名称",
"provider.api.url.reset": "重置",
"provider.api.url.preview": "预览: {{url}}",
"provider.api.url.tip": "/结尾忽略v1版本#结尾制使用输入地址",
"provider.api.url.tip": "/结尾忽略v1版本#结尾<EFBFBD><EFBFBD>制使用输入地址",
"models.default_assistant_model": "默认助手模型",
"models.topic_naming_model": "话题命名模型",
"models.translate_model": "翻译模型",

View File

@ -167,7 +167,8 @@
"text": "文本",
"document": "文檔",
"actions": "操作",
"open": "打開"
"open": "打開",
"all": "所有檔案"
},
"agents": {
"title": "智能體",

View File

@ -14,9 +14,14 @@ import styled from 'styled-components'
const FilesPage: FC = () => {
const { t } = useTranslation()
const [fileType, setFileType] = useState<FileTypes>(FileTypes.IMAGE)
const [fileType, setFileType] = useState<FileTypes | 'all'>('all')
const files = useLiveQuery<FileType[]>(() => db.files.where('type').equals(fileType).sortBy('count'), [fileType])
const files = useLiveQuery<FileType[]>(() => {
if (fileType === 'all') {
return db.files.orderBy('count').toArray()
}
return db.files.where('type').equals(fileType).sortBy('count')
}, [fileType])
const dataSource = files?.map((file) => {
return {
@ -62,6 +67,7 @@ const FilesPage: FC = () => {
]
const menuItems = [
{ key: 'all', label: t('files.all'), icon: <FileTextOutlined /> },
{ key: FileTypes.IMAGE, label: t('files.image'), icon: <FileImageOutlined /> },
{ key: FileTypes.TEXT, label: t('files.text'), icon: <FileTextOutlined /> },
{ key: FileTypes.DOCUMENT, label: t('files.document'), icon: <FilePdfOutlined /> }
@ -77,7 +83,7 @@ const FilesPage: FC = () => {
<Menu selectedKeys={[fileType]} items={menuItems} onSelect={({ key }) => setFileType(key as FileTypes)} />
</SideNav>
<TableContainer right>
{fileType === FileTypes.IMAGE ? (
{fileType === FileTypes.IMAGE && files?.length > 0 ? (
<Image.PreviewGroup>
<Row gutter={[16, 16]}>
{files?.map((file) => (