Compare commits

..
Author SHA1 Message Date
Tunglies da7ccebf66 perf(setting): defer layout dialog icon loading to first open
Both settings sections mount the layout dialog, so its eager mount
effect issued about eleven Tauri calls twice per settings-page visit
before the dialog was ever opened. The icon scan now runs once, on the
first open.
2026-11-19 22:58:49 +08:00
Tunglies df4d09167d fix(sysproxy): read the live verge config in the toggle drain loop
The drain loop captured the render-time verge snapshot, so a config
revalidation landing mid-loop left later iterations deciding connection
closing and rollback with stale values. The confirmed-state seed and
the in-loop auto-close check now read through a latest ref.
2026-11-19 22:58:48 +08:00
Tunglies cc202fa312 fix(profile): update editor sequences through functional state
The rule, group and proxy editors mixed functional updaters with writes
computed from render-captured arrays, so two clicks in one React batch
(the second before re-render) read a pre-batch array: deletes dropped
an entry queued by the sibling updater, reorders resolved indices
against a stale list, and add buttons could duplicate past their
uniqueness checks. Every sequence mutation now derives from the live
previous state; the group add buttons keep their translated duplicate
notice and recheck inside the updater.
2026-11-19 22:58:39 +08:00
Tunglies f2c70c5180 fix(setting): keep the copy-success snackbar visible for its full duration
The clipboard handler cleared the success flag with a zero-delay
timeout, so the snackbar configured for 2000 ms was hidden on the next
macrotask. The clear now runs after 2000 ms, resetting the timer on
each copy so a second copy within the window keeps its full duration.
2026-11-19 22:58:30 +08:00
11 changed files with 115 additions and 141 deletions
Generated
+8 -73
View File
@@ -821,9 +821,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
[[package]]
name = "bytes"
version = "1.12.2"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "776dfebd015e2d8732c684a2c71003674ccb49457b539b9e82151ba38e96dd7c"
checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
dependencies = [
"serde",
]
@@ -1191,7 +1191,7 @@ name = "clash-verge-logging"
version = "0.1.0"
dependencies = [
"anyhow",
"flexi_logger 0.32.0",
"flexi_logger",
"log",
"parking_lot 0.13.0",
"tracing-estuary",
@@ -2425,19 +2425,6 @@ dependencies = [
"thiserror 2.0.20",
]
[[package]]
name = "flexi_logger"
version = "0.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e87b74024da93123949cca26cb6e366744234fdd4d7914eb3dfeab0baa82d51"
dependencies = [
"jiff",
"log",
"nu-ansi-term",
"regex",
"thiserror 2.0.20",
]
[[package]]
name = "float16"
version = "0.1.5"
@@ -3750,58 +3737,6 @@ dependencies = [
"system-deps 6.2.2",
]
[[package]]
name = "jiff"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5d126d72eb017f10b302e73bdeca446bea405ee449af4d9e7866d6b082d83e"
dependencies = [
"jiff-core",
"jiff-static",
"jiff-tzdb-platform",
"log",
"portable-atomic",
"portable-atomic-util",
"serde_core",
"windows-link 0.2.1",
]
[[package]]
name = "jiff-core"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6b46a105a9874634dd96231021526bf24ca04955a5998c59a9c7666e634b7b8"
dependencies = [
"log",
]
[[package]]
name = "jiff-static"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0127e9bde3c6130d6169e7d8d68676e4be69c4bf7573c308b6f960a5089c428"
dependencies = [
"jiff-core",
"proc-macro2",
"quote",
"syn 3.0.5",
]
[[package]]
name = "jiff-tzdb"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12e71a1b68a875a44a33bb7a1dd84392cb77145a3367a552a3cfe6a4f5cf3afc"
[[package]]
name = "jiff-tzdb-platform"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc65b284afcfa8f6cf189c7274c805505314a7ab975c60e1f548bff56525420e"
dependencies = [
"jiff-tzdb",
]
[[package]]
name = "jni"
version = "0.21.1"
@@ -7137,9 +7072,9 @@ dependencies = [
[[package]]
name = "sysinfo"
version = "0.40.4"
version = "0.40.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e80749408e2d8bec0ffa303012cf4e1b3b355f4a09087b4fdf7473680f6a2de"
checksum = "a86bac2f7d06e6384984118ad727f5694110f0ec44d924d05c8fdec3d030bee6"
dependencies = [
"libc",
"memchr",
@@ -8541,7 +8476,7 @@ dependencies = [
"anyhow",
"compact_str",
"console-subscriber",
"flexi_logger 0.31.10",
"flexi_logger",
"log",
"nu-ansi-term",
"parking_lot 0.12.5",
@@ -10201,9 +10136,9 @@ dependencies = [
[[package]]
name = "zip"
version = "9.7.3"
version = "9.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63e50f7b2212e4635244be3c363b53273d159f2523eb7db3096c1d2861c1b603"
checksum = "80cc68510ea7553c30a69c732de5278e94183f68765af6c642dbccefd6ec777e"
dependencies = [
"aes",
"bzip2",
+1 -1
View File
@@ -73,7 +73,7 @@ tokio = { version = "1.54.1", features = [
"time",
"sync",
] }
flexi_logger = "0.32.0"
flexi_logger = "0.31.10"
log = "0.4.35"
reqwest = { version = "0.13.5", features = [
"json",
+3
View File
@@ -28,6 +28,8 @@
<details>
<summary><strong> 🐞 修复问题 </strong></summary>
- 修复「外部控制器」复制成功的提示一闪而过
- 修复订阅的规则、代理组、节点编辑器快速连续操作时条目可能重复或错位
- 修复检测更新后又发布新版时,应用内更新失败
- 修复订阅响应过大导致内存占用过高,限制单次下载为 4 MiB
- 修复全局模式默认停在 `DIRECT` 或 `REJECT` 导致流量未经代理,现自动切换到第一个策略组
@@ -63,6 +65,7 @@
<details>
<summary><strong> 🚀 优化改进 </strong></summary>
- 优化设置页打开时的开销:布局设置弹窗首次打开时才加载图标
- 优化连接、规则和日志筛选:切换页面后保留过滤条件
- 优化全局模式代理列表:仅显示 `GLOBAL` 节点,选中其中的策略组时才显示该组
- 优化设置页开关和选项所在行的鼠标悬停高亮,便于对应说明与控件
@@ -12,7 +12,7 @@ parking_lot = { workspace = true }
serde = { workspace = true, features = ["derive"] }
# sysinfo 0.38.2 conflicts with dark-light
# see https://github.com/GuillaumeGomez/sysinfo/issues/1623
sysinfo = { version = "0.40.4", default-features = false, features = ["network", "system"] }
sysinfo = { version = "0.40.3", default-features = false, features = ["network", "system"] }
[target.'cfg(not(windows))'.dependencies]
libc = "0.2.191"
+2 -2
View File
@@ -77,7 +77,7 @@ tauri-plugin-dialog = "2.8.4"
tauri-plugin-fs = "2.7.1"
tauri-plugin-deep-link = "2.6.3"
tauri-plugin-window-state = "2.5.0"
zip = "9.7.3"
zip = "9.6.0"
flate2 = "1.1.11"
reqwest_dav = "0.3.3"
aes-gcm = { version = "0.11.1" }
@@ -101,7 +101,7 @@ tokio-rustls = "0.26.6"
rustls = { version = "0.23.46", features = ["ring"] }
webpki-roots = "1.0.12"
dark-light = "3.0.0"
bytes = "1.12.2"
bytes = "1.12.1"
tokio-util = { version = "0.7.20", features = ["time"] }
specta = { version = "=2.0.0-rc.26", features = ["derive", "function", "serde_json"] }
tauri-specta = { version = "=2.0.0-rc.26", features = ["derive", "typescript"] }
+33 -20
View File
@@ -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
+25 -22
View File
@@ -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()
+6 -2
View File
@@ -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,