mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-22 19:52:14 +08:00
* refactor(core): type notice statuses behind the frozen wire contract * refactor(utils): unified retry and strategy-list helpers * refactor(feat): declarative effect registry for verge and clash patches * refactor(core): derive refresh announcements from transaction commit * refactor(core): fold tray, hotkey, autostart updates into effect ensures * refactor(utils): migrate remaining bounded retry loops * docs: add src-tauri architecture guardrails * refactor(core): coalesce burst refresh announcements * refactor(core): complete bounded service retry migration * ci(backend): add architecture ban gates * test(feat): freeze representative effect registry mappings * docs(backend): record dead wire contract entries * chore(core): document watcher exit conditions * fix(backend): preserve applied state across later failures * fix(config): retain runtime after an applied core replacement * refactor(backend): flatten refresh publication and retry policies * docs(backend): focus guardrails on architecture ownership * refactor(effects): use one execution order * fix(config): publish retained runtime and reconcile proxy settings
54 lines
2.5 KiB
Rust
54 lines
2.5 KiB
Rust
use crate::core::notify::NoticeStatus;
|
|
use crate::core::{
|
|
handle,
|
|
validate::{ValidationErrorKind, ValidationOutcome},
|
|
};
|
|
use clash_verge_logging::{Type, logging};
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
pub enum ValidationNoticeTarget {
|
|
Runtime,
|
|
Merge,
|
|
Script,
|
|
}
|
|
|
|
const fn notice_key(kind: ValidationErrorKind, target: ValidationNoticeTarget) -> NoticeStatus {
|
|
match kind {
|
|
ValidationErrorKind::FileMissing => NoticeStatus::ConfigValidateFileNotFound,
|
|
ValidationErrorKind::FileRead => match target {
|
|
ValidationNoticeTarget::Script => NoticeStatus::ConfigValidateScriptError,
|
|
_ => NoticeStatus::ConfigValidateYamlReadError,
|
|
},
|
|
ValidationErrorKind::YamlSyntax => match target {
|
|
ValidationNoticeTarget::Merge => NoticeStatus::ConfigValidateMergeSyntaxError,
|
|
ValidationNoticeTarget::Script => NoticeStatus::ConfigValidateScriptError,
|
|
ValidationNoticeTarget::Runtime => NoticeStatus::ConfigValidateYamlSyntaxError,
|
|
},
|
|
ValidationErrorKind::YamlMapping => match target {
|
|
ValidationNoticeTarget::Merge => NoticeStatus::ConfigValidateMergeMappingError,
|
|
ValidationNoticeTarget::Script => NoticeStatus::ConfigValidateScriptError,
|
|
ValidationNoticeTarget::Runtime => NoticeStatus::ConfigValidateYamlMappingError,
|
|
},
|
|
ValidationErrorKind::ScriptSyntax => NoticeStatus::ConfigValidateScriptSyntaxError,
|
|
ValidationErrorKind::ScriptMissingMain => NoticeStatus::ConfigValidateScriptMissingMain,
|
|
ValidationErrorKind::ProcessTerminated => NoticeStatus::ConfigValidateProcessTerminated,
|
|
ValidationErrorKind::CoreRejected | ValidationErrorKind::Timeout => NoticeStatus::ConfigValidateError,
|
|
}
|
|
}
|
|
|
|
pub fn handle_validation_notice(outcome: &ValidationOutcome, target: ValidationNoticeTarget, file_type: &str) {
|
|
match outcome {
|
|
ValidationOutcome::Invalid { kind, message } => {
|
|
let status = notice_key(*kind, target);
|
|
logging!(warn, Type::Config, "{} 验证失败: {}", file_type, message);
|
|
handle::Handle::notice(status, message.as_str());
|
|
}
|
|
ValidationOutcome::Busy | ValidationOutcome::Skipped { .. } => {
|
|
let message = outcome.to_string();
|
|
logging!(warn, Type::Config, "{} 验证跳过: {}", file_type, message);
|
|
handle::Handle::notice(NoticeStatus::ConfigValidateError, message.as_str());
|
|
}
|
|
ValidationOutcome::Valid => {}
|
|
}
|
|
}
|