mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-22 17:00:14 +08:00
fix: display updated timestamp when available in knowledge base (#7453)
* fix: display updated timestamp when available in knowledge base - Add updated_at field when creating knowledge items - Show updated_at timestamp if it's newer than created_at - Fallback to created_at if updated_at is not available or older Fixes #4587 Signed-off-by: Ying-xi <62348590+Ying-xi@users.noreply.github.com> * refactor(knowledge): extract display time logic into a reusable function Signed-off-by: Ying-xi <62348590+Ying-xi@users.noreply.github.com> --------- Signed-off-by: Ying-xi <62348590+Ying-xi@users.noreply.github.com>
This commit is contained in:
parent
bbe380cc9e
commit
f69ea8648c
@ -169,7 +169,8 @@ export const useKnowledge = (baseId: string) => {
|
|||||||
processingStatus: 'pending',
|
processingStatus: 'pending',
|
||||||
processingProgress: 0,
|
processingProgress: 0,
|
||||||
processingError: '',
|
processingError: '',
|
||||||
uniqueId: undefined
|
uniqueId: undefined,
|
||||||
|
updated_at: Date.now()
|
||||||
})
|
})
|
||||||
setTimeout(() => KnowledgeQueue.checkAllBases(), 0)
|
setTimeout(() => KnowledgeQueue.checkAllBases(), 0)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,11 @@ interface KnowledgeContentProps {
|
|||||||
|
|
||||||
const fileTypes = [...bookExts, ...thirdPartyApplicationExts, ...documentExts, ...textExts]
|
const fileTypes = [...bookExts, ...thirdPartyApplicationExts, ...documentExts, ...textExts]
|
||||||
|
|
||||||
|
const getDisplayTime = (item: KnowledgeItem) => {
|
||||||
|
const timestamp = item.updated_at && item.updated_at > item.created_at ? item.updated_at : item.created_at
|
||||||
|
return dayjs(timestamp).format('MM-DD HH:mm')
|
||||||
|
}
|
||||||
|
|
||||||
const KnowledgeContent: FC<KnowledgeContentProps> = ({ selectedBase }) => {
|
const KnowledgeContent: FC<KnowledgeContentProps> = ({ selectedBase }) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [expandAll, setExpandAll] = useState(false)
|
const [expandAll, setExpandAll] = useState(false)
|
||||||
@ -335,7 +340,7 @@ const KnowledgeContent: FC<KnowledgeContentProps> = ({ selectedBase }) => {
|
|||||||
</ClickableSpan>
|
</ClickableSpan>
|
||||||
),
|
),
|
||||||
ext: file.ext,
|
ext: file.ext,
|
||||||
extra: `${dayjs(file.created_at).format('MM-DD HH:mm')} · ${formatFileSize(file.size)}`,
|
extra: `${getDisplayTime(item)} · ${formatFileSize(file.size)}`,
|
||||||
actions: (
|
actions: (
|
||||||
<FlexAlignCenter>
|
<FlexAlignCenter>
|
||||||
{item.uniqueId && (
|
{item.uniqueId && (
|
||||||
@ -392,7 +397,7 @@ const KnowledgeContent: FC<KnowledgeContentProps> = ({ selectedBase }) => {
|
|||||||
</ClickableSpan>
|
</ClickableSpan>
|
||||||
),
|
),
|
||||||
ext: '.folder',
|
ext: '.folder',
|
||||||
extra: `${dayjs(item.created_at).format('MM-DD HH:mm')}`,
|
extra: getDisplayTime(item),
|
||||||
actions: (
|
actions: (
|
||||||
<FlexAlignCenter>
|
<FlexAlignCenter>
|
||||||
{item.uniqueId && <Button type="text" icon={<RefreshIcon />} onClick={() => refreshItem(item)} />}
|
{item.uniqueId && <Button type="text" icon={<RefreshIcon />} onClick={() => refreshItem(item)} />}
|
||||||
@ -470,7 +475,7 @@ const KnowledgeContent: FC<KnowledgeContentProps> = ({ selectedBase }) => {
|
|||||||
</Dropdown>
|
</Dropdown>
|
||||||
),
|
),
|
||||||
ext: '.url',
|
ext: '.url',
|
||||||
extra: `${dayjs(item.created_at).format('MM-DD HH:mm')}`,
|
extra: getDisplayTime(item),
|
||||||
actions: (
|
actions: (
|
||||||
<FlexAlignCenter>
|
<FlexAlignCenter>
|
||||||
{item.uniqueId && <Button type="text" icon={<RefreshIcon />} onClick={() => refreshItem(item)} />}
|
{item.uniqueId && <Button type="text" icon={<RefreshIcon />} onClick={() => refreshItem(item)} />}
|
||||||
@ -525,7 +530,7 @@ const KnowledgeContent: FC<KnowledgeContentProps> = ({ selectedBase }) => {
|
|||||||
</ClickableSpan>
|
</ClickableSpan>
|
||||||
),
|
),
|
||||||
ext: '.sitemap',
|
ext: '.sitemap',
|
||||||
extra: `${dayjs(item.created_at).format('MM-DD HH:mm')}`,
|
extra: getDisplayTime(item),
|
||||||
actions: (
|
actions: (
|
||||||
<FlexAlignCenter>
|
<FlexAlignCenter>
|
||||||
{item.uniqueId && <Button type="text" icon={<RefreshIcon />} onClick={() => refreshItem(item)} />}
|
{item.uniqueId && <Button type="text" icon={<RefreshIcon />} onClick={() => refreshItem(item)} />}
|
||||||
@ -570,7 +575,7 @@ const KnowledgeContent: FC<KnowledgeContentProps> = ({ selectedBase }) => {
|
|||||||
fileInfo={{
|
fileInfo={{
|
||||||
name: <span onClick={() => handleEditNote(note)}>{(note.content as string).slice(0, 50)}...</span>,
|
name: <span onClick={() => handleEditNote(note)}>{(note.content as string).slice(0, 50)}...</span>,
|
||||||
ext: '.txt',
|
ext: '.txt',
|
||||||
extra: `${dayjs(note.created_at).format('MM-DD HH:mm')}`,
|
extra: getDisplayTime(note),
|
||||||
actions: (
|
actions: (
|
||||||
<FlexAlignCenter>
|
<FlexAlignCenter>
|
||||||
<Button type="text" onClick={() => handleEditNote(note)} icon={<EditOutlined />} />
|
<Button type="text" onClick={() => handleEditNote(note)} icon={<EditOutlined />} />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user