mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-05 04:19:02 +08:00
fix: add ellipsis in knowledge base item (#1718)
This commit is contained in:
parent
d574a09529
commit
2c5fe01fbf
26
src/renderer/src/components/Ellipsis/index.tsx
Normal file
26
src/renderer/src/components/Ellipsis/index.tsx
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import styled from 'styled-components'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
text: string | number
|
||||||
|
maxLine?: number
|
||||||
|
} & React.HTMLAttributes<HTMLDivElement>
|
||||||
|
|
||||||
|
const Ellipsis = (props: Props) => {
|
||||||
|
const { text, maxLine = 1, ...rest } = props
|
||||||
|
return (
|
||||||
|
<EllipsisContainer maxLine={maxLine} {...rest}>
|
||||||
|
{text}
|
||||||
|
</EllipsisContainer>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const EllipsisContainer = styled.div<{ maxLine: number }>`
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
-webkit-line-clamp: ${({ maxLine }) => maxLine};
|
||||||
|
`
|
||||||
|
|
||||||
|
export default Ellipsis
|
||||||
@ -10,6 +10,7 @@ import {
|
|||||||
SearchOutlined,
|
SearchOutlined,
|
||||||
SettingOutlined
|
SettingOutlined
|
||||||
} from '@ant-design/icons'
|
} from '@ant-design/icons'
|
||||||
|
import Ellipsis from '@renderer/components/Ellipsis'
|
||||||
import PromptPopup from '@renderer/components/Popups/PromptPopup'
|
import PromptPopup from '@renderer/components/Popups/PromptPopup'
|
||||||
import TextEditPopup from '@renderer/components/Popups/TextEditPopup'
|
import TextEditPopup from '@renderer/components/Popups/TextEditPopup'
|
||||||
import Scrollbar from '@renderer/components/Scrollbar'
|
import Scrollbar from '@renderer/components/Scrollbar'
|
||||||
@ -18,7 +19,7 @@ import FileManager from '@renderer/services/FileManager'
|
|||||||
import { getProviderName } from '@renderer/services/ProviderService'
|
import { getProviderName } from '@renderer/services/ProviderService'
|
||||||
import { FileType, FileTypes, KnowledgeBase } from '@renderer/types'
|
import { FileType, FileTypes, KnowledgeBase } from '@renderer/types'
|
||||||
import { documentExts, textExts } from '@shared/config/constant'
|
import { documentExts, textExts } from '@shared/config/constant'
|
||||||
import { Alert, Button, Card, Divider, message, Tag, Typography, Upload } from 'antd'
|
import { Alert, Button, Card, Divider, message, Tag, Tooltip, Typography, Upload } from 'antd'
|
||||||
import { FC } from 'react'
|
import { FC } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
@ -229,7 +230,11 @@ const KnowledgeContent: FC<KnowledgeContentProps> = ({ selectedBase }) => {
|
|||||||
<ItemContent>
|
<ItemContent>
|
||||||
<ItemInfo>
|
<ItemInfo>
|
||||||
<FileIcon />
|
<FileIcon />
|
||||||
<ClickableSpan onClick={() => window.api.file.openPath(file.path)}>{file.origin_name}</ClickableSpan>
|
<ClickableSpan onClick={() => window.api.file.openPath(file.path)}>
|
||||||
|
<Tooltip title={file.origin_name}>
|
||||||
|
<Ellipsis text={file.origin_name} />
|
||||||
|
</Tooltip>
|
||||||
|
</ClickableSpan>
|
||||||
</ItemInfo>
|
</ItemInfo>
|
||||||
<FlexAlignCenter>
|
<FlexAlignCenter>
|
||||||
{item.uniqueId && <Button type="text" icon={<RefreshIcon />} onClick={() => refreshItem(item)} />}
|
{item.uniqueId && <Button type="text" icon={<RefreshIcon />} onClick={() => refreshItem(item)} />}
|
||||||
@ -258,7 +263,9 @@ const KnowledgeContent: FC<KnowledgeContentProps> = ({ selectedBase }) => {
|
|||||||
<ItemInfo>
|
<ItemInfo>
|
||||||
<FolderOutlined />
|
<FolderOutlined />
|
||||||
<ClickableSpan onClick={() => window.api.file.openPath(item.content as string)}>
|
<ClickableSpan onClick={() => window.api.file.openPath(item.content as string)}>
|
||||||
{item.content as string}
|
<Tooltip title={item.content as string}>
|
||||||
|
<Ellipsis text={item.content as string} />
|
||||||
|
</Tooltip>
|
||||||
</ClickableSpan>
|
</ClickableSpan>
|
||||||
</ItemInfo>
|
</ItemInfo>
|
||||||
<FlexAlignCenter>
|
<FlexAlignCenter>
|
||||||
@ -288,7 +295,9 @@ const KnowledgeContent: FC<KnowledgeContentProps> = ({ selectedBase }) => {
|
|||||||
<ItemInfo>
|
<ItemInfo>
|
||||||
<LinkOutlined />
|
<LinkOutlined />
|
||||||
<a href={item.content as string} target="_blank" rel="noopener noreferrer">
|
<a href={item.content as string} target="_blank" rel="noopener noreferrer">
|
||||||
{item.content as string}
|
<Tooltip title={item.content as string}>
|
||||||
|
<Ellipsis text={item.content as string} />
|
||||||
|
</Tooltip>
|
||||||
</a>
|
</a>
|
||||||
</ItemInfo>
|
</ItemInfo>
|
||||||
<FlexAlignCenter>
|
<FlexAlignCenter>
|
||||||
@ -318,7 +327,9 @@ const KnowledgeContent: FC<KnowledgeContentProps> = ({ selectedBase }) => {
|
|||||||
<ItemInfo>
|
<ItemInfo>
|
||||||
<GlobalOutlined />
|
<GlobalOutlined />
|
||||||
<a href={item.content as string} target="_blank" rel="noopener noreferrer">
|
<a href={item.content as string} target="_blank" rel="noopener noreferrer">
|
||||||
{item.content as string}
|
<Tooltip title={item.content as string}>
|
||||||
|
<Ellipsis text={item.content as string} />
|
||||||
|
</Tooltip>
|
||||||
</a>
|
</a>
|
||||||
</ItemInfo>
|
</ItemInfo>
|
||||||
<FlexAlignCenter>
|
<FlexAlignCenter>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user