Forráskód Böngészése

feat: 新增App跳转来跳转引导关注公众号文章功能

Young 1 éve
szülő
commit
4db02850f4

BIN
.swc/plugins/v4/200063c2c798457e0f441f309e564fe9e258e1dcb142b8c6a1df1cbb41ae9bd9


+ 7 - 7
config/dev.js

@@ -1,13 +1,13 @@
 module.exports = {
   env: {
-    NODE_ENV: '"development"'
+    NODE_ENV: '"development"',
   },
   defineConstants: {
-    "ENV": '"DEVELOPMENT"',
-    "HOST": '"http://192.168.0.168:810"',
-    // "HOST": '"https://api.bicredit.xin"',
-    "APPID": '"422"'
+    ENV: '"DEVELOPMENT"',
+    // "HOST": '"http://192.168.0.168:810"',
+    HOST: '"https://api.bicredit.xin"',
+    APPID: '"422"',
   },
   mini: {},
-  h5: {}
-}
+  h5: {},
+};

+ 7 - 8
config/prod.js

@@ -1,12 +1,12 @@
 module.exports = {
   env: {
-    NODE_ENV: '"production"'
+    NODE_ENV: '"production"',
   },
   defineConstants: {
-    "ENV": '"PRODUCTION"',
-    // "HOST": '"https://api.bicredit.xin"',
-    "HOST": '"http://192.168.0.168:810"',
-    "APPID": '"422"'
+    ENV: '"PRODUCTION"',
+    HOST: '"https://api.bicredit.xin"',
+    // "HOST": '"http://192.168.0.168:810"',
+    APPID: '"422"',
   },
   mini: {},
   h5: {
@@ -21,7 +21,6 @@ module.exports = {
     //    */
     //   chain.plugin('analyzer')
     //     .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
-
     //   /**
     //    * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
     //    * @docs https://github.com/chrisvfritz/prerender-spa-plugin
@@ -37,5 +36,5 @@ module.exports = {
     //       postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') })
     //     }))
     // }
-  }
-}
+  },
+};

+ 40 - 29
src/app.tsx

@@ -1,5 +1,5 @@
 // import { Component, PropsWithChildren } from 'react'
-import './app.scss'
+import "./app.scss";
 
 // class App extends Component<PropsWithChildren> {
 
@@ -17,41 +17,52 @@ import './app.scss'
 
 // export default App
 
-import { PropsWithChildren } from 'react';
-import { useRequest } from 'ahooks';
-import Taro from '@tarojs/taro';
-import AppContext from './context/appContext';
-import { Provider as ReduxProvider } from 'react-redux';
-import ReduxUtil from './utils/reduxUtil';
-import UserHelper from './helper/userHelper';
+import { PropsWithChildren } from "react";
+import { useRequest } from "ahooks";
+import Taro, { useLaunch } from "@tarojs/taro";
+import AppContext from "./context/appContext";
+import { Provider as ReduxProvider } from "react-redux";
+import ReduxUtil from "./utils/reduxUtil";
+import RouteUtil from "./utils/routeUtil";
+import UserHelper from "./helper/userHelper";
+import { WebView } from "@tarojs/components";
 
-interface IAppProps {
-
-}
+interface IAppProps {}
 
 const App = (props: PropsWithChildren<IAppProps>) => {
   const result = useRequest(Taro.getSystemInfo);
   useRequest(() => {
     return UserHelper.cacheTabMenu();
-  })
+  });
+  useLaunch((options) => {
+    console.log(options);
+    if (options.query.source === "app") {
+      RouteUtil.toWebViewPage({
+        url: "https://mp.weixin.qq.com/s/X0OAslHaFjld6Zf2ifVC5A",
+      });
+    }
+  });
   return (
     // (appContext.systemInfo?.screenHeight || 0) - (appContext.systemInfo?.safeArea?.bottom || 0);
-    <AppContext.Provider value={{
-      systemInfo: result.data,
-      screenSize: {
-        width: result.data?.screenWidth || 0,
-        height: result.data?.screenHeight || 0,
-      },
-      padding: {
-        top: result.data?.safeArea?.top || 0,
-        bottom: (result.data?.screenHeight || 0) - (result.data?.safeArea?.bottom || 0),
-      }
-    }} >
-      <ReduxProvider store={ReduxUtil.store} >
-        {props.children}
-      </ReduxProvider>
+    <AppContext.Provider
+      value={{
+        systemInfo: result.data,
+        screenSize: {
+          width: result.data?.screenWidth || 0,
+          height: result.data?.screenHeight || 0,
+        },
+        padding: {
+          top: result.data?.safeArea?.top || 0,
+          bottom:
+            (result.data?.screenHeight || 0) -
+            (result.data?.safeArea?.bottom || 0),
+        },
+      }}
+    >
+      <WebView src="https://mp.weixin.qq.com/s/X0OAslHaFjld6Zf2ifVC5A"></WebView>
+      <ReduxProvider store={ReduxUtil.store}>{props.children}</ReduxProvider>
     </AppContext.Provider>
-  )
-}
+  );
+};
 
-export default App;
+export default App;