diff --git a/src/renderer/src/components/CustomCollapse.tsx b/src/renderer/src/components/CustomCollapse.tsx index 9b0ba053..804c0352 100644 --- a/src/renderer/src/components/CustomCollapse.tsx +++ b/src/renderer/src/components/CustomCollapse.tsx @@ -7,6 +7,7 @@ interface CustomCollapseProps { children: React.ReactNode destroyInactivePanel?: boolean defaultActiveKey?: string[] + activeKey?: string[] collapsible?: 'header' | 'icon' | 'disabled' } @@ -16,6 +17,7 @@ const CustomCollapse: FC = ({ children, destroyInactivePanel = false, defaultActiveKey = ['1'], + activeKey, collapsible = undefined }) => { const CollapseStyle = { @@ -27,7 +29,10 @@ const CustomCollapse: FC = ({ header: { padding: '8px 16px', alignItems: 'center', - justifyContent: 'space-between' + justifyContent: 'space-between', + background: 'var(--color-background-soft)', + borderTopLeftRadius: '8px', + borderTopRightRadius: '8px' }, body: { borderTop: '0.5px solid var(--color-border)' @@ -38,6 +43,7 @@ const CustomCollapse: FC = ({ bordered={false} style={CollapseStyle} defaultActiveKey={defaultActiveKey} + activeKey={activeKey} destroyInactivePanel={destroyInactivePanel} collapsible={collapsible} items={[ diff --git a/src/renderer/src/components/DividerWithText.tsx b/src/renderer/src/components/DividerWithText.tsx index 0a160894..76455038 100644 --- a/src/renderer/src/components/DividerWithText.tsx +++ b/src/renderer/src/components/DividerWithText.tsx @@ -1,13 +1,14 @@ -import React from 'react' +import React, { CSSProperties } from 'react' import styled from 'styled-components' interface DividerWithTextProps { text: string + style?: CSSProperties } -const DividerWithText: React.FC = ({ text }) => { +const DividerWithText: React.FC = ({ text, style }) => { return ( - + {text} diff --git a/src/renderer/src/components/ListItem/index.tsx b/src/renderer/src/components/ListItem/index.tsx index 7e2165c5..56c05346 100644 --- a/src/renderer/src/components/ListItem/index.tsx +++ b/src/renderer/src/components/ListItem/index.tsx @@ -70,7 +70,7 @@ const TextContainer = styled.div` overflow: hidden; ` -const TitleText = styled.div` +const TitleText = styled.div<{ $active?: boolean }>` overflow: hidden; text-overflow: ellipsis; white-space: nowrap; diff --git a/src/renderer/src/components/ModelTagsWithLabel.tsx b/src/renderer/src/components/ModelTagsWithLabel.tsx index de92fdd7..bc2de857 100644 --- a/src/renderer/src/components/ModelTagsWithLabel.tsx +++ b/src/renderer/src/components/ModelTagsWithLabel.tsx @@ -85,8 +85,8 @@ const ModelTagsWithLabel: FC = ({ )} {showToolsCalling && isFunctionCallingModel(model) && ( - } tooltip={t('models.function_calling')}> - {_showLabel ? t('models.function_calling') : ''} + } tooltip={t('models.type.function_calling')}> + {_showLabel ? t('models.type.function_calling') : ''} )} {isEmbeddingModel(model) && ( diff --git a/src/renderer/src/i18n/locales/en-us.json b/src/renderer/src/i18n/locales/en-us.json index c8d0c447..067476e0 100644 --- a/src/renderer/src/i18n/locales/en-us.json +++ b/src/renderer/src/i18n/locales/en-us.json @@ -277,6 +277,7 @@ "duplicate": "Duplicate", "edit": "Edit", "expand": "Expand", + "collapse": "Collapse", "footnote": "Reference content", "footnotes": "References", "fullscreen": "Entered fullscreen mode. Press F11 to exit", diff --git a/src/renderer/src/i18n/locales/ja-jp.json b/src/renderer/src/i18n/locales/ja-jp.json index 062ec4cc..b08a31f4 100644 --- a/src/renderer/src/i18n/locales/ja-jp.json +++ b/src/renderer/src/i18n/locales/ja-jp.json @@ -277,6 +277,7 @@ "duplicate": "複製", "edit": "編集", "expand": "展開", + "collapse": "折りたたむ", "footnote": "引用内容", "footnotes": "脚注", "fullscreen": "全画面モードに入りました。F11キーで終了します", diff --git a/src/renderer/src/i18n/locales/ru-ru.json b/src/renderer/src/i18n/locales/ru-ru.json index 9e55694b..83cc3087 100644 --- a/src/renderer/src/i18n/locales/ru-ru.json +++ b/src/renderer/src/i18n/locales/ru-ru.json @@ -277,6 +277,7 @@ "duplicate": "Дублировать", "edit": "Редактировать", "expand": "Развернуть", + "collapse": "Свернуть", "footnote": "Цитируемый контент", "footnotes": "Сноски", "fullscreen": "Вы вошли в полноэкранный режим. Нажмите F11 для выхода", diff --git a/src/renderer/src/i18n/locales/zh-cn.json b/src/renderer/src/i18n/locales/zh-cn.json index 7a74a6b9..09790eb0 100644 --- a/src/renderer/src/i18n/locales/zh-cn.json +++ b/src/renderer/src/i18n/locales/zh-cn.json @@ -277,6 +277,7 @@ "duplicate": "复制", "edit": "编辑", "expand": "展开", + "collapse": "折叠", "footnote": "引用内容", "footnotes": "引用内容", "fullscreen": "已进入全屏模式,按 F11 退出", diff --git a/src/renderer/src/i18n/locales/zh-tw.json b/src/renderer/src/i18n/locales/zh-tw.json index a447874c..4754300f 100644 --- a/src/renderer/src/i18n/locales/zh-tw.json +++ b/src/renderer/src/i18n/locales/zh-tw.json @@ -277,6 +277,7 @@ "duplicate": "複製", "edit": "編輯", "expand": "展開", + "collapse": "折疊", "footnote": "引用內容", "footnotes": "引用", "fullscreen": "已進入全螢幕模式,按 F11 結束", diff --git a/src/renderer/src/pages/files/FileItem.tsx b/src/renderer/src/pages/files/FileItem.tsx index 13bc4f72..ce611ce9 100644 --- a/src/renderer/src/pages/files/FileItem.tsx +++ b/src/renderer/src/pages/files/FileItem.tsx @@ -93,7 +93,6 @@ const FileItem: React.FC = ({ fileInfo, style }) => { } const FileItemCard = styled.div` - background: rgba(255, 255, 255, 0.04); border-radius: 8px; overflow: hidden; border: 0.5px solid var(--color-border); diff --git a/src/renderer/src/pages/files/FilesPage.tsx b/src/renderer/src/pages/files/FilesPage.tsx index bbbb770a..3e4c8723 100644 --- a/src/renderer/src/pages/files/FilesPage.tsx +++ b/src/renderer/src/pages/files/FilesPage.tsx @@ -223,7 +223,7 @@ const ContentContainer = styled.div` ` const SideNav = styled.div` - width: var(--assistants-width); + width: var(--settings-width); border-right: 0.5px solid var(--color-border); padding: 7px 12px; user-select: none; diff --git a/src/renderer/src/pages/knowledge/KnowledgeContent.tsx b/src/renderer/src/pages/knowledge/KnowledgeContent.tsx index 866bb20f..bfc9b204 100644 --- a/src/renderer/src/pages/knowledge/KnowledgeContent.tsx +++ b/src/renderer/src/pages/knowledge/KnowledgeContent.tsx @@ -1,11 +1,13 @@ import { + ColumnHeightOutlined, CopyOutlined, DeleteOutlined, EditOutlined, PlusOutlined, RedoOutlined, SearchOutlined, - SettingOutlined + SettingOutlined, + VerticalAlignMiddleOutlined } from '@ant-design/icons' import CustomTag from '@renderer/components/CustomTag' import Ellipsis from '@renderer/components/Ellipsis' @@ -19,10 +21,10 @@ import { getProviderName } from '@renderer/services/ProviderService' import { FileType, FileTypes, KnowledgeBase, KnowledgeItem } from '@renderer/types' import { formatFileSize } from '@renderer/utils' import { bookExts, documentExts, textExts, thirdPartyApplicationExts } from '@shared/config/constant' -import { Alert, Button, Dropdown, Empty, Flex, message, Tooltip, Upload } from 'antd' +import { Alert, Button, Dropdown, Empty, message, Tag, Tooltip, Upload } from 'antd' import dayjs from 'dayjs' import VirtualList from 'rc-virtual-list' -import { FC } from 'react' +import { FC, useState } from 'react' import { useTranslation } from 'react-i18next' import styled from 'styled-components' @@ -42,6 +44,7 @@ const fileTypes = [...bookExts, ...thirdPartyApplicationExts, ...documentExts, . const KnowledgeContent: FC = ({ selectedBase }) => { const { t } = useTranslation() + const [expandAll, setExpandAll] = useState(false) const { base, @@ -230,366 +233,389 @@ const KnowledgeContent: FC = ({ selectedBase }) => { } return ( - - {!base?.version && ( - - )} - {!providerName && ( - - )} - - } - extra={ - - }> - handleDrop([file as File])} - multiple={true} - accept={fileTypes.join(',')} - style={{ marginTop: 10, background: 'transparent' }}> -

{t('knowledge.drag_file')}

-

- {t('knowledge.file_hint', { file_types: 'TXT, MD, HTML, PDF, DOCX, PPTX, XLSX, EPUB...' })} -

-
- - - {fileItems.length === 0 ? ( - - ) : ( - 5 ? 400 : fileItems.length * 75} - itemHeight={75} - itemKey="id" - styles={{ - verticalScrollBar: { - width: 6 - }, - verticalScrollBarThumb: { - background: 'var(--color-scrollbar-thumb)' - } - }}> - {(item) => { - const file = item.content as FileType - return ( -
- window.api.file.openPath(file.path)}> - - {file.origin_name} - - - ), - ext: file.ext, - extra: `${dayjs(file.created_at).format('MM-DD HH:mm')} · ${formatFileSize(file.size)}`, - actions: ( - - {item.uniqueId && ( -
- ) - }} -
- )} -
-
- - } - extra={ - - }> - - {directoryItems.length === 0 && } - {directoryItems.reverse().map((item) => ( - window.api.file.openPath(item.content as string)}> - - {item.content as string} - - - ), - ext: '.folder', - extra: `${dayjs(item.created_at).format('MM-DD HH:mm')}`, - actions: ( - - {item.uniqueId && - }> - - {urlItems.length === 0 && } - {urlItems.reverse().map((item) => ( - , - label: t('knowledge.edit_remark'), - onClick: () => handleEditRemark(item) - }, - { - key: 'copy', - icon: , - label: t('common.copy'), - onClick: () => { - navigator.clipboard.writeText(item.content as string) - message.success(t('message.copied')) - } - } - ] - }} - trigger={['contextMenu']}> - - - - - {item.remark || (item.content as string)} - - - - - - ), - ext: '.url', - extra: `${dayjs(item.created_at).format('MM-DD HH:mm')}`, - actions: ( - - {item.uniqueId && - }> - - {sitemapItems.length === 0 && } - {sitemapItems.reverse().map((item) => ( - - - - - {item.content as string} - - - - - ), - ext: '.sitemap', - extra: `${dayjs(item.created_at).format('MM-DD HH:mm')}`, - actions: ( - - {item.uniqueId && - }> - - {noteItems.length === 0 && } - {noteItems.reverse().map((note) => ( - handleEditNote(note)}>{(note.content as string).slice(0, 50)}..., - ext: '.txt', - extra: `${dayjs(note.created_at).format('MM-DD HH:mm')}`, - actions: ( - - - }> + + + + + + }> + handleDrop([file as File])} + multiple={true} + accept={fileTypes.join(',')} + style={{ marginTop: 10, background: 'transparent' }}> +

{t('knowledge.drag_file')}

+

+ {t('knowledge.file_hint', { file_types: 'TXT, MD, HTML, PDF, DOCX, PPTX, XLSX, EPUB...' })} +

+
- -
+ + {fileItems.length === 0 ? ( + + ) : ( + 5 ? 400 : fileItems.length * 75} + itemHeight={75} + itemKey="id" + styles={{ + verticalScrollBar: { + width: 6 + }, + verticalScrollBarThumb: { + background: 'var(--color-scrollbar-thumb)' + } + }}> + {(item) => { + const file = item.content as FileType + return ( +
+ window.api.file.openPath(file.path)}> + + {file.origin_name} + + + ), + ext: file.ext, + extra: `${dayjs(file.created_at).format('MM-DD HH:mm')} · ${formatFileSize(file.size)}`, + actions: ( + + {item.uniqueId && ( +
+ ) + }} +
+ )} +
+ + + } + defaultActiveKey={[]} + activeKey={expandAll ? ['1'] : undefined} + extra={ + + }> + + {directoryItems.length === 0 && } + {directoryItems.reverse().map((item) => ( + window.api.file.openPath(item.content as string)}> + + {item.content as string} + + + ), + ext: '.folder', + extra: `${dayjs(item.created_at).format('MM-DD HH:mm')}`, + actions: ( + + {item.uniqueId && + }> + + {urlItems.length === 0 && } + {urlItems.reverse().map((item) => ( + , + label: t('knowledge.edit_remark'), + onClick: () => handleEditRemark(item) + }, + { + key: 'copy', + icon: , + label: t('common.copy'), + onClick: () => { + navigator.clipboard.writeText(item.content as string) + message.success(t('message.copied')) + } + } + ] + }} + trigger={['contextMenu']}> + + + + + {item.remark || (item.content as string)} + + + + + + ), + ext: '.url', + extra: `${dayjs(item.created_at).format('MM-DD HH:mm')}`, + actions: ( + + {item.uniqueId && + }> + + {sitemapItems.length === 0 && } + {sitemapItems.reverse().map((item) => ( + + + + + {item.content as string} + + + + + ), + ext: '.sitemap', + extra: `${dayjs(item.created_at).format('MM-DD HH:mm')}`, + actions: ( + + {item.uniqueId && + }> + + {noteItems.length === 0 && } + {noteItems.reverse().map((note) => ( + handleEditNote(note)}>{(note.content as string).slice(0, 50)}..., + ext: '.txt', + extra: `${dayjs(note.created_at).format('MM-DD HH:mm')}`, + actions: ( + +