mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-08 19:22:44 +08:00
fix: prevent rules editor from clearing custom rules before load
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
- 修复 JS 脚本验证因 console 方法调用导致的执行失败问题
|
||||
- 修复 macOS 内存压力下 WebView 渲染进程被系统终止引发的白屏与主进程内存泄漏
|
||||
- 删除覆盖全局热键开关的冗余写入
|
||||
- 修复编辑节点下base64解码未能正确处理非ASCII字符
|
||||
- 修复订阅规则编辑器自定义规则偶发显示为空的问题
|
||||
|
||||
<details>
|
||||
<summary><strong> ✨ 新增功能 </strong></summary>
|
||||
|
||||
@@ -276,6 +276,7 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
const [prependSeq, setPrependSeq] = useState<string[]>([])
|
||||
const [appendSeq, setAppendSeq] = useState<string[]>([])
|
||||
const [deleteSeq, setDeleteSeq] = useState<string[]>([])
|
||||
const hasLoadedSeqConfigRef = useRef(false)
|
||||
|
||||
const filteredPrependSeq = useMemo(
|
||||
() => prependSeq.filter((rule) => match(rule)),
|
||||
@@ -406,6 +407,7 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
}
|
||||
}
|
||||
const fetchContent = useCallback(async () => {
|
||||
hasLoadedSeqConfigRef.current = false
|
||||
const data = await readProfileFile(property)
|
||||
const obj = yaml.load(data) as ISeqProfileConfig | null
|
||||
|
||||
@@ -415,6 +417,7 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
|
||||
setPrevData(data)
|
||||
setCurrData(data)
|
||||
hasLoadedSeqConfigRef.current = true
|
||||
}, [property])
|
||||
|
||||
useEffect(() => {
|
||||
@@ -432,11 +435,19 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
|
||||
// 优化:异步处理大数据yaml.dump,避免UI卡死
|
||||
useEffect(() => {
|
||||
if (!hasLoadedSeqConfigRef.current) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!(prependSeq && appendSeq && deleteSeq)) {
|
||||
return
|
||||
}
|
||||
|
||||
const serialize = () => {
|
||||
if (!hasLoadedSeqConfigRef.current) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
setCurrData(
|
||||
yaml.dump(
|
||||
|
||||
Reference in New Issue
Block a user