mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-06-16 13:34:04 +08:00
57552b3159
- Fix negative margin overflow in all dialog content areas - Standardize dialog structure with flex-col layout - Add consistent py-4 spacing to all content areas - Ensure proper spacing between header, content, and footer Affected components: - AddProviderDialog, EditProviderDialog - McpFormModal, McpPanel - UsageScriptModal - SettingsDialog All dialogs now follow unified layout pattern: - DialogContent: flex flex-col max-h-[90vh] - Content area: flex-1 overflow-y-auto px-6 py-4 - No negative margins that cause content overflow
62 lines
1.4 KiB
TypeScript
62 lines
1.4 KiB
TypeScript
import { useCallback, useEffect, useState } from "react";
|
|
import { settingsApi } from "@/lib/api";
|
|
|
|
export interface UseSettingsMetadataResult {
|
|
isPortable: boolean;
|
|
requiresRestart: boolean;
|
|
isLoading: boolean;
|
|
acknowledgeRestart: () => void;
|
|
setRequiresRestart: (value: boolean) => void;
|
|
}
|
|
|
|
/**
|
|
* useSettingsMetadata - 元数据管理
|
|
* 负责:
|
|
* - isPortable(便携模式)
|
|
* - requiresRestart(需要重启标志)
|
|
*/
|
|
export function useSettingsMetadata(): UseSettingsMetadataResult {
|
|
const [isPortable, setIsPortable] = useState(false);
|
|
const [requiresRestart, setRequiresRestart] = useState(false);
|
|
const [isLoading, setIsLoading] = useState(true);
|
|
|
|
// 加载元数据
|
|
useEffect(() => {
|
|
let active = true;
|
|
setIsLoading(true);
|
|
|
|
const load = async () => {
|
|
try {
|
|
const portable = await settingsApi.isPortable();
|
|
|
|
if (!active) return;
|
|
|
|
setIsPortable(portable);
|
|
} catch (error) {
|
|
console.error("[useSettingsMetadata] Failed to load metadata", error);
|
|
} finally {
|
|
if (active) {
|
|
setIsLoading(false);
|
|
}
|
|
}
|
|
};
|
|
|
|
void load();
|
|
return () => {
|
|
active = false;
|
|
};
|
|
}, []);
|
|
|
|
const acknowledgeRestart = useCallback(() => {
|
|
setRequiresRestart(false);
|
|
}, []);
|
|
|
|
return {
|
|
isPortable,
|
|
requiresRestart,
|
|
isLoading,
|
|
acknowledgeRestart,
|
|
setRequiresRestart,
|
|
};
|
|
}
|