refactor(types): introduce Settings and apply in API

- style(prettier): format src files
- style(rustfmt): format Rust sources
- refactor(tauri-api): type-safe getSettings/saveSettings
- refactor(d.ts): declare window.api with Settings

[skip ci]
This commit is contained in:
Jason
2025-09-07 11:36:09 +08:00
parent 77bdeb02fb
commit 02bfc97ee6
11 changed files with 210 additions and 106 deletions

View File

@@ -1,10 +1,7 @@
import { useState, useEffect } from "react";
import { X, Info, RefreshCw, FolderOpen } from "lucide-react";
import "../lib/tauri-api";
interface Settings {
showInDock: boolean;
}
import type { Settings } from "../types";
interface SettingsModalProps {
onClose: () => void;
@@ -36,9 +33,9 @@ export default function SettingsModal({ onClose }: SettingsModalProps) {
const loadConfigPath = async () => {
try {
const status = await window.api.getConfigStatus("claude");
if (status?.path) {
setConfigPath(status.path.replace("/claude_code_config.json", ""));
const path = await window.api.getAppConfigPath();
if (path) {
setConfigPath(path);
}
} catch (error) {
console.error("获取配置路径失败:", error);
@@ -67,7 +64,7 @@ export default function SettingsModal({ onClose }: SettingsModalProps) {
const handleOpenConfigFolder = async () => {
try {
await window.api.openConfigFolder("claude");
await window.api.openAppConfigFolder();
} catch (error) {
console.error("打开配置文件夹失败:", error);
}