refactor: remove config file location display feature
Remove the config file location display from settings dialog to simplify the user interface. Users who need to access the config file can still do so through the advanced settings section. Changes: - Removed ConfigPathDisplay component and its usage - Removed configPath and openConfigFolder from useSettings hook - Removed configPath and openConfigFolder from useSettingsMetadata hook - Removed related i18n keys: configFileLocation, openFolder - Updated settings dialog to remove the config path display section This simplifies the settings UI while maintaining access to config directory management through the advanced settings tab.
This commit is contained in:
@@ -25,7 +25,6 @@ export interface UseSettingsResult {
|
||||
isLoading: boolean;
|
||||
isSaving: boolean;
|
||||
isPortable: boolean;
|
||||
configPath: string;
|
||||
appConfigDir?: string;
|
||||
resolvedDirs: ResolvedDirectories;
|
||||
requiresRestart: boolean;
|
||||
@@ -36,7 +35,6 @@ export interface UseSettingsResult {
|
||||
browseAppConfigDir: () => Promise<void>;
|
||||
resetDirectory: (app: AppType) => Promise<void>;
|
||||
resetAppConfigDir: () => Promise<void>;
|
||||
openConfigFolder: () => Promise<void>;
|
||||
saveSettings: () => Promise<SaveResult | null>;
|
||||
resetSettings: () => void;
|
||||
acknowledgeRestart: () => void;
|
||||
@@ -92,11 +90,9 @@ export function useSettings(): UseSettingsResult {
|
||||
|
||||
// 3️⃣ 元数据管理
|
||||
const {
|
||||
configPath,
|
||||
isPortable,
|
||||
requiresRestart,
|
||||
isLoading: isMetadataLoading,
|
||||
openConfigFolder,
|
||||
acknowledgeRestart,
|
||||
setRequiresRestart,
|
||||
} = useSettingsMetadata();
|
||||
@@ -195,7 +191,6 @@ export function useSettings(): UseSettingsResult {
|
||||
isLoading,
|
||||
isSaving: saveMutation.isPending,
|
||||
isPortable,
|
||||
configPath,
|
||||
appConfigDir,
|
||||
resolvedDirs,
|
||||
requiresRestart,
|
||||
@@ -206,7 +201,6 @@ export function useSettings(): UseSettingsResult {
|
||||
browseAppConfigDir,
|
||||
resetDirectory,
|
||||
resetAppConfigDir,
|
||||
openConfigFolder,
|
||||
saveSettings,
|
||||
resetSettings,
|
||||
acknowledgeRestart,
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { toast } from "sonner";
|
||||
import { settingsApi } from "@/lib/api";
|
||||
|
||||
export interface UseSettingsMetadataResult {
|
||||
configPath: string;
|
||||
isPortable: boolean;
|
||||
requiresRestart: boolean;
|
||||
isLoading: boolean;
|
||||
openConfigFolder: () => Promise<void>;
|
||||
acknowledgeRestart: () => void;
|
||||
setRequiresRestart: (value: boolean) => void;
|
||||
}
|
||||
@@ -16,15 +12,10 @@ export interface UseSettingsMetadataResult {
|
||||
/**
|
||||
* useSettingsMetadata - 元数据管理
|
||||
* 负责:
|
||||
* - configPath(配置文件路径)
|
||||
* - isPortable(便携模式)
|
||||
* - requiresRestart(需要重启标志)
|
||||
* - 打开配置文件夹
|
||||
*/
|
||||
export function useSettingsMetadata(): UseSettingsMetadataResult {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [configPath, setConfigPath] = useState("");
|
||||
const [isPortable, setIsPortable] = useState(false);
|
||||
const [requiresRestart, setRequiresRestart] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
@@ -36,14 +27,10 @@ export function useSettingsMetadata(): UseSettingsMetadataResult {
|
||||
|
||||
const load = async () => {
|
||||
try {
|
||||
const [appConfigPath, portable] = await Promise.all([
|
||||
settingsApi.getAppConfigPath(),
|
||||
settingsApi.isPortable(),
|
||||
]);
|
||||
const portable = await settingsApi.isPortable();
|
||||
|
||||
if (!active) return;
|
||||
|
||||
setConfigPath(appConfigPath || "");
|
||||
setIsPortable(portable);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
@@ -63,32 +50,14 @@ export function useSettingsMetadata(): UseSettingsMetadataResult {
|
||||
};
|
||||
}, []);
|
||||
|
||||
const openConfigFolder = useCallback(async () => {
|
||||
try {
|
||||
await settingsApi.openAppConfigFolder();
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"[useSettingsMetadata] Failed to open config folder",
|
||||
error,
|
||||
);
|
||||
toast.error(
|
||||
t("settings.openFolderFailed", {
|
||||
defaultValue: "打开目录失败",
|
||||
}),
|
||||
);
|
||||
}
|
||||
}, [t]);
|
||||
|
||||
const acknowledgeRestart = useCallback(() => {
|
||||
setRequiresRestart(false);
|
||||
}, []);
|
||||
|
||||
return {
|
||||
configPath,
|
||||
isPortable,
|
||||
requiresRestart,
|
||||
isLoading,
|
||||
openConfigFolder,
|
||||
acknowledgeRestart,
|
||||
setRequiresRestart,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user