mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-20 02:42:12 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99815e7fe3 |
Generated
+73
-8
@@ -821,9 +821,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.12.1"
|
||||
version = "1.12.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
|
||||
checksum = "776dfebd015e2d8732c684a2c71003674ccb49457b539b9e82151ba38e96dd7c"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
@@ -1191,7 +1191,7 @@ name = "clash-verge-logging"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"flexi_logger",
|
||||
"flexi_logger 0.32.0",
|
||||
"log",
|
||||
"parking_lot 0.13.0",
|
||||
"tracing-estuary",
|
||||
@@ -2425,6 +2425,19 @@ 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"
|
||||
@@ -3737,6 +3750,58 @@ 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"
|
||||
@@ -7072,9 +7137,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sysinfo"
|
||||
version = "0.40.3"
|
||||
version = "0.40.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a86bac2f7d06e6384984118ad727f5694110f0ec44d924d05c8fdec3d030bee6"
|
||||
checksum = "3e80749408e2d8bec0ffa303012cf4e1b3b355f4a09087b4fdf7473680f6a2de"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"memchr",
|
||||
@@ -8476,7 +8541,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"compact_str",
|
||||
"console-subscriber",
|
||||
"flexi_logger",
|
||||
"flexi_logger 0.31.10",
|
||||
"log",
|
||||
"nu-ansi-term",
|
||||
"parking_lot 0.12.5",
|
||||
@@ -10136,9 +10201,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zip"
|
||||
version = "9.6.0"
|
||||
version = "9.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80cc68510ea7553c30a69c732de5278e94183f68765af6c642dbccefd6ec777e"
|
||||
checksum = "63e50f7b2212e4635244be3c363b53273d159f2523eb7db3096c1d2861c1b603"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"bzip2",
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ tokio = { version = "1.54.1", features = [
|
||||
"time",
|
||||
"sync",
|
||||
] }
|
||||
flexi_logger = "0.31.10"
|
||||
flexi_logger = "0.32.0"
|
||||
log = "0.4.35"
|
||||
reqwest = { version = "0.13.5", features = [
|
||||
"json",
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
<details>
|
||||
<summary><strong> 🐞 修复问题 </strong></summary>
|
||||
|
||||
- 修复「外部控制器」复制成功的提示一闪而过
|
||||
- 修复订阅的规则、代理组、节点编辑器快速连续操作时条目可能重复或错位
|
||||
- 修复检测更新后又发布新版时,应用内更新失败
|
||||
- 修复订阅响应过大导致内存占用过高,限制单次下载为 4 MiB
|
||||
- 修复全局模式默认停在 `DIRECT` 或 `REJECT` 导致流量未经代理,现自动切换到第一个策略组
|
||||
@@ -65,7 +63,6 @@
|
||||
<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.3", default-features = false, features = ["network", "system"] }
|
||||
sysinfo = { version = "0.40.4", default-features = false, features = ["network", "system"] }
|
||||
|
||||
[target.'cfg(not(windows))'.dependencies]
|
||||
libc = "0.2.191"
|
||||
|
||||
@@ -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.6.0"
|
||||
zip = "9.7.3"
|
||||
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.1"
|
||||
bytes = "1.12.2"
|
||||
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"] }
|
||||
|
||||
@@ -218,7 +218,7 @@ export const GroupsEditorViewer = (props: Props) => {
|
||||
group={item}
|
||||
onDelete={() => {
|
||||
if (isDeleted) {
|
||||
setDeleteSeq((prev) => prev.filter((v) => v !== item.name))
|
||||
setDeleteSeq(deleteSeq.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((prev) => prev.filter((v) => v.name !== item.name))
|
||||
setPrependSeq(prependSeq.filter((v) => v.name !== item.name))
|
||||
}}
|
||||
/>
|
||||
)
|
||||
@@ -244,7 +244,7 @@ export const GroupsEditorViewer = (props: Props) => {
|
||||
type="append"
|
||||
group={item}
|
||||
onDelete={() => {
|
||||
setAppendSeq((prev) => prev.filter((v) => v.name !== item.name))
|
||||
setAppendSeq(appendSeq.filter((v) => v.name !== item.name))
|
||||
}}
|
||||
/>
|
||||
)
|
||||
@@ -255,22 +255,21 @@ 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
|
||||
// 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
|
||||
}
|
||||
const activeRealIndex = findRealIndex(list, filtered, activeIndex)
|
||||
const overRealIndex = findRealIndex(list, filtered, overIndex)
|
||||
if (
|
||||
activeRealIndex < 0 ||
|
||||
overRealIndex < 0 ||
|
||||
activeRealIndex === overRealIndex
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
return arrayMove(prev, activeRealIndex, overRealIndex)
|
||||
})
|
||||
setList(arrayMove(list, activeRealIndex, overRealIndex))
|
||||
}
|
||||
|
||||
const fetchContent = useCallback(async () => {
|
||||
@@ -1020,20 +1019,14 @@ export const GroupsEditorViewer = (props: Props) => {
|
||||
onClick={() => {
|
||||
try {
|
||||
validateGroup()
|
||||
const values = formIns.getValues()
|
||||
for (const item of [...prependSeq, ...groupList]) {
|
||||
if (item.name === values.name) {
|
||||
if (item.name === formIns.getValues().name) {
|
||||
throw new Error(
|
||||
t('profiles.modals.groupsEditor.errors.nameExists'),
|
||||
)
|
||||
}
|
||||
}
|
||||
// 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],
|
||||
)
|
||||
setPrependSeq([formIns.getValues(), ...prependSeq])
|
||||
} catch (err) {
|
||||
showNotice.error(err)
|
||||
}
|
||||
@@ -1050,20 +1043,14 @@ export const GroupsEditorViewer = (props: Props) => {
|
||||
onClick={() => {
|
||||
try {
|
||||
validateGroup()
|
||||
const values = formIns.getValues()
|
||||
for (const item of [...appendSeq, ...groupList]) {
|
||||
if (item.name === values.name) {
|
||||
if (item.name === formIns.getValues().name) {
|
||||
throw new Error(
|
||||
t('profiles.modals.groupsEditor.errors.nameExists'),
|
||||
)
|
||||
}
|
||||
}
|
||||
// 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],
|
||||
)
|
||||
setAppendSeq([...appendSeq, formIns.getValues()])
|
||||
} catch (err) {
|
||||
showNotice.error(err)
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ export const ProxiesEditorViewer = (props: Props) => {
|
||||
proxy={item}
|
||||
onDelete={() => {
|
||||
if (isDeleted) {
|
||||
setDeleteSeq((prev) => prev.filter((v) => v !== item.name))
|
||||
setDeleteSeq(deleteSeq.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((prev) => prev.filter((v) => v.name !== item.name))
|
||||
setPrependSeq(prependSeq.filter((v) => v.name !== item.name))
|
||||
}}
|
||||
/>
|
||||
)
|
||||
@@ -149,7 +149,7 @@ export const ProxiesEditorViewer = (props: Props) => {
|
||||
type="append"
|
||||
proxy={item}
|
||||
onDelete={() => {
|
||||
setAppendSeq((prev) => prev.filter((v) => v.name !== item.name))
|
||||
setAppendSeq(appendSeq.filter((v) => v.name !== item.name))
|
||||
}}
|
||||
/>
|
||||
)
|
||||
@@ -160,22 +160,21 @@ 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
|
||||
// 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
|
||||
}
|
||||
const activeRealIndex = findRealIndex(list, filtered, activeIndex)
|
||||
const overRealIndex = findRealIndex(list, filtered, overIndex)
|
||||
if (
|
||||
activeRealIndex < 0 ||
|
||||
overRealIndex < 0 ||
|
||||
activeRealIndex === overRealIndex
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
return arrayMove(prev, activeRealIndex, overRealIndex)
|
||||
})
|
||||
setList(arrayMove(list, activeRealIndex, overRealIndex))
|
||||
}
|
||||
|
||||
// 优化:异步分片解析,避免主线程阻塞,解析完成后批量setState
|
||||
|
||||
@@ -318,7 +318,7 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
ruleRaw={item}
|
||||
onDelete={() => {
|
||||
if (isDeleted) {
|
||||
setDeleteSeq((prev) => prev.filter((v) => v !== item))
|
||||
setDeleteSeq(deleteSeq.filter((v) => v !== item))
|
||||
} else {
|
||||
setDeleteSeq((prev) => [...prev, item])
|
||||
}
|
||||
@@ -333,13 +333,13 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
type="prepend"
|
||||
ruleRaw={item}
|
||||
onDelete={() => {
|
||||
setPrependSeq((prev) => prev.filter((v) => v !== item))
|
||||
setPrependSeq(prependSeq.filter((v) => v !== item))
|
||||
}}
|
||||
onAppend={() => {
|
||||
setAppendSeq((prev) =>
|
||||
prev.includes(item) ? prev : [...prev, item],
|
||||
)
|
||||
setPrependSeq((prev) => prev.filter((v) => v !== item))
|
||||
setPrependSeq(prependSeq.filter((v) => v !== item))
|
||||
}}
|
||||
/>
|
||||
)
|
||||
@@ -350,13 +350,13 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
type="append"
|
||||
ruleRaw={item}
|
||||
onDelete={() => {
|
||||
setAppendSeq((prev) => prev.filter((v) => v !== item))
|
||||
setAppendSeq(appendSeq.filter((v) => v !== item))
|
||||
}}
|
||||
onPrepend={() => {
|
||||
setPrependSeq((prev) =>
|
||||
prev.includes(item) ? prev : [...prev, item],
|
||||
)
|
||||
setAppendSeq((prev) => prev.filter((v) => v !== item))
|
||||
setAppendSeq(appendSeq.filter((v) => v !== item))
|
||||
}}
|
||||
/>
|
||||
)
|
||||
@@ -367,22 +367,21 @@ 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
|
||||
// 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
|
||||
}
|
||||
const activeRealIndex = findRealIndex(list, filtered, activeIndex)
|
||||
const overRealIndex = findRealIndex(list, filtered, overIndex)
|
||||
if (
|
||||
activeRealIndex < 0 ||
|
||||
overRealIndex < 0 ||
|
||||
activeRealIndex === overRealIndex
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
return arrayMove(prev, activeRealIndex, overRealIndex)
|
||||
})
|
||||
setList(arrayMove(list, activeRealIndex, overRealIndex))
|
||||
}
|
||||
|
||||
const fetchContent = useCallback(async () => {
|
||||
@@ -749,9 +748,8 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
onClick={() => {
|
||||
try {
|
||||
const raw = validateRule()
|
||||
setPrependSeq((prev) =>
|
||||
prev.includes(raw) ? prev : [raw, ...prev],
|
||||
)
|
||||
if (prependSeq.includes(raw)) return
|
||||
setPrependSeq([raw, ...prependSeq])
|
||||
} catch (err: any) {
|
||||
showNotice.error(err)
|
||||
}
|
||||
@@ -768,9 +766,8 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
onClick={() => {
|
||||
try {
|
||||
const raw = validateRule()
|
||||
setAppendSeq((prev) =>
|
||||
prev.includes(raw) ? prev : [...prev, raw],
|
||||
)
|
||||
if (appendSeq.includes(raw)) return
|
||||
setAppendSeq([...appendSeq, raw])
|
||||
} catch (err: any) {
|
||||
showNotice.error(err)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
Tooltip,
|
||||
} from '@mui/material'
|
||||
import { useLockFn } from 'ahooks'
|
||||
import { useRef, useState, type Ref } from 'react'
|
||||
import { useState, type Ref } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
import { BaseDialog, DialogRef, Switch } from '@/components/base'
|
||||
@@ -26,10 +26,6 @@ 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()
|
||||
@@ -100,11 +96,7 @@ export function ControllerViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text)
|
||||
setCopySuccess(type)
|
||||
clearTimeout(copySuccessTimerRef.current)
|
||||
copySuccessTimerRef.current = setTimeout(
|
||||
() => setCopySuccess(null),
|
||||
2000,
|
||||
)
|
||||
setTimeout(() => setCopySuccess(null))
|
||||
} 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, useRef, useState } from 'react'
|
||||
import { forwardRef, useEffect, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
import { BaseDialog, DialogRef, Switch, TooltipIcon } from '@/components/base'
|
||||
@@ -62,16 +62,9 @@ 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,14 +48,10 @@ 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 = vergeRef.current?.enable_system_proxy ?? false
|
||||
let confirmed = verge?.enable_system_proxy ?? false
|
||||
mutateVerge((prev) =>
|
||||
prev ? { ...prev, enable_system_proxy: enabled } : prev,
|
||||
)
|
||||
@@ -73,7 +69,7 @@ export const useSystemProxyState = () => {
|
||||
errorNotice: false,
|
||||
})
|
||||
confirmed = target
|
||||
if (!target && vergeRef.current?.auto_close_connection) {
|
||||
if (!target && verge?.auto_close_connection) {
|
||||
await mutate(() => closeAllConnections(), {
|
||||
id: 'close-all-connections',
|
||||
errorNotice: false,
|
||||
|
||||
Reference in New Issue
Block a user