perf: add notification toasts

This commit is contained in:
Junyan Qin
2025-05-09 22:36:13 +08:00
parent 337090e7cb
commit df700ec7c2
17 changed files with 131 additions and 71 deletions
@@ -4,6 +4,7 @@ import { httpClient } from '@/app/infra/http/HttpClient';
import { Badge } from "@/components/ui/badge"
import { Switch } from "@/components/ui/switch"
import { Button } from "@/components/ui/button"
import { toast } from "sonner"
export default function PluginCardComponent({
cardVO,
@@ -24,7 +25,7 @@ export default function PluginCardComponent({
setEnabled(!enabled);
})
.catch((err) => {
console.log('error: ', err);
toast.error("修改失败:" + err.message);
})
.finally(() => {
setSwitchEnable(true);
@@ -12,6 +12,7 @@ import {
DialogTitle,
DialogFooter,
} from "@/components/ui/dialog";
import { toast } from "sonner";
enum PluginRemoveStatus {
WAIT_INPUT = 'WAIT_INPUT',
@@ -51,14 +52,14 @@ export default function PluginForm({
const handleSubmit = async (values: object) => {
setIsLoading(true);
try {
await httpClient.updatePluginConfig(pluginAuthor, pluginName, values);
onFormSubmit();
} catch (error) {
console.error('更新插件配置失败:', error);
} finally {
setIsLoading(false);
}
httpClient.updatePluginConfig(pluginAuthor, pluginName, values).then(() => {
onFormSubmit();
toast.success("保存成功");
}).catch((error) => {
toast.error("保存失败:" + error.message);
}).finally(() => {
setIsLoading(false);
});
};
if (!pluginInfo || !pluginConfig) {