mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-25 13:12:07 +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:
@@ -138,14 +138,10 @@ async fn refresh_core_config() {
|
||||
Type::Config,
|
||||
"Deep link import set current profile; refreshing core config"
|
||||
);
|
||||
match CoreManager::global().update_config().await {
|
||||
Ok((true, _)) => handle::Handle::refresh_clash(),
|
||||
Ok((false, msg)) => {
|
||||
let message = if msg.is_empty() {
|
||||
String::from("Failed to apply subscription configuration")
|
||||
} else {
|
||||
msg
|
||||
};
|
||||
match CoreManager::global().update_config_forced().await {
|
||||
Ok(outcome) if outcome.is_valid() => handle::Handle::refresh_clash(),
|
||||
Ok(outcome) => {
|
||||
let message = outcome.to_string();
|
||||
logging!(warn, Type::Config, "Apply config failed: {}", message);
|
||||
handle::Handle::notice_message("config_validate::error", message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user