mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2026-04-13 08:00:30 +08:00
Compare commits
2 Commits
06591b50f4
...
2698f36868
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2698f36868 | ||
|
|
58a11fa232 |
@ -107,7 +107,8 @@ async function findDesktopFile(appPath: string): Promise<string | null> {
|
|||||||
execCmd === appPath ||
|
execCmd === appPath ||
|
||||||
execBasename === execName ||
|
execBasename === execName ||
|
||||||
execCmd.endsWith(appPath) ||
|
execCmd.endsWith(appPath) ||
|
||||||
appPath.endsWith(execBasename)
|
appPath.endsWith(execBasename) ||
|
||||||
|
path.basename(file, '.desktop') === execName
|
||||||
) {
|
) {
|
||||||
return fullPath
|
return fullPath
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,7 +97,6 @@ const Proxies: React.FC = () => {
|
|||||||
const [cols, setCols] = useState(1)
|
const [cols, setCols] = useState(1)
|
||||||
const { virtuosoRef, isOpen, setIsOpen } = useProxyState(groups)
|
const { virtuosoRef, isOpen, setIsOpen } = useProxyState(groups)
|
||||||
const [delaying, setDelaying] = useState(Array(groups.length).fill(false))
|
const [delaying, setDelaying] = useState(Array(groups.length).fill(false))
|
||||||
const [proxyDelaying, setProxyDelaying] = useState<Set<string>>(new Set())
|
|
||||||
const [searchValue, setSearchValue] = useState(Array(groups.length).fill(''))
|
const [searchValue, setSearchValue] = useState(Array(groups.length).fill(''))
|
||||||
|
|
||||||
// searchValue 初始化
|
// searchValue 初始化
|
||||||
@ -202,14 +201,6 @@ const Proxies: React.FC = () => {
|
|||||||
return newDelaying
|
return newDelaying
|
||||||
})
|
})
|
||||||
|
|
||||||
// 管理测试状态
|
|
||||||
const groupProxies = allProxies[index]
|
|
||||||
setProxyDelaying((prev) => {
|
|
||||||
const newSet = new Set(prev)
|
|
||||||
groupProxies.forEach((proxy) => newSet.add(proxy.name))
|
|
||||||
return newSet
|
|
||||||
})
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 限制并发数量
|
// 限制并发数量
|
||||||
const result: Promise<void>[] = []
|
const result: Promise<void>[] = []
|
||||||
@ -221,12 +212,6 @@ const Proxies: React.FC = () => {
|
|||||||
} catch {
|
} catch {
|
||||||
// ignore
|
// ignore
|
||||||
} finally {
|
} finally {
|
||||||
// 更新状态
|
|
||||||
setProxyDelaying((prev) => {
|
|
||||||
const newSet = new Set(prev)
|
|
||||||
newSet.delete(proxy.name)
|
|
||||||
return newSet
|
|
||||||
})
|
|
||||||
mutate()
|
mutate()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -246,12 +231,6 @@ const Proxies: React.FC = () => {
|
|||||||
newDelaying[index] = false
|
newDelaying[index] = false
|
||||||
return newDelaying
|
return newDelaying
|
||||||
})
|
})
|
||||||
// 状态清理
|
|
||||||
setProxyDelaying((prev) => {
|
|
||||||
const newSet = new Set(prev)
|
|
||||||
groupProxies.forEach((proxy) => newSet.delete(proxy.name))
|
|
||||||
return newSet
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[allProxies, groups, delayTestConcurrency, mutate, setIsOpen]
|
[allProxies, groups, delayTestConcurrency, mutate, setIsOpen]
|
||||||
@ -280,34 +259,20 @@ const Proxies: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}, [calcCols])
|
}, [calcCols])
|
||||||
|
|
||||||
// 预加载图片
|
|
||||||
useEffect(() => {
|
|
||||||
const loadImages = async (): Promise<void> => {
|
|
||||||
const imagesToLoad: string[] = []
|
|
||||||
groups.forEach((group) => {
|
|
||||||
if (group.icon && group.icon.startsWith('http') && !localStorage.getItem(group.icon)) {
|
|
||||||
imagesToLoad.push(group.icon)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (imagesToLoad.length > 0) {
|
|
||||||
const promises = imagesToLoad.map(async (url) => {
|
|
||||||
try {
|
|
||||||
const dataURL = await getImageDataURL(url)
|
|
||||||
localStorage.setItem(url, dataURL)
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to load image:', url, error)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
await Promise.all(promises)
|
|
||||||
mutate()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
loadImages()
|
|
||||||
}, [groups, mutate])
|
|
||||||
|
|
||||||
const renderGroupContent = useCallback(
|
const renderGroupContent = useCallback(
|
||||||
(index: number) => {
|
(index: number) => {
|
||||||
|
if (
|
||||||
|
groups[index]?.icon &&
|
||||||
|
groups[index].icon.startsWith('http') &&
|
||||||
|
!localStorage.getItem(groups[index].icon)
|
||||||
|
) {
|
||||||
|
getImageDataURL(groups[index].icon)
|
||||||
|
.then((dataURL) => {
|
||||||
|
localStorage.setItem(groups[index].icon, dataURL)
|
||||||
|
mutate()
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
}
|
||||||
return groups[index] ? (
|
return groups[index] ? (
|
||||||
<div
|
<div
|
||||||
className={`w-full pt-2 ${index === groupCounts.length - 1 && !isOpen[index] ? 'pb-2' : ''} px-2`}
|
className={`w-full pt-2 ${index === groupCounts.length - 1 && !isOpen[index] ? 'pb-2' : ''} px-2`}
|
||||||
@ -476,9 +441,7 @@ const Proxies: React.FC = () => {
|
|||||||
selected={
|
selected={
|
||||||
allProxies[groupIndex][innerIndex * cols + i]?.name === groups[groupIndex].now
|
allProxies[groupIndex][innerIndex * cols + i]?.name === groups[groupIndex].now
|
||||||
}
|
}
|
||||||
isGroupTesting={proxyDelaying.has(
|
isGroupTesting={delaying[groupIndex]}
|
||||||
allProxies[groupIndex][innerIndex * cols + i].name
|
|
||||||
)}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
@ -494,7 +457,7 @@ const Proxies: React.FC = () => {
|
|||||||
cols,
|
cols,
|
||||||
groups,
|
groups,
|
||||||
proxyDisplayMode,
|
proxyDisplayMode,
|
||||||
proxyDelaying,
|
delaying,
|
||||||
mutate,
|
mutate,
|
||||||
onProxyDelay,
|
onProxyDelay,
|
||||||
onChangeProxy
|
onChangeProxy
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user