refactor: unify showNotice usage
This commit is contained in:
@@ -297,7 +297,7 @@ export const HomeProfileCard = ({
|
||||
// 刷新首页数据
|
||||
refreshAll();
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()), 3000);
|
||||
showNotice.error(createRawNotice(err.message || err.toString()), 3000);
|
||||
} finally {
|
||||
setUpdating(false);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ export const ProxyTunCard: FC = () => {
|
||||
const { enable_tun_mode } = verge ?? {};
|
||||
|
||||
const handleError = (err: Error) => {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
};
|
||||
|
||||
const handleTabChange = (tab: string) => {
|
||||
|
||||
@@ -174,15 +174,15 @@ export const SystemInfoCard = () => {
|
||||
try {
|
||||
const info = await checkUpdate();
|
||||
if (!info?.available) {
|
||||
showNotice("success", {
|
||||
showNotice.success({
|
||||
i18nKey: "Currently on the Latest Version",
|
||||
});
|
||||
} else {
|
||||
showNotice("info", { i18nKey: "Update Available" }, 2000);
|
||||
showNotice.info({ i18nKey: "Update Available" }, 2000);
|
||||
goToSettings();
|
||||
}
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ export const EditorViewer = <T extends Language>(props: Props<T>) => {
|
||||
currData.current = value;
|
||||
onChange?.(prevData.current, currData.current);
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -144,7 +144,7 @@ export const EditorViewer = <T extends Language>(props: Props<T>) => {
|
||||
}
|
||||
onClose();
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -152,7 +152,7 @@ export const EditorViewer = <T extends Language>(props: Props<T>) => {
|
||||
try {
|
||||
onClose();
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -384,14 +384,14 @@ export const GroupsEditorViewer = (props: Props) => {
|
||||
}
|
||||
|
||||
await saveProfileFile(property, nextData);
|
||||
showNotice("success", {
|
||||
showNotice.success({
|
||||
i18nKey: "components.profile.notifications.saved",
|
||||
});
|
||||
setPrevData(nextData);
|
||||
onSave?.(prevData, nextData);
|
||||
onClose();
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.toString()));
|
||||
showNotice.error(createRawNotice(err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -922,8 +922,7 @@ export const GroupsEditorViewer = (props: Props) => {
|
||||
}
|
||||
setPrependSeq([formIns.getValues(), ...prependSeq]);
|
||||
} catch (err: any) {
|
||||
showNotice(
|
||||
"error",
|
||||
showNotice.error(
|
||||
createRawNotice(err.message || err.toString()),
|
||||
);
|
||||
}
|
||||
@@ -951,8 +950,7 @@ export const GroupsEditorViewer = (props: Props) => {
|
||||
}
|
||||
setAppendSeq([...appendSeq, formIns.getValues()]);
|
||||
} catch (err: any) {
|
||||
showNotice(
|
||||
"error",
|
||||
showNotice.error(
|
||||
createRawNotice(err.message || err.toString()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ export const ProfileItem = (props: Props) => {
|
||||
try {
|
||||
await viewProfile(itemData.uid);
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err?.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err?.message || err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ export const ProfileMore = (props: Props) => {
|
||||
try {
|
||||
await viewProfile(id);
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err?.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err?.message || err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -144,8 +144,7 @@ export function ProfileViewer({ onChange, ref }: ProfileViewerProps) {
|
||||
}
|
||||
} catch {
|
||||
// 首次创建/更新失败,尝试使用自身代理
|
||||
showNotice(
|
||||
"info",
|
||||
showNotice.info(
|
||||
t("components.profile.viewer.notifications.creationRetry"),
|
||||
);
|
||||
|
||||
@@ -170,8 +169,7 @@ export function ProfileViewer({ onChange, ref }: ProfileViewerProps) {
|
||||
await patchProfile(form.uid, { option: originalOptions });
|
||||
}
|
||||
|
||||
showNotice(
|
||||
"success",
|
||||
showNotice.success(
|
||||
t("components.profile.viewer.notifications.creationSuccess"),
|
||||
);
|
||||
}
|
||||
@@ -187,7 +185,7 @@ export function ProfileViewer({ onChange, ref }: ProfileViewerProps) {
|
||||
onChange(isActivating);
|
||||
}, 0);
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -263,13 +263,13 @@ export const ProxiesEditorViewer = (props: Props) => {
|
||||
const handleSave = useLockFn(async () => {
|
||||
try {
|
||||
await saveProfileFile(property, currData);
|
||||
showNotice("success", {
|
||||
showNotice.success({
|
||||
i18nKey: "components.profile.notifications.saved",
|
||||
});
|
||||
onSave?.(prevData, currData);
|
||||
onClose();
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.toString()));
|
||||
showNotice.error(createRawNotice(err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -351,8 +351,7 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
),
|
||||
);
|
||||
} catch (e: any) {
|
||||
showNotice(
|
||||
"error",
|
||||
showNotice.error(
|
||||
createRawNotice(e?.message || e?.toString() || "YAML dump error"),
|
||||
);
|
||||
}
|
||||
@@ -482,13 +481,13 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
const handleSave = useLockFn(async () => {
|
||||
try {
|
||||
await saveProfileFile(property, currData);
|
||||
showNotice("success", {
|
||||
showNotice.success({
|
||||
i18nKey: "components.profile.notifications.saved",
|
||||
});
|
||||
onSave?.(prevData, currData);
|
||||
onClose();
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.toString()));
|
||||
showNotice.error(createRawNotice(err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -631,8 +630,7 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
if (prependSeq.includes(raw)) return;
|
||||
setPrependSeq([raw, ...prependSeq]);
|
||||
} catch (err: any) {
|
||||
showNotice(
|
||||
"error",
|
||||
showNotice.error(
|
||||
createRawNotice(err.message || err.toString()),
|
||||
);
|
||||
}
|
||||
@@ -652,8 +650,7 @@ export const RulesEditorViewer = (props: Props) => {
|
||||
if (appendSeq.includes(raw)) return;
|
||||
setAppendSeq([...appendSeq, raw]);
|
||||
} catch (err: any) {
|
||||
showNotice(
|
||||
"error",
|
||||
showNotice.error(
|
||||
createRawNotice(err.message || err.toString()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,13 +66,13 @@ export const ProviderButton = () => {
|
||||
await refreshProxy();
|
||||
await refreshProxyProviders();
|
||||
|
||||
showNotice("success", {
|
||||
showNotice.success({
|
||||
i18nKey: "components.providers.notices.updateSuccess",
|
||||
params: { name },
|
||||
});
|
||||
} catch (err: any) {
|
||||
const message = err?.message || err?.toString?.() || String(err);
|
||||
showNotice("error", {
|
||||
showNotice.error({
|
||||
i18nKey: "components.providers.notices.updateFailed",
|
||||
params: { name, message },
|
||||
});
|
||||
@@ -88,7 +88,7 @@ export const ProviderButton = () => {
|
||||
// 获取所有provider的名称
|
||||
const allProviders = Object.keys(proxyProviders || {});
|
||||
if (allProviders.length === 0) {
|
||||
showNotice("info", {
|
||||
showNotice.info({
|
||||
i18nKey: "components.providers.notices.none",
|
||||
});
|
||||
return;
|
||||
@@ -120,12 +120,12 @@ export const ProviderButton = () => {
|
||||
await refreshProxy();
|
||||
await refreshProxyProviders();
|
||||
|
||||
showNotice("success", {
|
||||
showNotice.success({
|
||||
i18nKey: "components.providers.notices.allUpdated",
|
||||
});
|
||||
} catch (err: any) {
|
||||
const message = err?.message || err?.toString?.() || String(err);
|
||||
showNotice("error", {
|
||||
showNotice.error({
|
||||
i18nKey: "components.providers.notices.genericError",
|
||||
params: { message },
|
||||
});
|
||||
|
||||
@@ -58,13 +58,13 @@ export const ProviderButton = () => {
|
||||
await refreshRules();
|
||||
await refreshRuleProviders();
|
||||
|
||||
showNotice("success", {
|
||||
showNotice.success({
|
||||
i18nKey: "components.notices.providers.updateSuccess",
|
||||
params: { name },
|
||||
});
|
||||
} catch (err: any) {
|
||||
const message = err?.message || err?.toString?.() || String(err);
|
||||
showNotice("error", {
|
||||
showNotice.error({
|
||||
i18nKey: "components.notices.providers.updateFailed",
|
||||
params: { name, message },
|
||||
});
|
||||
@@ -80,7 +80,7 @@ export const ProviderButton = () => {
|
||||
// 获取所有provider的名称
|
||||
const allProviders = Object.keys(ruleProviders || {});
|
||||
if (allProviders.length === 0) {
|
||||
showNotice("info", {
|
||||
showNotice.info({
|
||||
i18nKey: "components.notices.providers.none",
|
||||
});
|
||||
return;
|
||||
@@ -112,12 +112,12 @@ export const ProviderButton = () => {
|
||||
await refreshRules();
|
||||
await refreshRuleProviders();
|
||||
|
||||
showNotice("success", {
|
||||
showNotice.success({
|
||||
i18nKey: "components.notices.providers.allUpdated",
|
||||
});
|
||||
} catch (err: any) {
|
||||
const message = err?.message || err?.toString?.() || String(err);
|
||||
showNotice("error", {
|
||||
showNotice.error({
|
||||
i18nKey: "components.notices.providers.genericError",
|
||||
params: { message },
|
||||
});
|
||||
|
||||
@@ -54,7 +54,7 @@ export function ClashCoreViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
const errorMsg = await changeClashCore(core);
|
||||
|
||||
if (errorMsg) {
|
||||
showNotice("error", createRawNotice(errorMsg));
|
||||
showNotice.error(createRawNotice(errorMsg));
|
||||
setChangingCore(null);
|
||||
return;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ export function ClashCoreViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
}, 500);
|
||||
} catch (err: any) {
|
||||
setChangingCore(null);
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -75,11 +75,11 @@ export function ClashCoreViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
try {
|
||||
setRestarting(true);
|
||||
await restartCore();
|
||||
showNotice("success", { i18nKey: "Clash Core Restarted" });
|
||||
showNotice.success({ i18nKey: "Clash Core Restarted" });
|
||||
setRestarting(false);
|
||||
} catch (err: any) {
|
||||
setRestarting(false);
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -88,14 +88,14 @@ export function ClashCoreViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
setUpgrading(true);
|
||||
await upgradeCore();
|
||||
setUpgrading(false);
|
||||
showNotice("success", { i18nKey: "Core Version Updated" });
|
||||
showNotice.success({ i18nKey: "Core Version Updated" });
|
||||
} catch (err: any) {
|
||||
setUpgrading(false);
|
||||
const errMsg = err.response?.data?.message || err.toString();
|
||||
const showMsg = errMsg.includes("already using latest version")
|
||||
? "Already Using Latest Core Version"
|
||||
: errMsg;
|
||||
showNotice("error", { i18nKey: showMsg, fallback: showMsg });
|
||||
showNotice.error({ i18nKey: showMsg, fallback: showMsg });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ export function ControllerViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
// 如果启用了外部控制器,则保存控制器地址和密钥
|
||||
if (enableController) {
|
||||
if (!controller.trim()) {
|
||||
showNotice("error", {
|
||||
showNotice.error({
|
||||
i18nKey:
|
||||
"components.settings.externalController.messages.addressRequired",
|
||||
});
|
||||
@@ -64,7 +64,7 @@ export function ControllerViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
}
|
||||
|
||||
if (!secret.trim()) {
|
||||
showNotice("error", {
|
||||
showNotice.error({
|
||||
i18nKey:
|
||||
"components.settings.externalController.messages.secretRequired",
|
||||
});
|
||||
@@ -77,12 +77,11 @@ export function ControllerViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
await patchInfo({ "external-controller": "" });
|
||||
}
|
||||
|
||||
showNotice("success", { i18nKey: "Configuration saved successfully" });
|
||||
showNotice.success({ i18nKey: "Configuration saved successfully" });
|
||||
setOpen(false);
|
||||
} catch (err: any) {
|
||||
const message = err?.message || err?.toString?.();
|
||||
showNotice(
|
||||
"error",
|
||||
showNotice.error(
|
||||
message
|
||||
? createPrefixedNotice(t("Failed to save configuration"), message)
|
||||
: { i18nKey: "Failed to save configuration" },
|
||||
@@ -102,7 +101,7 @@ export function ControllerViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
setTimeout(() => setCopySuccess(null));
|
||||
} catch (err) {
|
||||
console.warn("[ControllerViewer] copy to clipboard failed:", err);
|
||||
showNotice("error", {
|
||||
showNotice.error({
|
||||
i18nKey: "components.settings.externalController.messages.copyFailed",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -428,7 +428,7 @@ export function DnsViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
skipYamlSyncRef.current = true;
|
||||
updateValuesFromConfig(parsedYaml);
|
||||
} catch {
|
||||
showNotice("error", { i18nKey: "Invalid YAML format" });
|
||||
showNotice.error({ i18nKey: "Invalid YAML format" });
|
||||
}
|
||||
}, [yamlContent, updateValuesFromConfig]);
|
||||
|
||||
@@ -551,8 +551,7 @@ export function DnsViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
}
|
||||
}
|
||||
|
||||
showNotice(
|
||||
"error",
|
||||
showNotice.error(
|
||||
createPrefixedNotice(
|
||||
`${t("DNS configuration error")}:`,
|
||||
cleanErrorMsg,
|
||||
@@ -568,9 +567,9 @@ export function DnsViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
}
|
||||
|
||||
setOpen(false);
|
||||
showNotice("success", { i18nKey: "DNS settings saved" });
|
||||
showNotice.success({ i18nKey: "DNS settings saved" });
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -140,12 +140,12 @@ export const HeaderConfiguration = forwardRef<ClashHeaderConfigingRef>(
|
||||
manual: true,
|
||||
onSuccess: () => {
|
||||
setOpen(false);
|
||||
showNotice("success", {
|
||||
showNotice.success({
|
||||
i18nKey: "Configuration saved successfully",
|
||||
});
|
||||
},
|
||||
onError: () => {
|
||||
showNotice("error", { i18nKey: "Failed to save configuration" });
|
||||
showNotice.error({ i18nKey: "Failed to save configuration" });
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
@@ -82,7 +82,7 @@ export const HotkeyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
});
|
||||
setOpen(false);
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ export const LayoutViewer = forwardRef<DialogRef>((_, ref) => {
|
||||
|
||||
const onSwitchFormat = (_e: any, value: boolean) => value;
|
||||
const onError = (err: any) => {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
};
|
||||
const onChangeData = (patch: Partial<IVergeConfig>) => {
|
||||
mutateVerge({ ...verge, ...patch }, false);
|
||||
|
||||
@@ -46,7 +46,7 @@ export function LiteModeViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
});
|
||||
setOpen(false);
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ export const MiscViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
});
|
||||
setOpen(false);
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.toString()));
|
||||
showNotice.error(createRawNotice(err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ const AddressDisplay = ({
|
||||
size="small"
|
||||
onClick={async () => {
|
||||
await writeText(content);
|
||||
showNotice("success", { i18nKey: "Copy Success" });
|
||||
showNotice.success({ i18nKey: "Copy Success" });
|
||||
}}
|
||||
>
|
||||
<ContentCopyRounded sx={{ fontSize: "18px" }} />
|
||||
|
||||
@@ -161,7 +161,7 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
]);
|
||||
}
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.toString()));
|
||||
showNotice.error(createRawNotice(err.toString()));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -277,15 +277,13 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
|
||||
const onSave = useLockFn(async () => {
|
||||
if (value.duration < 1) {
|
||||
showNotice(
|
||||
"error",
|
||||
showNotice.error(
|
||||
t("components.settings.sysproxy.messages.durationTooShort"),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (value.bypass && !validReg.test(value.bypass)) {
|
||||
showNotice(
|
||||
"error",
|
||||
showNotice.error(
|
||||
t("components.settings.sysproxy.messages.invalidBypass"),
|
||||
);
|
||||
return;
|
||||
@@ -304,8 +302,7 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
!ipv6Regex.test(value.proxy_host) &&
|
||||
!hostnameRegex.test(value.proxy_host)
|
||||
) {
|
||||
showNotice(
|
||||
"error",
|
||||
showNotice.error(
|
||||
t("components.settings.sysproxy.messages.invalidProxyHost"),
|
||||
);
|
||||
return;
|
||||
@@ -410,7 +407,7 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
} catch (err: any) {
|
||||
console.error("配置保存失败:", err);
|
||||
mutateVerge();
|
||||
showNotice("error", createRawNotice(err.toString()));
|
||||
showNotice.error(createRawNotice(err.toString()));
|
||||
// setOpen(true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@ export function ThemeViewer(props: { ref?: React.Ref<DialogRef> }) {
|
||||
await patchVerge({ theme_setting: theme });
|
||||
setOpen(false);
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.toString()));
|
||||
showNotice.error(createRawNotice(err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -80,15 +80,15 @@ export function TunViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
);
|
||||
try {
|
||||
await enhanceProfiles();
|
||||
showNotice("success", {
|
||||
showNotice.success({
|
||||
i18nKey: "components.settings.tun.messages.applied",
|
||||
});
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
}
|
||||
setOpen(false);
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -58,16 +58,12 @@ export function UpdateViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
|
||||
const onUpdate = useLockFn(async () => {
|
||||
if (portableFlag) {
|
||||
showNotice(
|
||||
"error",
|
||||
t("components.settings.update.messages.portableError"),
|
||||
);
|
||||
showNotice.error(t("components.settings.update.messages.portableError"));
|
||||
return;
|
||||
}
|
||||
if (!updateInfo?.body) return;
|
||||
if (breakChangeFlag) {
|
||||
showNotice(
|
||||
"error",
|
||||
showNotice.error(
|
||||
t("components.settings.update.messages.breakChangeError"),
|
||||
);
|
||||
return;
|
||||
@@ -95,7 +91,7 @@ export function UpdateViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
await updateInfo.downloadAndInstall();
|
||||
await relaunch();
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err?.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err?.message || err.toString()));
|
||||
} finally {
|
||||
setUpdateState(false);
|
||||
if (progressListener) {
|
||||
|
||||
@@ -92,7 +92,7 @@ export function WebUIViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
|
||||
await openWebUrl(url);
|
||||
} catch (e: any) {
|
||||
showNotice("error", createRawNotice(e.message || e.toString()));
|
||||
showNotice.error(createRawNotice(e.message || e.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -67,12 +67,11 @@ const SettingClash = ({ onError }: Props) => {
|
||||
const onUpdateGeo = async () => {
|
||||
try {
|
||||
await updateGeo();
|
||||
showNotice(
|
||||
"success",
|
||||
showNotice.success(
|
||||
t("components.settings.clash.messages.geoDataUpdated"),
|
||||
);
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -89,7 +88,7 @@ const SettingClash = ({ onError }: Props) => {
|
||||
} catch (err: any) {
|
||||
setDnsSettingsEnabled(!enable);
|
||||
localStorage.setItem("dns_settings_enabled", String(!enable));
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
await patchVerge({ enable_dns_settings: !enable }).catch(() => {});
|
||||
throw err;
|
||||
}
|
||||
|
||||
@@ -47,22 +47,20 @@ const SettingVergeAdvanced = ({ onError: _ }: Props) => {
|
||||
try {
|
||||
const info = await checkUpdate();
|
||||
if (!info?.available) {
|
||||
showNotice(
|
||||
"success",
|
||||
showNotice.success(
|
||||
t("components.settings.verge.advanced.notifications.latestVersion"),
|
||||
);
|
||||
} else {
|
||||
updateRef.current?.open();
|
||||
}
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
}
|
||||
};
|
||||
|
||||
const onExportDiagnosticInfo = useCallback(async () => {
|
||||
await exportDiagnosticInfo();
|
||||
showNotice(
|
||||
"success",
|
||||
showNotice.success(
|
||||
t("components.settings.common.notifications.copySuccess"),
|
||||
1000,
|
||||
);
|
||||
@@ -70,8 +68,7 @@ const SettingVergeAdvanced = ({ onError: _ }: Props) => {
|
||||
|
||||
const copyVersion = useCallback(() => {
|
||||
navigator.clipboard.writeText(`v${version}`).then(() => {
|
||||
showNotice(
|
||||
"success",
|
||||
showNotice.success(
|
||||
t("components.settings.verge.advanced.notifications.versionCopied"),
|
||||
1000,
|
||||
);
|
||||
|
||||
@@ -126,7 +126,7 @@ const ProxyControlSwitches = ({
|
||||
const { enable_tun_mode, enable_system_proxy } = verge ?? {};
|
||||
|
||||
const showErrorNotice = useCallback(
|
||||
(msg: string) => showNotice("error", { i18nKey: msg }),
|
||||
(msg: string) => showNotice.error({ i18nKey: msg }),
|
||||
[],
|
||||
);
|
||||
|
||||
@@ -145,10 +145,7 @@ const ProxyControlSwitches = ({
|
||||
await installServiceAndRestartCore();
|
||||
await mutateSystemState();
|
||||
} catch (err) {
|
||||
showNotice(
|
||||
"error",
|
||||
createRawNotice((err as Error).message || String(err)),
|
||||
);
|
||||
showNotice.error(createRawNotice((err as Error).message || String(err)));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -160,10 +157,7 @@ const ProxyControlSwitches = ({
|
||||
await uninstallServiceAndRestartCore();
|
||||
await mutateSystemState();
|
||||
} catch (err) {
|
||||
showNotice(
|
||||
"error",
|
||||
createRawNotice((err as Error).message || String(err)),
|
||||
);
|
||||
showNotice.error(createRawNotice((err as Error).message || String(err)));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ export const TestItem = ({
|
||||
try {
|
||||
removeTest(uid);
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ export const TestViewer = forwardRef<TestViewerRef, Props>((props, ref) => {
|
||||
setLoading(false);
|
||||
setTimeout(() => formIns.reset(), 500);
|
||||
} catch (err: any) {
|
||||
showNotice("error", createRawNotice(err.message || err.toString()));
|
||||
showNotice.error(createRawNotice(err.message || err.toString()));
|
||||
setLoading(false);
|
||||
}
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user