refactor: remove check ip API
This commit is contained in:
@@ -32,7 +32,6 @@ const whiteList = [
|
||||
];
|
||||
const whiteList401 = ["getAgoraVoicingList", "getAgoraChannels"];
|
||||
const errorWhiteList = [
|
||||
"getIfInChina",
|
||||
"preCheckFileFromUrl",
|
||||
"getFavoriteDetails",
|
||||
"getOGInfo",
|
||||
|
||||
@@ -65,29 +65,6 @@ export const serverApi = createApi({
|
||||
responseHandler: "text"
|
||||
})
|
||||
}),
|
||||
getIfInChina: builder.query<boolean, void>({
|
||||
query: () => ({
|
||||
url: `https://cf-props.ihacker.dev`
|
||||
}),
|
||||
transformResponse: (resp: IPData) => {
|
||||
if (!("error" in resp)) {
|
||||
return resp.country.toUpperCase() == "CN";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// async onQueryStarted(data, { dispatch, queryFulfilled }) {
|
||||
// try {
|
||||
// const {data:{status}} = await queryFulfilled;
|
||||
// if(status=="success"){
|
||||
|
||||
// }
|
||||
// localStorage.setItem(KEY_SERVER_VERSION, resp.data);
|
||||
// dispatch(updateInfo({ version: resp.data }));
|
||||
// } catch {
|
||||
// console.error("get server version error");
|
||||
// }
|
||||
// }
|
||||
}),
|
||||
getServerVersion: builder.query<string, void>({
|
||||
query: () => ({
|
||||
headers: {
|
||||
@@ -508,6 +485,5 @@ export const {
|
||||
useLazyGetAgoraUsersByChannelQuery,
|
||||
useLazyClearAllFilesQuery,
|
||||
useLazyClearAllMessagesQuery,
|
||||
useLazyGetFilesQuery,
|
||||
useGetIfInChinaQuery
|
||||
useLazyGetFilesQuery
|
||||
} = serverApi;
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
import { FC, useEffect } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
// import { KEY_SET_EMAIL_MSG_TIP } from "@/app/config";
|
||||
import Button from "./styled/Button";
|
||||
import { useGetIfInChinaQuery } from "@/app/services/server";
|
||||
import { useAppSelector } from "@/app/store";
|
||||
|
||||
interface ContainerProps {
|
||||
id: string;
|
||||
}
|
||||
const Container = (props: ContainerProps) => {
|
||||
const { id } = props;
|
||||
const { t } = useTranslation();
|
||||
const handleUpgrade = () => {
|
||||
// localStorage.removeItem(KEY_SET_EMAIL_MSG_TIP);
|
||||
toast.dismiss(id);
|
||||
location.href = "/#/setting/license";
|
||||
};
|
||||
const handleClose = () => {
|
||||
// localStorage.removeItem(KEY_SET_EMAIL_MSG_TIP);
|
||||
toast.dismiss(id);
|
||||
};
|
||||
return (
|
||||
<div className="flex flex-col md:flex-row items-center gap-2 whitespace-nowrap">
|
||||
<div>{t("tip.email_msg_tip")}</div>
|
||||
<div className="flex gap-1">
|
||||
<Button className="mini main" onClick={handleUpgrade}>
|
||||
{t("action.upgrade")}
|
||||
</Button>
|
||||
<Button className="mini cancel" onClick={handleClose}>
|
||||
{t("action.dismiss")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
// 免费用户,admin,特定版本,在国内,提醒
|
||||
interface Props {}
|
||||
const Index: FC<Props> = () => {
|
||||
const isAdmin = useAppSelector((store) => store.authData.user?.is_admin);
|
||||
const isUpgraded = useAppSelector((store) => store.server.upgraded);
|
||||
const { data: isInChina } = useGetIfInChinaQuery();
|
||||
// const [visible, setVisible] = useState(false);
|
||||
// useEffect(() => {
|
||||
// setVisible(!!localStorage.getItem(KEY_SET_EMAIL_MSG_TIP));
|
||||
// }, []);
|
||||
const showToast = isAdmin && isInChina && !isUpgraded;
|
||||
useEffect(() => {
|
||||
if (showToast) {
|
||||
toast((t) => <Container id={t.id} />, {
|
||||
duration: Infinity,
|
||||
position: "top-right"
|
||||
});
|
||||
}
|
||||
}, [showToast]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export default Index;
|
||||
@@ -16,7 +16,6 @@ import InvitePrivate from "./invitePrivate";
|
||||
import LazyIt from "./lazy";
|
||||
import InviteInMobile from "./reg/InviteInMobile";
|
||||
import usePrefetchData from "@/hooks/usePrefetchData";
|
||||
import SetEmailMsgTip from "@/components/SetEmailMsgTip";
|
||||
import ServerVersionChecker from "@/components/ServerVersionChecker";
|
||||
|
||||
const RegBasePage = lazy(() => import("./reg"));
|
||||
@@ -297,9 +296,6 @@ function ReduxRoutes() {
|
||||
<Provider store={store}>
|
||||
<Meta />
|
||||
<PageRoutes />
|
||||
<ServerVersionChecker empty version="2.0.0">
|
||||
<SetEmailMsgTip />
|
||||
</ServerVersionChecker>
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user