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
3 Commits
4fd7dec4db
...
34fc4d2d96
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34fc4d2d96 | ||
|
|
b9a7e04eee | ||
|
|
1a52bff8af |
@ -179,7 +179,10 @@ interface FetchResult {
|
||||
async function fetchAndValidateSubscription(options: FetchOptions): Promise<FetchResult> {
|
||||
const { url, useProxy, mixedPort, userAgent, authToken, timeout, substore } = options
|
||||
|
||||
const headers: Record<string, string> = { 'User-Agent': userAgent }
|
||||
const headers: Record<string, string> = {
|
||||
'User-Agent': userAgent,
|
||||
'Accept-Encoding': 'identity'
|
||||
}
|
||||
if (authToken) headers['Authorization'] = authToken
|
||||
|
||||
let res: chromeRequest.Response<string>
|
||||
|
||||
@ -132,7 +132,7 @@ export async function triggerFloatingWindow(): Promise<void> {
|
||||
export async function closeFloatingWindow(): Promise<void> {
|
||||
if (floatingWindow) {
|
||||
ipcMain.removeAllListeners('updateFloatingWindow')
|
||||
floatingWindow.close()
|
||||
floatingWindow.destroy()
|
||||
floatingWindow = null
|
||||
}
|
||||
await showTrayIcon()
|
||||
|
||||
@ -46,7 +46,6 @@ const Logs: React.FC = () => {
|
||||
const [trace, setTrace] = useState(true)
|
||||
|
||||
const virtuosoRef = useRef<VirtuosoHandle>(null)
|
||||
const traceRef = useRef(trace)
|
||||
|
||||
const filteredLogs = useMemo(() => {
|
||||
if (filter === '') return logs
|
||||
@ -59,29 +58,10 @@ const Logs: React.FC = () => {
|
||||
localStorage.setItem(LOGS_FILTER_KEY, filter)
|
||||
}, [filter])
|
||||
|
||||
useEffect(() => {
|
||||
traceRef.current = trace
|
||||
if (trace) {
|
||||
setLogs([...cachedLogs.log])
|
||||
}
|
||||
}, [trace])
|
||||
|
||||
useEffect(() => {
|
||||
if (!trace) return
|
||||
virtuosoRef.current?.scrollToIndex({
|
||||
index: filteredLogs.length - 1,
|
||||
behavior: 'smooth',
|
||||
align: 'end',
|
||||
offset: 0
|
||||
})
|
||||
}, [filteredLogs, trace])
|
||||
|
||||
useEffect(() => {
|
||||
const old = cachedLogs.trigger
|
||||
cachedLogs.trigger = (a): void => {
|
||||
if (traceRef.current) {
|
||||
setLogs([...a])
|
||||
}
|
||||
setLogs([...a])
|
||||
}
|
||||
return (): void => {
|
||||
cachedLogs.trigger = old
|
||||
@ -132,6 +112,8 @@ const Logs: React.FC = () => {
|
||||
<Virtuoso
|
||||
ref={virtuosoRef}
|
||||
data={filteredLogs}
|
||||
initialTopMostItemIndex={filteredLogs.length - 1}
|
||||
followOutput={trace}
|
||||
itemContent={(i, log) => (
|
||||
<LogItem index={i} time={log.time} type={log.type} payload={log.payload} />
|
||||
)}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user