mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
refactor(profiles): drop manual snapshot update now that switching autosaves
Since switching projects automatically saves the current configuration back to the project being left, the per-project "update from current" button is redundant and even harmful: it allowed overwriting another project's snapshot with the current state, breaking the invariant that a project holds the state you last left it in. - Remove the resnapshot button and confirm dialog from the manage dialog; drop the now-unused scope prop and PROFILE_SCOPE_LABELS - Add a footer Close button to the manage dialog (overlay click is disabled app-wide, so it previously could only be closed via Esc) - Update manageDescription in all four locales to describe the autosave behavior; remove the two dead i18n keys - Fix a shadowed `warnings` vec in ProfileService::apply that silently dropped autosave-failure warnings before they reached the frontend - Mention auto-capture on next switch in the "no snapshot for this scope yet" warning and doc comments The backend update command keeps its resnapshot parameter; it is now only exercised by the pre-switch autosave path.
This commit is contained in:
@@ -184,12 +184,7 @@ pub fn apply_profile(
|
||||
log::warn!("切换项目后停止代理服务失败: {e}");
|
||||
}
|
||||
if let Some(app_state) = app_handle.try_state::<AppState>() {
|
||||
emit_profile_apply_events(
|
||||
&app_handle,
|
||||
app_state.inner(),
|
||||
&profile_id,
|
||||
scope,
|
||||
);
|
||||
emit_profile_apply_events(&app_handle, app_state.inner(), &profile_id, scope);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -264,7 +264,8 @@ impl ProfileService {
|
||||
}
|
||||
|
||||
/// 更新项目:重命名(作用于共享实体)和/或以当前状态重拍快照
|
||||
/// (resnapshot 只覆盖 scope 分组的槽位,其余分组原样保留)
|
||||
/// (resnapshot 只覆盖 scope 分组的槽位,其余分组原样保留;
|
||||
/// 快照重拍仅由 [`Self::apply`] 切换前的自动保存触发,UI 不再暴露手动入口)
|
||||
pub fn update(
|
||||
state: &AppState,
|
||||
id: &str,
|
||||
@@ -314,7 +315,7 @@ impl ProfileService {
|
||||
///
|
||||
/// 只作用于发起页所属分组内的应用,不碰其他分组的配置与 current 标记。
|
||||
/// 该分组从未拍过快照时不改动任何配置,仅标记 current 并返回提示
|
||||
/// (用户可先绑定项目、再"以当前状态更新"补拍该侧快照)。
|
||||
/// (下次从该项目切走时,自动保存会补拍该侧快照)。
|
||||
///
|
||||
/// **切换前会自动保存旧项目**:若当前分组已绑定到另一个项目,先把当前
|
||||
/// 状态写入那个旧项目(仅当前分组槽位),再加载目标项目。这样切走后
|
||||
@@ -351,10 +352,9 @@ impl ProfileService {
|
||||
let payload: ProfilePayload = serde_json::from_str(&profile.payload)
|
||||
.map_err(|e| AppError::Config(format!("解析 profile payload 失败: {e}")))?;
|
||||
|
||||
let mut warnings = Vec::new();
|
||||
if !payload.scope_captured(scope) {
|
||||
warnings.push(format!(
|
||||
"no {} configuration captured in this project yet; marked as current without changes",
|
||||
"no {} configuration captured in this project yet; marked as current without changes (it will be saved automatically when you switch away)",
|
||||
scope.as_str()
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user