|
@@ -3,7 +3,7 @@ import { useSystemStore } from "@/stores/useSystemStore";
|
|
|
import { Button, Popup } from "antd-mobile";
|
|
|
import { useTranslations } from "next-intl";
|
|
|
import Image from "next/image";
|
|
|
-import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
|
|
|
+import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
|
|
|
|
/**
|
|
|
* @description 检测pwa是否下载
|
|
@@ -14,17 +14,21 @@ export interface DesktopRefProps {
|
|
|
onOpen: () => void;
|
|
|
onClose: () => void;
|
|
|
}
|
|
|
-interface Props {}
|
|
|
+interface Props {
|
|
|
+ source?: "page" | "components";
|
|
|
+}
|
|
|
const Desktop = forwardRef<DesktopRefProps, Props>(function Desktop(props, ref) {
|
|
|
const prompt = useRef<Event | null>(null);
|
|
|
+ const { source = "page" } = props;
|
|
|
|
|
|
const t = useTranslations("HomePage");
|
|
|
- const { isHasDesktop, setHasDesktop } = useSystemStore((state) => {
|
|
|
- return {
|
|
|
- isHasDesktop: state.isHasDesktop,
|
|
|
- setHasDesktop: state.setHasDesktop,
|
|
|
- };
|
|
|
- });
|
|
|
+ // const { isHasDesktop, setHasDesktop } = useSystemStore((state) => {
|
|
|
+ // return {
|
|
|
+ // isHasDesktop: state.isHasDesktop,
|
|
|
+ // setHasDesktop: state.setHasDesktop,
|
|
|
+ // };
|
|
|
+ // });
|
|
|
+ const [isHasDesktop, setHasDesktop] = useState(false);
|
|
|
const downloadHandler = () => {
|
|
|
// @ts-ignore
|
|
|
prompt.current?.prompt();
|
|
@@ -33,6 +37,8 @@ const Desktop = forwardRef<DesktopRefProps, Props>(function Desktop(props, ref)
|
|
|
};
|
|
|
|
|
|
const initDesktop = (e: Event) => {
|
|
|
+ console.log(`🚀🚀🚀🚀🚀-> in Desktop.tsx on 40`, source);
|
|
|
+ if (source === "components") return;
|
|
|
if (window.matchMedia("(display-mode: standalone)").matches) {
|
|
|
setHasDesktop(false);
|
|
|
return;
|
|
@@ -66,7 +72,7 @@ const Desktop = forwardRef<DesktopRefProps, Props>(function Desktop(props, ref)
|
|
|
return (
|
|
|
<Popup
|
|
|
visible={!!isHasDesktop}
|
|
|
- getContainer={null}
|
|
|
+ getContainer={document.getElementById("app")}
|
|
|
bodyStyle={{ padding: "0.2rem", background: "#fff" }}
|
|
|
>
|
|
|
<div className={"flex text-[0.12rem] text-[#8d8d8d]"}>
|