refactor(settings): rename Dock setting to system tray (showInDock → showInTray)
- compat: map legacy showInDock to showInTray when loading settings - ui(copy): clarify “system tray (menu bar)” vs Dock in SettingsModal - tauri(settings): return showInTray in get_settings; adjust default fallback - docs(comment): align comments to “system tray” terminology across code - note: no functional change yet; tray visibility toggle remains unimplemented
This commit is contained in:
@@ -567,9 +567,9 @@ pub async fn open_app_config_folder(handle: tauri::AppHandle) -> Result<bool, St
|
||||
/// 获取设置
|
||||
#[tauri::command]
|
||||
pub async fn get_settings(_state: State<'_, AppState>) -> Result<serde_json::Value, String> {
|
||||
// 暂时返回默认设置
|
||||
// 暂时返回默认设置:系统托盘(菜单栏)显示开关
|
||||
Ok(serde_json::json!({
|
||||
"showInDock": true
|
||||
"showInTray": true
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -579,7 +579,7 @@ pub async fn save_settings(
|
||||
_state: State<'_, AppState>,
|
||||
settings: serde_json::Value,
|
||||
) -> Result<bool, String> {
|
||||
// TODO: 实现设置保存逻辑
|
||||
// TODO: 实现系统托盘显示开关的保存与应用(显示/隐藏菜单栏托盘图标)
|
||||
log::info!("保存设置: {:?}", settings);
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ interface SettingsModalProps {
|
||||
|
||||
export default function SettingsModal({ onClose }: SettingsModalProps) {
|
||||
const [settings, setSettings] = useState<Settings>({
|
||||
showInDock: true,
|
||||
showInTray: true,
|
||||
});
|
||||
const [configPath, setConfigPath] = useState<string>("");
|
||||
const [version, setVersion] = useState<string>("");
|
||||
@@ -49,8 +49,11 @@ export default function SettingsModal({ onClose }: SettingsModalProps) {
|
||||
const loadSettings = async () => {
|
||||
try {
|
||||
const loadedSettings = await window.api.getSettings();
|
||||
if (loadedSettings?.showInDock !== undefined) {
|
||||
setSettings({ showInDock: loadedSettings.showInDock });
|
||||
if ((loadedSettings as any)?.showInTray !== undefined) {
|
||||
setSettings({ showInTray: (loadedSettings as any).showInTray });
|
||||
} else if ((loadedSettings as any)?.showInDock !== undefined) {
|
||||
// 向后兼容:若历史上有 showInDock,则映射为 showInTray
|
||||
setSettings({ showInTray: (loadedSettings as any).showInDock });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("加载设置失败:", error);
|
||||
@@ -171,20 +174,21 @@ export default function SettingsModal({ onClose }: SettingsModalProps) {
|
||||
|
||||
{/* 设置内容 */}
|
||||
<div className="px-6 py-4 space-y-6">
|
||||
{/* 显示设置 - 功能还未实现 */}
|
||||
{/* 系统托盘设置(未实现)
|
||||
说明:此开关用于控制是否在系统托盘/菜单栏显示应用图标。 */}
|
||||
{/* <div>
|
||||
<h3 className="text-sm font-medium text-gray-900 dark:text-gray-100 mb-3">
|
||||
显示设置
|
||||
显示设置(系统托盘)
|
||||
</h3>
|
||||
<label className="flex items-center justify-between">
|
||||
<span className="text-sm text-gray-500">
|
||||
在 Dock 中显示(macOS)
|
||||
在菜单栏显示图标(系统托盘)
|
||||
</span>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={settings.showInDock}
|
||||
checked={settings.showInTray}
|
||||
onChange={(e) =>
|
||||
setSettings({ ...settings, showInDock: e.target.checked })
|
||||
setSettings({ ...settings, showInTray: e.target.checked })
|
||||
}
|
||||
className="w-4 h-4 text-blue-500 rounded focus:ring-blue-500/20"
|
||||
/>
|
||||
|
||||
@@ -201,7 +201,7 @@ export const tauriAPI = {
|
||||
return await invoke("get_settings");
|
||||
} catch (error) {
|
||||
console.error("获取设置失败:", error);
|
||||
return { showInDock: true };
|
||||
return { showInTray: true };
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -13,5 +13,6 @@ export interface AppConfig {
|
||||
|
||||
// 应用设置类型(用于 SettingsModal 与 Tauri API)
|
||||
export interface Settings {
|
||||
showInDock: boolean;
|
||||
// 是否在系统托盘(macOS 菜单栏)显示图标
|
||||
showInTray: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user