mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-04 20:17:31 +08:00
feat: add backend config change listener to update frontend state
This commit is contained in:
parent
23b0493d0b
commit
ff5a2c6ca4
@ -17,6 +17,7 @@
|
||||
- Vless URL 解码时网络类型错误
|
||||
- 切换自定义代理地址导致系统代理状态异常
|
||||
- Macos TUN 默认无效网卡名称
|
||||
- 托盘更改订阅后 UI 不同步的问题
|
||||
|
||||
#### 新增了:
|
||||
- 允许代理主机地址设置为非 127.0.0.1 对 WSL 代理友好
|
||||
@ -43,6 +44,7 @@
|
||||
- 改进核心功能防止主进程阻塞、改进MihomoManager实现,以及优化窗口创建流程。减少应用程序可能出现的主进程卡死情况
|
||||
- 优化系统代理设置更新逻辑
|
||||
- 重构前端通知系统分离通知线程防止前端卡死
|
||||
- 优化网络请求和错误处理
|
||||
|
||||
## v2.2.3
|
||||
|
||||
|
@ -146,6 +146,9 @@ pub async fn patch_profiles_config(profiles: IProfiles) -> CmdResult<bool> {
|
||||
|
||||
// 更新profiles配置
|
||||
logging!(info, Type::Cmd, true, "正在更新配置草稿");
|
||||
|
||||
let current_value = profiles.current.clone();
|
||||
|
||||
let _ = Config::profiles().draft().patch_config(profiles);
|
||||
|
||||
// 更新配置并进行验证
|
||||
@ -156,6 +159,14 @@ pub async fn patch_profiles_config(profiles: IProfiles) -> CmdResult<bool> {
|
||||
let _ = Tray::global().update_tooltip();
|
||||
Config::profiles().apply();
|
||||
wrap_err!(Config::profiles().data().save_file())?;
|
||||
|
||||
if let Some(window) = handle::Handle::global().get_window() {
|
||||
if let Some(current) = ¤t_value {
|
||||
logging!(info, Type::Cmd, true, "向前端发送配置变更事件: {}", current);
|
||||
let _ = window.emit("profile-changed", current.clone());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(true)
|
||||
}
|
||||
Ok((false, error_msg)) => {
|
||||
|
@ -295,6 +295,24 @@ const ProfilePage = () => {
|
||||
? "rgba(0, 0, 0, 0.06)"
|
||||
: "rgba(255, 255, 255, 0.06)";
|
||||
|
||||
// 监听后端配置变更
|
||||
useEffect(() => {
|
||||
let unlistenPromise: Promise<() => void> | undefined;
|
||||
|
||||
const setupListener = async () => {
|
||||
unlistenPromise = listen<string>('profile-changed', (event) => {
|
||||
console.log('Profile changed event received:', event.payload);
|
||||
mutateProfiles();
|
||||
});
|
||||
};
|
||||
|
||||
setupListener();
|
||||
|
||||
return () => {
|
||||
unlistenPromise?.then(unlisten => unlisten());
|
||||
};
|
||||
}, [mutateProfiles, t]);
|
||||
|
||||
return (
|
||||
<BasePage
|
||||
full
|
||||
|
Loading…
x
Reference in New Issue
Block a user