diff --git a/UPDATELOG.md b/UPDATELOG.md index c583998d..3f6ec3cc 100644 --- a/UPDATELOG.md +++ b/UPDATELOG.md @@ -1,9 +1,12 @@ ## v2.2.4-alpha +尽管外部控制密钥已自动补全默认值且不允许为空。仍然推荐自行修改外部控制密钥。 + #### 已知问题 - 仅在Ubuntu 22.04/24.04,Fedora 41 **Gnome桌面环境** 做过简单测试,不保证其他其他Linux发行版可用,将在未来做进一步适配和调优 - MacOS 下 墙贴主要为浅色,Tray 图标深色时图标闪烁;彩色 Tray 速率颜色淡 - 窗口状态管理器已确定上游存在缺陷,暂时移除。当前不再内置窗口大小和位置记忆。 + - MacOS 下卸载服务后需手动重启软件才能与内核通信。 ### 2.2.4 相对于 2.2.3 #### 修复了: @@ -50,6 +53,7 @@ - 切换、升级、重启内核的状态管理 - 更精细化控制自动日志清理,新增1天选项 - Winodws 快捷键名称改为 `Clash Verge` + - 配置加载阶段自动补全 external-controller secret 字段。 #### 优化了: - 系统代理 Bypass 设置 @@ -79,6 +83,7 @@ - 优化端口设置退出和保存机制 - 强制为 Mihomo 配置补全并覆盖 external-controller-cors 字段,默认不允许跨域和仅本地请求,提升 cors 安全性,升级配置时自动覆盖 - 修改 端口检测范围 (1111-65536) + - 配置文件缺失 secret 字段时自动填充默认值 set-your-secret #### 移除了: - 窗口状态管理器 diff --git a/src-tauri/src/config/clash.rs b/src-tauri/src/config/clash.rs index aca558e5..5dbefdfd 100644 --- a/src-tauri/src/config/clash.rs +++ b/src-tauri/src/config/clash.rs @@ -20,6 +20,12 @@ impl IClashTemp { map.insert(key.clone(), template.0.get(key).unwrap().clone()); } }); + // 确保 secret 字段存在且不为空 + if let Some(Value::String(s)) = map.get_mut("secret") { + if s.is_empty() { + *s = "set-your-secret".to_string(); + } + } Self(Self::guard(map)) } Err(err) => { @@ -64,7 +70,7 @@ impl IClashTemp { ] .into(), ); - map.insert("secret".into(), "".into()); + map.insert("secret".into(), "set-your-secret".into()); map.insert("tun".into(), tun.into()); map.insert("external-controller-cors".into(), cors_map.into()); map.insert("unified-delay".into(), true.into()); diff --git a/src/components/setting/mods/controller-viewer.tsx b/src/components/setting/mods/controller-viewer.tsx index 4724355b..e32c158c 100644 --- a/src/components/setting/mods/controller-viewer.tsx +++ b/src/components/setting/mods/controller-viewer.tsx @@ -42,7 +42,12 @@ export const ControllerViewer = forwardRef((props, ref) => { // 保存配置 const onSave = useLockFn(async () => { if (!controller.trim()) { - showNotice('info', t("Controller address cannot be empty"), 3000); + showNotice('error', t("Controller address cannot be empty"), 3000); + return; + } + + if (!secret.trim()) { + showNotice('error', t("Secret cannot be empty"), 3000); return; } @@ -95,14 +100,13 @@ export const ControllerViewer = forwardRef((props, ref) => { size="small" sx={{ width: 175, - opacity: 0.7, - pointerEvents: 'none' + opacity: 1, + pointerEvents: 'auto' }} value={controller} placeholder="Required" - onChange={() => {}} - disabled={true} - inputProps={{ readOnly: true }} + onChange={e => setController(e.target.value)} + disabled={isSaving} /> ((props, ref) => { size="small" sx={{ width: 175, - opacity: 0.7, - pointerEvents: 'none' + opacity: 1, + pointerEvents: 'auto' }} value={secret} placeholder={t("Recommended")} - onChange={() => {}} - disabled={true} - inputProps={{ readOnly: true }} + onChange={e => setSecret(e.target.value)} + disabled={isSaving} />