fix(theme): citation list dark theme display & url repeatedly requesting (#5752)

* fix(theme): citation list dark theme  display

* fix: 减少属性变量及反复请求

* fix: update react-query
This commit is contained in:
自由的世界人 2025-05-08 17:24:04 +08:00 committed by GitHub
parent 875d20d34c
commit 1f96b326b6
3 changed files with 43 additions and 133 deletions

View File

@ -71,6 +71,7 @@
"@electron/notarize": "^2.5.0",
"@langchain/community": "^0.3.36",
"@strongtz/win32-arm64-msvc": "^0.4.7",
"@tanstack/react-query": "^5.27.0",
"@types/react-infinite-scroll-component": "^5.0.0",
"adm-zip": "^0.5.16",
"archiver": "^7.0.1",
@ -96,7 +97,6 @@
"opendal": "^0.47.11",
"os-proxy-config": "^1.1.2",
"proxy-agent": "^6.5.0",
"react-query": "^3.39.3",
"tar": "^7.4.3",
"turndown": "^7.2.0",
"turndown-plugin-gfm": "^1.0.2",

View File

@ -1,11 +1,11 @@
import Favicon from '@renderer/components/Icons/FallbackFavicon'
import { HStack } from '@renderer/components/Layout'
import { fetchWebContent } from '@renderer/utils/fetch'
import { QueryClient, QueryClientProvider, useQuery } from '@tanstack/react-query'
import { Button, Drawer } from 'antd'
import { FileSearch } from 'lucide-react'
import React, { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { QueryClient, QueryClientProvider } from 'react-query'
import styled from 'styled-components'
export interface Citation {
@ -26,7 +26,7 @@ const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: Infinity,
cacheTime: Infinity,
gcTime: Infinity,
refetchOnWindowFocus: false,
retry: false
}
@ -90,8 +90,7 @@ const CitationsList: React.FC<CitationsListProps> = ({ citations }) => {
onClose={() => setOpen(false)}
open={open}
width={680}
destroyOnClose={true} // unmount on close
>
destroyOnClose={false}>
{open &&
citations.map((citation) => (
<HStack key={citation.url || citation.number} style={{ alignItems: 'center', gap: 8, marginBottom: 12 }}>
@ -116,19 +115,17 @@ const handleLinkClick = (url: string, event: React.MouseEvent) => {
const WebSearchCitation: React.FC<{ citation: Citation }> = ({ citation }) => {
const { t } = useTranslation()
const [fetchedContent, setFetchedContent] = React.useState('')
const [isLoading, setIsLoading] = React.useState(false)
React.useEffect(() => {
if (citation.url) {
setIsLoading(true)
fetchWebContent(citation.url, 'markdown')
.then((res) => {
const cleaned = cleanMarkdownContent(res.content)
setFetchedContent(truncateText(cleaned, 100))
})
.finally(() => setIsLoading(false))
}
}, [citation.url])
const { data: fetchedContent, isLoading } = useQuery({
queryKey: ['webContent', citation.url],
queryFn: async () => {
if (!citation.url) return ''
const res = await fetchWebContent(citation.url, 'markdown')
return cleanMarkdownContent(res.content)
},
enabled: Boolean(citation.url),
select: (content) => truncateText(content, 100)
})
return (
<WebSearchCard>
@ -180,8 +177,8 @@ const PreviewIcon = styled.div`
display: flex;
align-items: center;
justify-content: center;
background: #f0f2f5;
border: 1px solid #e1e4e8;
background: var(--color-background-soft);
border: 1px solid var(--color-border);
margin-left: -8px;
color: var(--color-text-2);
@ -212,14 +209,14 @@ const WebSearchCard = styled.div`
padding: 12px;
margin-bottom: 8px;
border-radius: 8px;
border: 1px solid #e5e6eb;
background-color: #f8f9fa;
border: 1px solid var(--color-border);
background-color: var(--color-background);
transition: all 0.3s ease;
&:hover {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
background-color: #f1f3f5;
border-color: rgba(24, 144, 255, 0.1);
box-shadow: 0 4px 12px var(--color-border-soft);
background-color: var(--color-hover);
border-color: var(--color-primary-soft);
transform: translateY(-2px);
}
`

129
yarn.lock
View File

@ -383,13 +383,6 @@ __metadata:
languageName: node
linkType: hard
"@babel/runtime@npm:^7.23.8, @babel/runtime@npm:^7.5.5, @babel/runtime@npm:^7.6.2":
version: 7.27.1
resolution: "@babel/runtime@npm:7.27.1"
checksum: 10c0/530a7332f86ac5a7442250456823a930906911d895c0b743bf1852efc88a20a016ed4cd26d442d0ca40ae6d5448111e02a08dd638a4f1064b47d080e2875dc05
languageName: node
linkType: hard
"@babel/template@npm:^7.26.9, @babel/template@npm:^7.27.0":
version: 7.27.0
resolution: "@babel/template@npm:7.27.0"
@ -3556,6 +3549,24 @@ __metadata:
languageName: node
linkType: hard
"@tanstack/query-core@npm:5.75.5":
version: 5.75.5
resolution: "@tanstack/query-core@npm:5.75.5"
checksum: 10c0/3627f9580df5b4a032ff830c1b1f6fa55ae754962a6aaab4ee79607917c9fbd98ce8f7302cc4c88e5b19fd6378689163eb42f32a83c05fe2dc81e7899c94d0df
languageName: node
linkType: hard
"@tanstack/react-query@npm:^5.27.0":
version: 5.75.5
resolution: "@tanstack/react-query@npm:5.75.5"
dependencies:
"@tanstack/query-core": "npm:5.75.5"
peerDependencies:
react: ^18 || ^19
checksum: 10c0/658e6b36577c531659e19da19ce46005ae36e17517409f4105c4e9181b7ec2ac21bd6d1e2415b8e16004fdd4f7c51b724af1327834b16f1d037edabeaf9b1cbc
languageName: node
linkType: hard
"@tavily/core@npm:0.3.1":
version: 0.3.1
resolution: "@tavily/core@npm:0.3.1"
@ -4393,6 +4404,7 @@ __metadata:
"@shikijs/markdown-it": "npm:^3.2.2"
"@strongtz/win32-arm64-msvc": "npm:^0.4.7"
"@swc/plugin-styled-components": "npm:^7.1.3"
"@tanstack/react-query": "npm:^5.27.0"
"@tavily/core": "patch:@tavily/core@npm%3A0.3.1#~/.yarn/patches/@tavily-core-npm-0.3.1-fe69bf2bea.patch"
"@tryfabric/martian": "npm:^1.2.4"
"@types/adm-zip": "npm:^0"
@ -4475,7 +4487,6 @@ __metadata:
react-i18next: "npm:^14.1.2"
react-infinite-scroll-component: "npm:^6.1.0"
react-markdown: "npm:^9.0.1"
react-query: "npm:^3.39.3"
react-redux: "npm:^9.1.2"
react-router: "npm:6"
react-router-dom: "npm:6"
@ -5124,13 +5135,6 @@ __metadata:
languageName: node
linkType: hard
"big-integer@npm:^1.6.16":
version: 1.6.52
resolution: "big-integer@npm:1.6.52"
checksum: 10c0/9604224b4c2ab3c43c075d92da15863077a9f59e5d4205f4e7e76acd0cd47e8d469ec5e5dba8d9b32aa233951893b29329ca56ac80c20ce094b4a647a66abae0
languageName: node
linkType: hard
"bignumber.js@npm:^9.0.0":
version: 9.2.1
resolution: "bignumber.js@npm:9.2.1"
@ -5248,22 +5252,6 @@ __metadata:
languageName: node
linkType: hard
"broadcast-channel@npm:^3.4.1":
version: 3.7.0
resolution: "broadcast-channel@npm:3.7.0"
dependencies:
"@babel/runtime": "npm:^7.7.2"
detect-node: "npm:^2.1.0"
js-sha3: "npm:0.8.0"
microseconds: "npm:0.2.0"
nano-time: "npm:1.0.0"
oblivious-set: "npm:1.0.0"
rimraf: "npm:3.0.2"
unload: "npm:2.2.0"
checksum: 10c0/95978446f24c685be666f5508a91350bcd4075c08feda929d26c0c678fb24bd421901f19fa8d36cb6f5ed480a334072f3bdce48fa177a8cb29793d88693911cc
languageName: node
linkType: hard
"browser-image-compression@npm:^2.0.2":
version: 2.0.2
resolution: "browser-image-compression@npm:2.0.2"
@ -6717,7 +6705,7 @@ __metadata:
languageName: node
linkType: hard
"detect-node@npm:^2.0.4, detect-node@npm:^2.1.0":
"detect-node@npm:^2.0.4":
version: 2.1.0
resolution: "detect-node@npm:2.1.0"
checksum: 10c0/f039f601790f2e9d4654e499913259a798b1f5246ae24f86ab5e8bd4aaf3bce50484234c494f11fb00aecb0c6e2733aa7b1cf3f530865640b65fbbd65b2c4e09
@ -10253,13 +10241,6 @@ __metadata:
languageName: node
linkType: hard
"js-sha3@npm:0.8.0":
version: 0.8.0
resolution: "js-sha3@npm:0.8.0"
checksum: 10c0/43a21dc7967c871bd2c46cb1c2ae97441a97169f324e509f382d43330d8f75cf2c96dba7c806ab08a425765a9c847efdd4bffbac2d99c3a4f3de6c0218f40533
languageName: node
linkType: hard
"js-tiktoken@npm:^1.0.12, js-tiktoken@npm:^1.0.14":
version: 1.0.19
resolution: "js-tiktoken@npm:1.0.19"
@ -11163,16 +11144,6 @@ __metadata:
languageName: node
linkType: hard
"match-sorter@npm:^6.0.2":
version: 6.3.4
resolution: "match-sorter@npm:6.3.4"
dependencies:
"@babel/runtime": "npm:^7.23.8"
remove-accents: "npm:0.5.0"
checksum: 10c0/35d2a6b6df003c677d9ec87ecd4683657638f5bce856f43f9cf90b03e357ed2f09813ebbac759defa7e7438706936dd34dc2bfe1a18771f7d2541f14d639b4ad
languageName: node
linkType: hard
"matcher@npm:^3.0.0":
version: 3.0.0
resolution: "matcher@npm:3.0.0"
@ -12108,13 +12079,6 @@ __metadata:
languageName: node
linkType: hard
"microseconds@npm:0.2.0":
version: 0.2.0
resolution: "microseconds@npm:0.2.0"
checksum: 10c0/59dfae1c696c0bacd79603c4df7cd0dcc9e091b7c5556aaca9b0832017d3c0b40ad8f57ca25e0ee5709ef1973404448c4a2fea6c9c1fad7d9e197ff5c1c9c2d5
languageName: node
linkType: hard
"mime-db@npm:1.52.0":
version: 1.52.0
resolution: "mime-db@npm:1.52.0"
@ -12462,15 +12426,6 @@ __metadata:
languageName: node
linkType: hard
"nano-time@npm:1.0.0":
version: 1.0.0
resolution: "nano-time@npm:1.0.0"
dependencies:
big-integer: "npm:^1.6.16"
checksum: 10c0/3bd12e0bcd30867178afdbe8053b3dde5fdd1c665ecd348bf879863049344fbaf05cbb1d7806a825b91efbca011ee115eee52e76fb38b7da9c97931cd9e61f15
languageName: node
linkType: hard
"nanoid@npm:^3.3.7, nanoid@npm:^3.3.8":
version: 3.3.11
resolution: "nanoid@npm:3.3.11"
@ -12810,13 +12765,6 @@ __metadata:
languageName: node
linkType: hard
"oblivious-set@npm:1.0.0":
version: 1.0.0
resolution: "oblivious-set@npm:1.0.0"
checksum: 10c0/ca8640474ea1e1feb3b5c98d42f5649f114ac4513ef84774e724f22fc7e529f1de3e7f26a0d9593097ab8942ca0bb8c241f7c1bd63c3e33047dd49de3aca9805
languageName: node
linkType: hard
"office-text-extractor@npm:^3.0.3":
version: 3.0.3
resolution: "office-text-extractor@npm:3.0.3"
@ -14654,24 +14602,6 @@ __metadata:
languageName: node
linkType: hard
"react-query@npm:^3.39.3":
version: 3.39.3
resolution: "react-query@npm:3.39.3"
dependencies:
"@babel/runtime": "npm:^7.5.5"
broadcast-channel: "npm:^3.4.1"
match-sorter: "npm:^6.0.2"
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0
peerDependenciesMeta:
react-dom:
optional: true
react-native:
optional: true
checksum: 10c0/319045ef31b9b02aa9b5446169a8c6f95cfe49406466b819cc85e41c29bfe5032d3732577efe56511278db41514772375d416a3e3976e8967c6e0972ff04dd2e
languageName: node
linkType: hard
"react-redux@npm:^8.1.3":
version: 8.1.3
resolution: "react-redux@npm:8.1.3"
@ -15092,13 +15022,6 @@ __metadata:
languageName: node
linkType: hard
"remove-accents@npm:0.5.0":
version: 0.5.0
resolution: "remove-accents@npm:0.5.0"
checksum: 10c0/a75321aa1b53d9abe82637115a492770bfe42bb38ed258be748bf6795871202bc8b4badff22013494a7029f5a241057ad8d3f72adf67884dbe15a9e37e87adc4
languageName: node
linkType: hard
"repeat-string@npm:^1.0.0":
version: 1.6.1
resolution: "repeat-string@npm:1.6.1"
@ -15300,7 +15223,7 @@ __metadata:
languageName: node
linkType: hard
"rimraf@npm:3.0.2, rimraf@npm:^3.0.2":
"rimraf@npm:^3.0.2":
version: 3.0.2
resolution: "rimraf@npm:3.0.2"
dependencies:
@ -17208,16 +17131,6 @@ __metadata:
languageName: node
linkType: hard
"unload@npm:2.2.0":
version: 2.2.0
resolution: "unload@npm:2.2.0"
dependencies:
"@babel/runtime": "npm:^7.6.2"
detect-node: "npm:^2.0.4"
checksum: 10c0/0a4f86b502e7aa35d39c27373ebeaad4f2b7da793fb3d6308e5337aab541885cfe7b339ea4a1963477bf73fddabd5d69f4f47023dad71224b4b4a25611ef7dd8
languageName: node
linkType: hard
"unpipe@npm:1.0.0":
version: 1.0.0
resolution: "unpipe@npm:1.0.0"