refactor: clean code

This commit is contained in:
Fu Diwei
2024-10-22 11:38:55 +08:00
parent 18a7bf0d66
commit 716f5f1426
26 changed files with 63 additions and 60 deletions

View File

@@ -8,7 +8,7 @@ import { Switch } from "@/components/ui/switch";
import { useToast } from "@/components/ui/use-toast";
import { getErrMessage } from "@/lib/error";
import { NotifyChannelDingTalk, NotifyChannels } from "@/domain/settings";
import { useNotify } from "@/providers/notify";
import { useNotifyContext } from "@/providers/notify";
import { update } from "@/repository/settings";
import Show from "@/components/Show";
import { notifyTest } from "@/api/notify";
@@ -20,7 +20,7 @@ type DingTalkSetting = {
};
const DingTalk = () => {
const { config, setChannels } = useNotify();
const { config, setChannels } = useNotifyContext();
const { t } = useTranslation();
const [changed, setChanged] = useState<boolean>(false);
@@ -241,4 +241,3 @@ const DingTalk = () => {
};
export default DingTalk;

View File

@@ -2,7 +2,7 @@ import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { Switch } from "@/components/ui/switch";
import { Label } from "@/components/ui/label";
import { useNotify } from "@/providers/notify";
import { useNotifyContext } from "@/providers/notify";
import { NotifyChannelLark, NotifyChannels } from "@/domain/settings";
import { useEffect, useState } from "react";
import { update } from "@/repository/settings";
@@ -19,7 +19,7 @@ type LarkSetting = {
};
const Lark = () => {
const { config, setChannels } = useNotify();
const { config, setChannels } = useNotifyContext();
const { t } = useTranslation();
const [changed, setChanged] = useState<boolean>(false);
@@ -222,4 +222,3 @@ const Lark = () => {
};
export default Lark;

View File

@@ -9,7 +9,7 @@ import { useToast } from "@/components/ui/use-toast";
import { getErrMessage } from "@/lib/error";
import { NotifyChannels, NotifyChannelTelegram } from "@/domain/settings";
import { update } from "@/repository/settings";
import { useNotify } from "@/providers/notify";
import { useNotifyContext } from "@/providers/notify";
import { notifyTest } from "@/api/notify";
import Show from "@/components/Show";
@@ -20,7 +20,7 @@ type TelegramSetting = {
};
const Telegram = () => {
const { config, setChannels } = useNotify();
const { config, setChannels } = useNotifyContext();
const { t } = useTranslation();
const [changed, setChanged] = useState<boolean>(false);
@@ -244,4 +244,3 @@ const Telegram = () => {
};
export default Telegram;

View File

@@ -10,7 +10,7 @@ import { getErrMessage } from "@/lib/error";
import { isValidURL } from "@/lib/url";
import { NotifyChannels, NotifyChannelWebhook } from "@/domain/settings";
import { update } from "@/repository/settings";
import { useNotify } from "@/providers/notify";
import { useNotifyContext } from "@/providers/notify";
import { notifyTest } from "@/api/notify";
import Show from "@/components/Show";
@@ -21,7 +21,7 @@ type WebhookSetting = {
};
const Webhook = () => {
const { config, setChannels } = useNotify();
const { config, setChannels } = useNotifyContext();
const { t } = useTranslation();
const [changed, setChanged] = useState<boolean>(false);
@@ -234,4 +234,3 @@ const Webhook = () => {
};
export default Webhook;