|
@@ -5,10 +5,11 @@ import { useSystemStore } from "@/stores/useSystemStore";
|
|
|
import { ConfigProvider } from "antd-mobile";
|
|
|
import enUS from "antd-mobile/es/locales/en-US";
|
|
|
import { ThemeProviderProps } from "next-themes/dist/types";
|
|
|
-import { ReactNode, useLayoutEffect, useRef } from "react";
|
|
|
+import { ReactNode, useRef } from "react";
|
|
|
import { Swiper, SwiperClass, SwiperSlide } from "swiper/react";
|
|
|
|
|
|
-import { setHtmlFontSize } from "@/utils";
|
|
|
+import { getShareApi } from "@/api/config";
|
|
|
+import { setupFontSize } from "@/utils";
|
|
|
import { useDebounceEffect } from "ahooks";
|
|
|
import { initializeApp } from "firebase/app";
|
|
|
import { getMessaging, getToken, onMessage } from "firebase/messaging";
|
|
@@ -16,26 +17,12 @@ export interface ProvidersProps {
|
|
|
children: ReactNode;
|
|
|
themeProps?: Omit<ThemeProviderProps, "children">;
|
|
|
}
|
|
|
-
|
|
|
+// 初始化 fireBase
|
|
|
const initFirebase = () => {
|
|
|
// 是否是https
|
|
|
if (document.location.protocol.indexOf("https") === -1) return;
|
|
|
// 浏览器是否支持 且是 pwa
|
|
|
if (!window.Notification) {
|
|
|
- // Dialog.alert({
|
|
|
- // getContainer: null,
|
|
|
- // bodyStyle: { background: "#fff" },
|
|
|
- // title: "提示",
|
|
|
- // confirmText: "我知道了",
|
|
|
- // content: (
|
|
|
- // <>
|
|
|
- // <div className={"text-center"}>
|
|
|
- // <p>当前版本浏览器不支持通知</p>
|
|
|
- // <p>请更换或升级浏览器获得更好使用体验</p>
|
|
|
- // </div>
|
|
|
- // </>
|
|
|
- // ),
|
|
|
- // });
|
|
|
return;
|
|
|
}
|
|
|
// 是否开启通知
|
|
@@ -96,11 +83,6 @@ const Layout = ({ children, themeProps }: ProvidersProps) => {
|
|
|
setCollapse(false);
|
|
|
};
|
|
|
|
|
|
- useLayoutEffect(() => {
|
|
|
- // 调用响应式方法
|
|
|
- setHtmlFontSize();
|
|
|
- }, []);
|
|
|
-
|
|
|
return (
|
|
|
<div id="app" className="bg-black">
|
|
|
<Swiper
|
|
@@ -138,11 +120,22 @@ const Layout = ({ children, themeProps }: ProvidersProps) => {
|
|
|
</div>
|
|
|
);
|
|
|
};
|
|
|
+
|
|
|
export const Providers = ({ children, themeProps }: ProvidersProps) => {
|
|
|
+ const setupConfig = useSystemStore((state) => state.setupConfig);
|
|
|
+
|
|
|
useDebounceEffect(() => {
|
|
|
if ("serviceWorker" in navigator) {
|
|
|
initFirebase();
|
|
|
}
|
|
|
+
|
|
|
+ // 初始化配置
|
|
|
+ setupConfig();
|
|
|
+ // 初始化字体
|
|
|
+ setupFontSize();
|
|
|
+ // 初始化参数地址
|
|
|
+
|
|
|
+ getShareApi({ channel_url: window.location.href });
|
|
|
}, []);
|
|
|
|
|
|
return (
|