fix: 调用不存在接口导致404

This commit is contained in:
haorwen
2026-01-18 23:01:55 +08:00
parent 1b1645846f
commit 759e231406
3 changed files with 31 additions and 6 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "vocechat-web",
"version": "0.9.52",
"version": "0.9.53",
"homepage": "https://voce.chat",
"dependencies": {
"@metamask/onboarding": "^1.0.1",
@@ -1,22 +1,35 @@
import { useState } from "react";
import { useState, useMemo } from "react";
import toast from "react-hot-toast";
import { useTranslation } from "react-i18next";
import { shallowEqual } from "react-redux";
import {
useGetEnabledChannelTypesQuery,
useToggleChannelTypeMutation,
useDeleteChannelTypeMutation,
} from "@/app/services/notification";
import { useAppSelector } from "@/app/store";
import { ConfigTip } from "@/components/ConfigTip";
import Button from "@/components/styled/Button";
import Toggle from "@/components/styled/Toggle";
import { EnabledChannelType, ChannelType } from "@/types/notification";
import { channelSchemas } from "./channelSchemas";
import ServerVersionChecker from "@/components/ServerVersionChecker";
import { compareVersion } from "@/utils";
export default function AdminNotificationChannels() {
const { t } = useTranslation("setting", { keyPrefix: "admin_notification_channels" });
const { data: channelTypes = [], isLoading } = useGetEnabledChannelTypesQuery();
// Check version first
const currentVersion = useAppSelector((store) => store.server.version, shallowEqual);
const isVersionSupported = useMemo(() => {
return currentVersion && compareVersion(currentVersion, "0.5.11") >= 0;
}, [currentVersion]);
// Fetch data only if version is supported
const { data: channelTypes = [], isLoading } = useGetEnabledChannelTypesQuery(undefined, {
skip: !isVersionSupported,
});
const [toggleChannelType] = useToggleChannelTypeMutation();
const [deleteChannelType] = useDeleteChannelTypeMutation();
+15 -3
View File
@@ -23,6 +23,8 @@ import Toggle from "@/components/styled/Toggle";
import { UserNotificationChannel, ChannelType, CreateUserChannelDTO } from "@/types/notification";
import { getChannelSchema } from "./AdminNotificationChannels/channelSchemas";
import ServerVersionChecker from "@/components/ServerVersionChecker";
import { compareVersion } from "@/utils";
import { useMemo } from "react";
export default function NotificationSettings() {
const { t } = useTranslation("setting", { keyPrefix: "notification" });
@@ -30,9 +32,19 @@ export default function NotificationSettings() {
const [creatingType, setCreatingType] = useState<ChannelType | null>(null);
const [formData, setFormData] = useState<Partial<CreateUserChannelDTO>>({});
// Fetch data
const { data: availableTypes = [], isLoading: typesLoading } = useGetAvailableChannelTypesQuery();
const { data: userChannels = [], isLoading: channelsLoading } = useGetUserChannelsQuery();
// Check version first
const currentVersion = useAppSelector((store) => store.server.version, shallowEqual);
const isVersionSupported = useMemo(() => {
return currentVersion && compareVersion(currentVersion, "0.5.11") >= 0;
}, [currentVersion]);
// Fetch data only if version is supported
const { data: availableTypes = [], isLoading: typesLoading } = useGetAvailableChannelTypesQuery(undefined, {
skip: !isVersionSupported,
});
const { data: userChannels = [], isLoading: channelsLoading } = useGetUserChannelsQuery(undefined, {
skip: !isVersionSupported,
});
const channels = useAppSelector((store) => Object.values(store.channels.byId), shallowEqual);
// Mutations