Browse Source

no message

zhejiushizhuce 2 years ago
parent
commit
2631753ca7
4 changed files with 47 additions and 3 deletions
  1. 28 2
      src/layout/Navbar/index.jsx
  2. 0 1
      src/layout/Navbar/styles.module.scss
  3. 3 0
      src/styles/_vars.scss
  4. 16 0
      src/styles/theme.js

+ 28 - 2
src/layout/Navbar/index.jsx

@@ -28,6 +28,7 @@ import {allTopNavs, getRoute, getRouteChain, getUserInfo, isLogin, isLogined} fr
 import LazyImage from "@components/LazyImage";
 import {numFormatter, sleep} from "@utils/helpers";
 import {ROUTE_PATH} from "@constants/routes";
+import {toast} from "react-toastify";
 const i18n=global.i18n;
 
 const StyledToggleGroup= styled(ToggleButtonGroup)`
@@ -247,6 +248,7 @@ const PageHeader = () => {
     const chain=useSelector(getRouteChain(pathname));
     const {isMobile,showHeader,setShowHeader} = useThemeProvider();
     const [showMHeader, setShowMHeader] = useState(true);
+    const isLogin=useSelector(isLogined);
     let lastscroll=0;
 
     const checkNavActive=(lv)=>{
@@ -338,18 +340,35 @@ const PageHeader = () => {
             await l.parent.data.waitForData();
         }
     }
+    const checkInstall=(l)=>{
+        if (isLogin){
+            return false;
+        }
+        if (l.parent.detection.isStandalone()) {
+            return false;
+        }
+        return true;
+    }
     const startListening=async ()=>{
         let l=window.progressier.banners;
         await l.parent.data.waitForData();
         l.data = l.parent.data.params;
         if (!l.reinstallTimer) {
             l.reinstallTimer = setInterval(function() {
-                if (!l.showInstall()) {
-                    return
+                // window.alert(window.progressier["native"].justInstalled)
+                // if (!l.showInstall()) {
+                //     return
+                // }
+                if (!checkInstall(l)){
+                    clearInterval(l.reinstallTimer)
+                    return;
                 }
+                // window.alert("222")
                 if (l.showed) {
+                    clearInterval(l.reinstallTimer)
                     return
                 }
+                // window.alert("3333")
                 l.showed = true;
                 // new window.NewProgressierInstallBanner({
                 //         icon: l.icon(),
@@ -376,6 +395,7 @@ const PageHeader = () => {
         }
     }
     const checkProgressier=async ()=>{
+        // return ;
         if (window.progressier){
             reProgressierInstallBanner();
             // let l=window.progressier.banners;
@@ -407,6 +427,11 @@ const PageHeader = () => {
             }
         }
     }
+    // const testBefore=()=>{
+    //     window.addEventListener("beforeinstallprompt", e => {
+    //         window.alert("beforeinstallprompt")
+    //     });
+    // }
     useEffect(() => {
         // 这里的代码会在组件挂载时执行
         // console.log('Component mounted');
@@ -414,6 +439,7 @@ const PageHeader = () => {
         if (barRef.current) {
             resizeObserver.observe(barRef.current);
         }
+        // testBefore();
         checkProgressier();
         return () => {
             // 可选的清除函数,当组件卸载时执行

+ 0 - 1
src/layout/Navbar/styles.module.scss

@@ -60,7 +60,6 @@
   position: relative;
   z-index: 2;
   width: 100%;
-  //height: auto;
   & .install_banner{
     position: relative !important;
     transition: none !important;

+ 3 - 0
src/styles/_vars.scss

@@ -69,6 +69,9 @@ $width-desktop-big-max:1564px;
     --zindex-drawer:1200;
     --zindex-popup:1300;
     --coin-yellow:#edc349;
+    //--progressierBg
+    --progressierBg:var(--widget) !important;
+    --progressierTxt: var(--text) !important;
 }
 
 //@media screen and (min-width: 414px) {

+ 16 - 0
src/styles/theme.js

@@ -115,5 +115,21 @@ export default createGlobalStyle`
         light: '#FFFFFF',
         dark:'rgba(69,70,80,0.5)'
     })};
+    --progressierElement: ${theme('theme', {
+        light: '#fafafa !important',
+        dark:'#29292e !important'
+    })};
+    --progressierBorderColor: ${theme('theme', {
+        light: '#eaeaea !important',
+        dark:'#313137 !important'
+    })};
+    --progressierHover: ${theme('theme', {
+        light: '#f6f6f6 !important',
+        dark:'#191a1e !important'
+    })};
+    --progressierBackdrop: ${theme('theme', {
+        light: 'rgba(255, 255, 255, 0.90) !important',
+        dark:'rgba(0, 0, 0, 0.90) !important'
+    })};
   }
 `;