mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-20 02:42:12 +08:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da7ccebf66 | ||
|
|
df4d09167d | ||
|
|
cc202fa312 | ||
|
|
f2c70c5180 |
@@ -28,6 +28,8 @@
|
||||
<details>
|
||||
<summary><strong> 🐞 修复问题 </strong></summary>
|
||||
|
||||
- 修复「外部控制器」复制成功的提示一闪而过
|
||||
- 修复订阅的规则、代理组、节点编辑器快速连续操作时条目可能重复或错位
|
||||
- 修复检测更新后又发布新版时,应用内更新失败
|
||||
- 修复订阅响应过大导致内存占用过高,限制单次下载为 4 MiB
|
||||
- 修复全局模式默认停在 `DIRECT` 或 `REJECT` 导致流量未经代理,现自动切换到第一个策略组
|
||||
@@ -63,6 +65,7 @@
|
||||
<details>
|
||||
<summary><strong> 🚀 优化改进 </strong></summary>
|
||||
|
||||
- 优化设置页打开时的开销:布局设置弹窗首次打开时才加载图标
|
||||
- 优化连接、规则和日志筛选:切换页面后保留过滤条件
|
||||
- 优化全局模式代理列表:仅显示 `GLOBAL` 节点,选中其中的策略组时才显示该组
|
||||
- 优化设置页开关和选项所在行的鼠标悬停高亮,便于对应说明与控件
|
||||
|
||||
@@ -218,7 +218,7 @@ export const GroupsEditorViewer = (props: Props) => {
|
||||
group={item}
|
||||
onDelete={() => {
|
||||
if (isDeleted) {
|
||||
setDeleteSeq(deleteSeq.filter((v) => v !== item.name))
|
||||
setDeleteSeq((prev) => prev.filter((v) => v !== item.name))
|
||||
} else {
|
||||
setDeleteSeq((prev) => [...prev, item.name])
|
||||
}
|
||||
@@ -233,7 +233,7 @@ export const GroupsEditorViewer = (props: Props) => {
|
||||
type="prepend"
|
||||
group={item}
|
||||
onDelete={() => {
|
||||
setPrependSeq(prependSeq.filter((v) => v.name !== item.name))
|
||||
setPrependSeq((prev) => prev.filter((v) => v.name !== item.name))
|
||||
}}
|
||||
/>
|
||||
)
|
||||
@@ -244,7 +244,7 @@ export const GroupsEditorViewer = (props: Props) => {
|
||||
type="append"
|
||||
group={item}
|
||||
onDelete={() => {
|
||||
setAppendSeq(appendSeq.filter((v) => v.name !== item.name))
|
||||
setAppendSeq((prev) => prev.filter((v) => v.name !== item.name))
|
||||
}}
|
||||
/>
|
||||
)
|
||||
@@ -255,21 +255,22 @@ export const GroupsEditorViewer = (props: Props) => {
|
||||
activeIndex: number,
|
||||
overIndex: number,
|
||||
) => {
|
||||
const list = category === 'prepend' ? prependSeq : appendSeq
|
||||
const filtered =
|
||||
category === 'prepend' ? filteredPrependSeq : filteredAppendSeq
|
||||
const setList = category === 'prepend' ? setPrependSeq : setAppendSeq
|
||||
const activeRealIndex = findRealIndex(list, filtered, activeIndex)
|
||||
const overRealIndex = findRealIndex(list, filtered, overIndex)
|
||||
if (
|
||||
activeRealIndex < 0 ||
|
||||
overRealIndex < 0 ||
|
||||
activeRealIndex === overRealIndex
|
||||
) {
|
||||
return
|
||||
}
|
||||
// Recompute inside the updater: two writes in one batch must not read the same pre-batch array.
|
||||
setList((prev) => {
|
||||
const filtered = prev.filter((v) => match(v.name))
|
||||
const activeRealIndex = findRealIndex(prev, filtered, activeIndex)
|
||||
const overRealIndex = findRealIndex(prev, filtered, overIndex)
|
||||
if (
|
||||
activeRealIndex < 0 ||
|
||||
overRealIndex < 0 ||
|
||||
activeRealIndex === overRealIndex
|
||||
) {
|
||||
return prev
|
||||
}
|
||||
|
||||
setList(arrayMove(list, activeRealIndex, overRealIndex))
|
||||
return arrayMove(prev, activeRealIndex, overRealIndex)
|
||||
})
|
||||
}
|
||||
|
||||
const fetchContent = useCallback(async () => {
|
||||
@@ -1019,14 +1020,20 @@ export const GroupsEditorViewer = (props: Props) => {
|
||||
onClick={() => {
|
||||
try {
|
||||
validateGroup()
|
||||
const values = formIns.getValues()
|
||||
for (const item of [...prependSeq, ...groupList]) {
|
||||
if (item.name === formIns.getValues().name) {
|
||||
if (item.name === values.name) {
|
||||
throw new Error(
|
||||
t('profiles.modals.groupsEditor.errors.nameExists'),
|
||||
)
|
||||
}
|
||||
}
|
||||
setPrependSeq([formIns.getValues(), ...prependSeq])
|
||||
// Recheck inside the updater so a same-batch second click cannot duplicate the entry.
|
||||
setPrependSeq((prev) =>
|
||||
prev.some((v) => v.name === values.name)
|
||||
? prev
|
||||
: [values, ...prev],
|
||||
)
|
||||
} catch (err) {
|
||||
showNotice.error(err)
|
||||
}
|
||||
@@ -1043,14 +1050,20 @@ export const GroupsEditorViewer = (props: Props) => {
|
||||
onClick={() => {
|
||||
try {
|
||||
validateGroup()
|
||||
const values = formIns.getValues()
|
||||
for (const item of [...appendSeq, ...groupList]) {
|
||||
if (item.name === formIns.getValues().name) {
|
||||
if (item.name === values.name) {
|
||||
throw new Error(
|
||||
t('profiles.modals.groupsEditor.errors.nameExists'),
|
||||
)
|
||||
}
|
||||
}
|
||||
setAppendSeq([...appendSeq, formIns.getValues()])
|
||||
// Recheck inside the updater so a same-batch second click cannot duplicate the entry.
|
||||
setAppendSeq((prev) =>
|
||||
prev.some((v) => v.name === values.name)
|
||||
? prev
|
||||
: [...prev, values],
|
||||
)
|
||||
} catch (err) {
|
||||
showNotice.error(err)
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ export const ProxiesEditorViewer = (props: Props) => {
|
||||
proxy={item}
|
||||
onDelete={() => {
|
||||
if (isDeleted) {
|
||||
setDeleteSeq(deleteSeq.filter((v) => v !== item.name))
|
||||
setDeleteSeq((prev) => prev.filter((v) => v !== item.name))
|
||||
} else {
|
||||
setDeleteSeq((prev) => [...prev, item.name])
|
||||
}
|
||||
@@ -138,7 +138,7 @@ export const ProxiesEditorViewer = (props: Props) => {
|
||||
type="prepend"
|
||||
proxy={item}
|
||||
onDelete={() => {
|
||||
setPrependSeq(prependSeq.filter((v) => v.name !== item.name))
|
||||
setPrependSeq((prev) => prev.filter((v) => v.name !== item.name))
|
||||
}}
|
||||
/>
|
||||
)
|
||||
@@ -149,7 +149,7 @@ export const ProxiesEditorViewer = (props: Props) => {
|
||||
type="append"
|
||||
proxy={item}
|
||||
onDelete={() => {
|
||||
setAppendSeq(appendSeq.filter((v) => v.name !== item.name))
|
||||
setAppendSeq((prev) => prev.filter((v) => v.name !== item.name))
|
||||
}}
|
||||
/>
|
||||
)
|
||||
@@ -160,21 +160,22 @@ export const ProxiesEditorViewer = (props: Props) => {
|
||||
activeIndex: number,
|
||||
overIndex: number,
|
||||
) => {
|
||||
const list = category === 'prepend' ? prependSeq : appendSeq
|
||||
const filtered =
|
||||
category === 'prepend' ? filteredPrependSeq : filteredAppendSeq
|
||||
const setList = category === 'prepend' ? setPrependSeq : setAppendSeq
|
||||
const activeRealIndex = findRealIndex(list, filtered, activeIndex)
|
||||
const overRealIndex = findRealIndex(list, filtered, overIndex)
|
||||
if (
|
||||
activeRealIndex < 0 ||
|
||||
overRealIndex < 0 ||
|
||||
activeRealIndex === overRealIndex
|
||||
) {
|
||||
return
|
||||
}
|
||||
// Recompute inside the updater: two writes in one batch must not read the same pre-batch array.
|
||||
setList((prev) => {
|
||||
const filtered = prev.filter((v) => hasValidName(v) && match(v.name))
|
||||
const activeRealIndex = findRealIndex(prev, filtered, activeIndex)
|
||||
const overRealIndex = findRealIndex(prev, filtered, overIndex)
|
||||
if (
|
||||
activeRealIndex < 0 ||
|
||||
overRealIndex < 0 ||
|
||||
activeRealIndex === overRealIndex
|
||||
) {
|
||||
return prev
|
||||
}
|
||||
|
||||
setList(arrayMove(list, activeRealIndex, overRealIndex))
|
||||
return arrayMove(prev, activeRealIndex, overRealIndex)
|
||||
})
|
||||
}
|
||||
|
||||
// 优化:异步分片解析,避免主线程阻塞,解析完成后批量setState
|
||||
|
||||
@@ -318,7 +318,7 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
ruleRaw={item}
|
||||
onDelete={() => {
|
||||
if (isDeleted) {
|
||||
setDeleteSeq(deleteSeq.filter((v) => v !== item))
|
||||
setDeleteSeq((prev) => prev.filter((v) => v !== item))
|
||||
} else {
|
||||
setDeleteSeq((prev) => [...prev, item])
|
||||
}
|
||||
@@ -333,13 +333,13 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
type="prepend"
|
||||
ruleRaw={item}
|
||||
onDelete={() => {
|
||||
setPrependSeq(prependSeq.filter((v) => v !== item))
|
||||
setPrependSeq((prev) => prev.filter((v) => v !== item))
|
||||
}}
|
||||
onAppend={() => {
|
||||
setAppendSeq((prev) =>
|
||||
prev.includes(item) ? prev : [...prev, item],
|
||||
)
|
||||
setPrependSeq(prependSeq.filter((v) => v !== item))
|
||||
setPrependSeq((prev) => prev.filter((v) => v !== item))
|
||||
}}
|
||||
/>
|
||||
)
|
||||
@@ -350,13 +350,13 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
type="append"
|
||||
ruleRaw={item}
|
||||
onDelete={() => {
|
||||
setAppendSeq(appendSeq.filter((v) => v !== item))
|
||||
setAppendSeq((prev) => prev.filter((v) => v !== item))
|
||||
}}
|
||||
onPrepend={() => {
|
||||
setPrependSeq((prev) =>
|
||||
prev.includes(item) ? prev : [...prev, item],
|
||||
)
|
||||
setAppendSeq(appendSeq.filter((v) => v !== item))
|
||||
setAppendSeq((prev) => prev.filter((v) => v !== item))
|
||||
}}
|
||||
/>
|
||||
)
|
||||
@@ -367,21 +367,22 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
activeIndex: number,
|
||||
overIndex: number,
|
||||
) => {
|
||||
const list = category === 'prepend' ? prependSeq : appendSeq
|
||||
const filtered =
|
||||
category === 'prepend' ? filteredPrependSeq : filteredAppendSeq
|
||||
const setList = category === 'prepend' ? setPrependSeq : setAppendSeq
|
||||
const activeRealIndex = findRealIndex(list, filtered, activeIndex)
|
||||
const overRealIndex = findRealIndex(list, filtered, overIndex)
|
||||
if (
|
||||
activeRealIndex < 0 ||
|
||||
overRealIndex < 0 ||
|
||||
activeRealIndex === overRealIndex
|
||||
) {
|
||||
return
|
||||
}
|
||||
// Recompute inside the updater: two writes in one batch must not read the same pre-batch array.
|
||||
setList((prev) => {
|
||||
const filtered = prev.filter(match)
|
||||
const activeRealIndex = findRealIndex(prev, filtered, activeIndex)
|
||||
const overRealIndex = findRealIndex(prev, filtered, overIndex)
|
||||
if (
|
||||
activeRealIndex < 0 ||
|
||||
overRealIndex < 0 ||
|
||||
activeRealIndex === overRealIndex
|
||||
) {
|
||||
return prev
|
||||
}
|
||||
|
||||
setList(arrayMove(list, activeRealIndex, overRealIndex))
|
||||
return arrayMove(prev, activeRealIndex, overRealIndex)
|
||||
})
|
||||
}
|
||||
|
||||
const fetchContent = useCallback(async () => {
|
||||
@@ -748,8 +749,9 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
onClick={() => {
|
||||
try {
|
||||
const raw = validateRule()
|
||||
if (prependSeq.includes(raw)) return
|
||||
setPrependSeq([raw, ...prependSeq])
|
||||
setPrependSeq((prev) =>
|
||||
prev.includes(raw) ? prev : [raw, ...prev],
|
||||
)
|
||||
} catch (err: any) {
|
||||
showNotice.error(err)
|
||||
}
|
||||
@@ -766,8 +768,9 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
onClick={() => {
|
||||
try {
|
||||
const raw = validateRule()
|
||||
if (appendSeq.includes(raw)) return
|
||||
setAppendSeq([...appendSeq, raw])
|
||||
setAppendSeq((prev) =>
|
||||
prev.includes(raw) ? prev : [...prev, raw],
|
||||
)
|
||||
} catch (err: any) {
|
||||
showNotice.error(err)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
Tooltip,
|
||||
} from '@mui/material'
|
||||
import { useLockFn } from 'ahooks'
|
||||
import { useState, type Ref } from 'react'
|
||||
import { useRef, useState, type Ref } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
import { BaseDialog, DialogRef, Switch } from '@/components/base'
|
||||
@@ -26,6 +26,10 @@ export function ControllerViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
const { t } = useTranslation()
|
||||
const [open, setOpen] = useState(false)
|
||||
const [copySuccess, setCopySuccess] = useState<null | string>(null)
|
||||
// A second copy within the window must not be hidden by the first timer.
|
||||
const copySuccessTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(
|
||||
undefined,
|
||||
)
|
||||
const [isSaving, setIsSaving] = useState(false)
|
||||
|
||||
const { clashInfo, patchInfo } = useClashInfo()
|
||||
@@ -96,7 +100,11 @@ export function ControllerViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text)
|
||||
setCopySuccess(type)
|
||||
setTimeout(() => setCopySuccess(null))
|
||||
clearTimeout(copySuccessTimerRef.current)
|
||||
copySuccessTimerRef.current = setTimeout(
|
||||
() => setCopySuccess(null),
|
||||
2000,
|
||||
)
|
||||
} catch (err) {
|
||||
console.warn('[ControllerViewer] copy to clipboard failed:', err)
|
||||
showNotice.error(
|
||||
|
||||
@@ -14,7 +14,7 @@ import { convertFileSrc } from '@tauri-apps/api/core'
|
||||
import { join } from '@tauri-apps/api/path'
|
||||
import { open as openDialog } from '@tauri-apps/plugin-dialog'
|
||||
import { exists } from '@tauri-apps/plugin-fs'
|
||||
import { forwardRef, useEffect, useState } from 'react'
|
||||
import { forwardRef, useEffect, useRef, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
import { BaseDialog, DialogRef, Switch, TooltipIcon } from '@/components/base'
|
||||
@@ -62,9 +62,16 @@ export const LayoutViewer = forwardRef<DialogRef>((_, ref) => {
|
||||
|
||||
const { decorated, toggleDecorations } = useWindowDecorations()
|
||||
|
||||
// Icon paths are only reachable from the open dialog; both settings sections
|
||||
// mount this viewer, so an eager read would double ~11 IPC calls per visit.
|
||||
// Loaded once per mount, deferred to the first open.
|
||||
const iconsLoadedRef = useRef(false)
|
||||
|
||||
useEffect(() => {
|
||||
if (!open || iconsLoadedRef.current) return
|
||||
iconsLoadedRef.current = true
|
||||
initIconPath()
|
||||
}, [])
|
||||
}, [open])
|
||||
|
||||
async function initIconPath() {
|
||||
const appDir = await getAppDir()
|
||||
|
||||
@@ -48,10 +48,14 @@ export const useSystemProxyState = () => {
|
||||
// Coalesce rapid clicks so only the latest requested state is applied.
|
||||
const pendingRef = useRef<boolean | null>(null)
|
||||
const busyRef = useRef(false)
|
||||
// The drain loop outlives the render it started in; reading the config
|
||||
// through a ref keeps mid-loop revalidations visible to later iterations.
|
||||
const vergeRef = useRef(verge)
|
||||
vergeRef.current = verge
|
||||
|
||||
const toggleSystemProxy = async (enabled: boolean) => {
|
||||
// Roll failed optimistic writes back to the latest confirmed state.
|
||||
let confirmed = verge?.enable_system_proxy ?? false
|
||||
let confirmed = vergeRef.current?.enable_system_proxy ?? false
|
||||
mutateVerge((prev) =>
|
||||
prev ? { ...prev, enable_system_proxy: enabled } : prev,
|
||||
)
|
||||
@@ -69,7 +73,7 @@ export const useSystemProxyState = () => {
|
||||
errorNotice: false,
|
||||
})
|
||||
confirmed = target
|
||||
if (!target && verge?.auto_close_connection) {
|
||||
if (!target && vergeRef.current?.auto_close_connection) {
|
||||
await mutate(() => closeAllConnections(), {
|
||||
id: 'close-all-connections',
|
||||
errorNotice: false,
|
||||
|
||||
Reference in New Issue
Block a user