mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-29 01:25:33 +08:00
fix(ui): add close button to all success toasts
This commit is contained in:
@@ -87,6 +87,7 @@ export function useDragSort(providers: Record<string, Provider>, appId: AppId) {
|
||||
t("provider.sortUpdated", {
|
||||
defaultValue: "排序已更新",
|
||||
}),
|
||||
{ closeButton: true },
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Failed to update provider sort order", error);
|
||||
|
||||
@@ -113,6 +113,7 @@ export function useImportExport(
|
||||
t("settings.importSuccess", {
|
||||
defaultValue: "配置导入成功",
|
||||
}),
|
||||
{ closeButton: true },
|
||||
);
|
||||
|
||||
successTimerRef.current = window.setTimeout(() => {
|
||||
@@ -170,6 +171,7 @@ export function useImportExport(
|
||||
t("settings.configExported", {
|
||||
defaultValue: "配置已导出",
|
||||
}) + `\n${displayPath}`,
|
||||
{ closeButton: true },
|
||||
);
|
||||
} else {
|
||||
toast.error(
|
||||
|
||||
@@ -36,7 +36,7 @@ export function usePromptActions(appId: AppId) {
|
||||
try {
|
||||
await promptsApi.upsertPrompt(appId, id, prompt);
|
||||
await reload();
|
||||
toast.success(t("prompts.saveSuccess"));
|
||||
toast.success(t("prompts.saveSuccess"), { closeButton: true });
|
||||
} catch (error) {
|
||||
toast.error(t("prompts.saveFailed"));
|
||||
throw error;
|
||||
@@ -50,7 +50,7 @@ export function usePromptActions(appId: AppId) {
|
||||
try {
|
||||
await promptsApi.deletePrompt(appId, id);
|
||||
await reload();
|
||||
toast.success(t("prompts.deleteSuccess"));
|
||||
toast.success(t("prompts.deleteSuccess"), { closeButton: true });
|
||||
} catch (error) {
|
||||
toast.error(t("prompts.deleteFailed"));
|
||||
throw error;
|
||||
@@ -64,7 +64,7 @@ export function usePromptActions(appId: AppId) {
|
||||
try {
|
||||
await promptsApi.enablePrompt(appId, id);
|
||||
await reload();
|
||||
toast.success(t("prompts.enableSuccess"));
|
||||
toast.success(t("prompts.enableSuccess"), { closeButton: true });
|
||||
} catch (error) {
|
||||
toast.error(t("prompts.enableFailed"));
|
||||
throw error;
|
||||
@@ -104,14 +104,14 @@ export function usePromptActions(appId: AppId) {
|
||||
try {
|
||||
if (enabled) {
|
||||
await promptsApi.enablePrompt(appId, id);
|
||||
toast.success(t("prompts.enableSuccess"));
|
||||
toast.success(t("prompts.enableSuccess"), { closeButton: true });
|
||||
} else {
|
||||
// 禁用提示词 - 需要后端支持
|
||||
await promptsApi.upsertPrompt(appId, id, {
|
||||
...prompts[id],
|
||||
enabled: false,
|
||||
});
|
||||
toast.success(t("prompts.disableSuccess"));
|
||||
toast.success(t("prompts.disableSuccess"), { closeButton: true });
|
||||
}
|
||||
await reload();
|
||||
} catch (error) {
|
||||
@@ -130,7 +130,7 @@ export function usePromptActions(appId: AppId) {
|
||||
try {
|
||||
const id = await promptsApi.importFromFile(appId);
|
||||
await reload();
|
||||
toast.success(t("prompts.importSuccess"));
|
||||
toast.success(t("prompts.importSuccess"), { closeButton: true });
|
||||
return id;
|
||||
} catch (error) {
|
||||
toast.error(t("prompts.importFailed"));
|
||||
|
||||
@@ -119,6 +119,7 @@ export function useProviderActions(activeApp: AppId) {
|
||||
t("provider.usageSaved", {
|
||||
defaultValue: "用量查询配置已保存",
|
||||
}),
|
||||
{ closeButton: true },
|
||||
);
|
||||
} catch (error) {
|
||||
const detail =
|
||||
|
||||
@@ -24,7 +24,7 @@ export function useProxyConfig() {
|
||||
mutationFn: (newConfig: ProxyConfig) =>
|
||||
invoke("update_proxy_config", { config: newConfig }),
|
||||
onSuccess: () => {
|
||||
toast.success("代理配置已保存");
|
||||
toast.success("代理配置已保存", { closeButton: true });
|
||||
queryClient.invalidateQueries({ queryKey: ["proxyConfig"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["proxyStatus"] });
|
||||
},
|
||||
|
||||
@@ -40,6 +40,7 @@ export function useProxyStatus() {
|
||||
t("proxy.startedWithTakeover", {
|
||||
defaultValue: `代理模式已启用 - ${info.address}:${info.port}`,
|
||||
}),
|
||||
{ closeButton: true },
|
||||
);
|
||||
queryClient.invalidateQueries({ queryKey: ["proxyStatus"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["proxyTakeoverActive"] });
|
||||
@@ -62,6 +63,7 @@ export function useProxyStatus() {
|
||||
t("proxy.stoppedWithRestore", {
|
||||
defaultValue: "代理模式已关闭,配置已恢复",
|
||||
}),
|
||||
{ closeButton: true },
|
||||
);
|
||||
queryClient.invalidateQueries({ queryKey: ["proxyStatus"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["proxyTakeoverActive"] });
|
||||
|
||||
@@ -309,6 +309,7 @@ export function useSettings(): UseSettingsResult {
|
||||
t("notifications.settingsSaved", {
|
||||
defaultValue: "设置已保存",
|
||||
}),
|
||||
{ closeButton: true },
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ export function useStreamCheck(appId: AppId) {
|
||||
time: result.responseTimeMs,
|
||||
defaultValue: `${providerName} 运行正常 (${result.responseTimeMs}ms)`,
|
||||
}),
|
||||
{ closeButton: true },
|
||||
);
|
||||
} else if (result.status === "degraded") {
|
||||
toast.warning(
|
||||
|
||||
Reference in New Issue
Block a user