فهرست منبع

Install prompt

zhejiushizhuce 2 سال پیش
والد
کامیت
41a1dd5623
4فایلهای تغییر یافته به همراه29 افزوده شده و 3 حذف شده
  1. 18 2
      src/App.js
  2. 8 1
      src/features/mainSlice.js
  3. 2 0
      src/styles/_global.scss
  4. 1 0
      src/styles/_vars.scss

+ 18 - 2
src/App.js

@@ -44,7 +44,7 @@ import Layout from "@layout/Layout";
 import {
 import {
     getBFP,
     getBFP,
     getFetchStatus,
     getFetchStatus,
-    getHallServerUrl, getKickState,
+    getHallServerUrl, getKickState, getPromoteInstall,
     getUserID,
     getUserID,
     getUserInfo,
     getUserInfo,
     isLogined,
     isLogined,
@@ -96,6 +96,7 @@ const App = () => {
     useGlobalClick();
     useGlobalClick();
     const {preLocation,gameID}=usePreviousRoute();
     const {preLocation,gameID}=usePreviousRoute();
     const serverKick=useSelector(getKickState);
     const serverKick=useSelector(getKickState);
+    const promoteInstall=useSelector(getPromoteInstall);
     const muiTheme = createTheme({
     const muiTheme = createTheme({
         direction: direction,
         direction: direction,
     });
     });
@@ -253,7 +254,9 @@ const App = () => {
             if (pathname){
             if (pathname){
                 if (pathname.startsWith(ROUTE_PATH.GAME)){
                 if (pathname.startsWith(ROUTE_PATH.GAME)){
                     //更新金币
                     //更新金币
-                    dispatch(reqGameInfo());
+                    if (userID>0){
+                        dispatch(reqGameInfo());
+                    }
                 }
                 }
             }
             }
         }
         }
@@ -271,6 +274,19 @@ const App = () => {
             }
             }
         }
         }
     },[serverKick])
     },[serverKick])
+    //监听安装提示
+    useEffect(()=>{
+        if (promoteInstall>0){
+            if (global.installed===1)return;
+            global.installed=1;
+            let time=promoteInstall*1000;
+            setTimeout(async ()=>{
+                if (window.progressier==null)return ;
+                if (window.progressier.detection.isStandalone())return;
+                window.progressier.flow.init("install",true)
+            },time);
+        }
+    },[promoteInstall])
     //app Effect
     //app Effect
 
 
     const renderLayout=()=>{
     const renderLayout=()=>{

+ 8 - 1
src/features/mainSlice.js

@@ -176,6 +176,7 @@ const reducerRoutes=(state,action)=>{
         }
         }
         let conf=json.conf;
         let conf=json.conf;
         let hallServerUrl='';
         let hallServerUrl='';
+        let promoteInstall=0;
         if (conf){
         if (conf){
             if (!!conf.hall)hallServerUrl=conf.hall;
             if (!!conf.hall)hallServerUrl=conf.hall;
             if (!!conf.DOLLAR)global.DOLLAR=conf.DOLLAR;
             if (!!conf.DOLLAR)global.DOLLAR=conf.DOLLAR;
@@ -185,10 +186,12 @@ const reducerRoutes=(state,action)=>{
                 let {type,id}=conf.pf;
                 let {type,id}=conf.pf;
                 initTrackAll(type,id,isLogin?userInfo.UserID:null)
                 initTrackAll(type,id,isLogin?userInfo.UserID:null)
             }
             }
+            //promoteInstall
+            if (!!conf.promoteInstall)promoteInstall=conf.promoteInstall;
         }
         }
         //favorites
         //favorites
         // let favorites=getFavorites(json.favorites);
         // let favorites=getFavorites(json.favorites);
-        Object.assign(state, {routes:state.routes,asyncRoutes:data,styles:styles,blocks:blocks,...generData,isLogin:isLogin,userInfo:userInfo,hallServerUrl:hallServerUrl});
+        Object.assign(state, {routes:state.routes,asyncRoutes:data,styles:styles,blocks:blocks,...generData,isLogin:isLogin,userInfo:userInfo,hallServerUrl:hallServerUrl,promoteInstall:promoteInstall});
     }
     }
 }
 }
 const routesStatus=(state,status,arg)=>{
 const routesStatus=(state,status,arg)=>{
@@ -415,6 +418,7 @@ export const Main=createSlice({
         favorites:[],
         favorites:[],
         gameID:0,
         gameID:0,
         serverKick:0,
         serverKick:0,
+        promoteInstall:0
     },
     },
     reducers: {
     reducers: {
         logout:(state, action)=>{
         logout:(state, action)=>{
@@ -653,6 +657,9 @@ export const getGameLike=(id)=>(state)=>{
 export const getKickState=(state)=>{
 export const getKickState=(state)=>{
     return state.main.serverKick;
     return state.main.serverKick;
 }
 }
+export const getPromoteInstall=(state)=>{
+    return state.main.promoteInstall;
+}
 //数据获取
 //数据获取
 export default Main.reducer;
 export default Main.reducer;
 
 

+ 2 - 0
src/styles/_global.scss

@@ -228,3 +228,5 @@ input, input::placeholder {
     width: 100vw;
     width: 100vw;
     height: 100vh;
     height: 100vh;
 }
 }
+body.progressier-blurring > *:not(.no-blurring){-webkit-filter:none !important;filter: none !important;pointer-events:none;z-index: 888 !important;}
+

+ 1 - 0
src/styles/_vars.scss

@@ -73,6 +73,7 @@ $width-desktop-big-max:1564px;
     //--progressierBg
     //--progressierBg
     --progressierBg:var(--widget) !important;
     --progressierBg:var(--widget) !important;
     --progressierTxt: var(--text) !important;
     --progressierTxt: var(--text) !important;
+    --progressierBackdrop: rgba(0,0,0,0.40) !important;
 }
 }
 
 
 //@media screen and (min-width: 414px) {
 //@media screen and (min-width: 414px) {