Skip to content

Commit

Permalink
feat: added translation options for opening all files
Browse files Browse the repository at this point in the history
  • Loading branch information
kangfenmao committed Oct 31, 2024
1 parent 79f6d59 commit ca2a9ed
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/renderer/src/i18n/locales/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@
"text": "Text",
"document": "Document",
"actions": "Actions",
"open": "Open"
"open": "Open",
"all": "All Files"
},
"agents": {
"title": "Agents",
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/src/i18n/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@
"text": "文本",
"document": "文档",
"actions": "操作",
"open": "打开"
"open": "打开",
"all": "所有文件"
},
"agents": {
"title": "智能体",
Expand Down Expand Up @@ -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版本,#结尾��制使用输入地址",
"models.default_assistant_model": "默认助手模型",
"models.topic_naming_model": "话题命名模型",
"models.translate_model": "翻译模型",
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/src/i18n/locales/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@
"text": "文本",
"document": "文檔",
"actions": "操作",
"open": "打開"
"open": "打開",
"all": "所有檔案"
},
"agents": {
"title": "智能體",
Expand Down
12 changes: 9 additions & 3 deletions src/renderer/src/pages/files/FilesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 /> }
Expand All @@ -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) => (
Expand Down

0 comments on commit ca2a9ed

Please sign in to comment.