mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-27 16:22:11 +08:00
refactor: structure config validation outcomes
- Replace boolean/string validation results with structured ValidationOutcome values across config validation, profile switching, DNS validation, and script validation. Callers can now distinguish valid, invalid, skipped, and busy states, with invalid results carrying an error kind and message. - Route core config updates through structured outcomes and checked forced updates. Generation and validation failures now discard runtime drafts and surface validation failures instead of relying on empty success messages. - Preserve existing frontend ergonomics by keeping boolean service wrappers where callers only need success, while direct DNS and script validation consumers receive ValidationOutcome. Failed profile editor saves reload the backend-restored file content and synchronize Monaco models so reopened editors show the restored state.
This commit is contained in:
@@ -528,12 +528,16 @@ export function DnsViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
await invoke('save_dns_config', { dnsConfig: config })
|
||||
|
||||
// 验证配置
|
||||
const [isValid, errorMsg] = await invoke<[boolean, string]>(
|
||||
const validation = await invoke<ValidationOutcome>(
|
||||
'validate_dns_config',
|
||||
{},
|
||||
)
|
||||
|
||||
if (!isValid) {
|
||||
if (validation.status !== 'valid') {
|
||||
const errorMsg =
|
||||
validation.status === 'invalid'
|
||||
? validation.message
|
||||
: 'Configuration validation skipped'
|
||||
let cleanErrorMsg = errorMsg
|
||||
|
||||
// 提取关键错误信息
|
||||
|
||||
Reference in New Issue
Block a user