jihuaqiang 2 anos atrás
pai
commit
111bf18d88

+ 6 - 0
.env

@@ -1,2 +1,8 @@
 REACT_APP_FETCH_LANDPAGE_API_HOST = https://testapi.denetme.net
 REACT_APP_FETCH_EXTENSION_API_HOST = https://testapi.denetme.net
+REACT_APP_IFRAME_HOST = https://iframe-test.denet.me
+
+
+
+
+<!-- REACT_APP_IFRAME_HOST = http://localhost:3001 -->

+ 11 - 3
android/build.gradle

@@ -8,6 +8,8 @@ buildscript {
         minSdkVersion = 21
         compileSdkVersion = 31
         targetSdkVersion = 31
+        agp_version = '7.1.1'
+        agp_version1 = agp_version
 
         if (System.properties['os.arch'] == "aarch64") {
             // For M1 Users we need to use the NDK 24 which added support for aarch64
@@ -18,11 +20,12 @@ buildscript {
         }
     }
     repositories {
-        google()
+         google()
+//        maven { url 'https://maven.aliyun.com/repository/google' }
         mavenCentral()
     }
     dependencies {
-        classpath("com.android.tools.build:gradle:7.1.1")
+        classpath('com.android.tools.build:gradle:7.2.1')
         classpath("com.facebook.react:react-native-gradle-plugin")
         classpath("de.undercouch:gradle-download-task:5.0.1")
         // NOTE: Do not place your application dependencies here; they belong
@@ -32,6 +35,11 @@ buildscript {
 
 allprojects {
     repositories {
+        google()
+        maven { url 'https://maven.aliyun.com/repository/jcenter' }
+        maven { url 'https://maven.aliyun.com/repository/google' }
+        maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
+        maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
         maven {
             // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
             url("$rootDir/../node_modules/react-native/android")
@@ -47,7 +55,7 @@ allprojects {
                 excludeGroup "com.facebook.react"
             }
         }
-        google()
+//        maven { url 'https://maven.aliyun.com/repository/google' }
         maven { url 'https://www.jitpack.io' }
     }
 }

+ 0 - 1
index.js

@@ -5,6 +5,5 @@
 import { AppRegistry } from 'react-native';
 import App from './App';
 import { name as appName } from './app.json';
-console.log('NODE_ENV ===== ', process.env.NODE_ENV);
 
 AppRegistry.registerComponent(appName, () => App);

+ 2 - 0
ios/Denet.xcodeproj/project.pbxproj

@@ -486,6 +486,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CLANG_ENABLE_MODULES = YES;
 				CURRENT_PROJECT_VERSION = 1;
+				DEVELOPMENT_TEAM = UH52C8A7SN;
 				ENABLE_BITCODE = NO;
 				INFOPLIST_FILE = Denet/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = (
@@ -512,6 +513,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CLANG_ENABLE_MODULES = YES;
 				CURRENT_PROJECT_VERSION = 1;
+				DEVELOPMENT_TEAM = UH52C8A7SN;
 				INFOPLIST_FILE = Denet/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = (
 					"$(inherited)",

+ 11 - 23
ios/Podfile.lock

@@ -286,17 +286,13 @@ PODS:
   - React-jsinspector (0.69.2)
   - React-logger (0.69.2):
     - glog
-  - react-native-cookie (0.3.0):
-    - React
-  - react-native-cookies (6.2.1):
-    - React-Core
-  - react-native-safe-area-context (4.3.1):
+  - react-native-safe-area-context (4.3.3):
     - RCT-Folly
     - RCTRequired
     - RCTTypeSafety
-    - React
+    - React-Core
     - ReactCommon/turbomodule/core
-  - react-native-webview (11.23.0):
+  - react-native-webview (11.23.1):
     - React-Core
   - React-perflogger (0.69.2)
   - React-RCTActionSheet (0.69.2):
@@ -364,12 +360,12 @@ PODS:
     - React-jsi (= 0.69.2)
     - React-logger (= 0.69.2)
     - React-perflogger (= 0.69.2)
-  - RNCAsyncStorage (1.17.9):
+  - RNCAsyncStorage (1.17.10):
     - React-Core
-  - RNScreens (3.15.0):
+  - RNScreens (3.17.0):
     - React-Core
     - React-RCTImage
-  - RNSVG (13.0.0):
+  - RNSVG (13.1.0):
     - React-Core
   - SocketRocket (0.6.0)
   - Yoga (1.14.0)
@@ -421,8 +417,6 @@ DEPENDENCIES:
   - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
   - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
   - React-logger (from `../node_modules/react-native/ReactCommon/logger`)
-  - react-native-cookie (from `../node_modules/react-native-cookie`)
-  - "react-native-cookies (from `../node_modules/@react-native-cookies/cookies`)"
   - react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
   - react-native-webview (from `../node_modules/react-native-webview`)
   - React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`)
@@ -501,10 +495,6 @@ EXTERNAL SOURCES:
     :path: "../node_modules/react-native/ReactCommon/jsinspector"
   React-logger:
     :path: "../node_modules/react-native/ReactCommon/logger"
-  react-native-cookie:
-    :path: "../node_modules/react-native-cookie"
-  react-native-cookies:
-    :path: "../node_modules/@react-native-cookies/cookies"
   react-native-safe-area-context:
     :path: "../node_modules/react-native-safe-area-context"
   react-native-webview:
@@ -576,10 +566,8 @@ SPEC CHECKSUMS:
   React-jsiexecutor: 7c23e92591431ac925f430b3118de934cb816ac0
   React-jsinspector: 31e53f048cc8f32605de36981903a7bbf9456892
   React-logger: 9a6c684d5cd56c4129e0c2842dba75c4bfb1e981
-  react-native-cookie: dfde9cd819c42c538abc19dc476c9c7ac53cb530
-  react-native-cookies: f54fcded06bb0cda05c11d86788020b43528a26c
-  react-native-safe-area-context: 6c12e3859b6f27b25de4fee8201cfb858432d8de
-  react-native-webview: e771bc375f789ebfa02a26939a57dbc6fa897336
+  react-native-safe-area-context: b456e1c40ec86f5593d58b275bd0e9603169daca
+  react-native-webview: d33e2db8925d090871ffeb232dfa50cb3a727581
   React-perflogger: 281c34e42f13245c7a4d6932364d9182f8655e1a
   React-RCTActionSheet: 92f4292754a1b4a0e42bf9b1489206a06f878929
   React-RCTAnimation: 2a5bb5549758e4e594481633f3db649d11519f75
@@ -592,9 +580,9 @@ SPEC CHECKSUMS:
   React-RCTVibration: 0d07f00705b5f11e88aaaaf9131f5e1785d4bd6e
   React-runtimeexecutor: 8030b9cf9b9e87b878d92da680b55b5e74c58e70
   ReactCommon: a9414b91f0d19de002b55d9f4f6cb176d6dd8452
-  RNCAsyncStorage: b2489b49e38c85e10ed45a888d13a2a4c7b32ea1
-  RNScreens: 4a1af06327774490d97342c00aee0c2bafb497b7
-  RNSVG: 42a0c731b11179ebbd27a3eeeafa7201ebb476ff
+  RNCAsyncStorage: 0c357f3156fcb16c8589ede67cc036330b6698ca
+  RNScreens: 0df01424e9e0ed7827200d6ed1087ddd06c493f9
+  RNSVG: 1153e8eeb34c788841016c517dba9f57f20b762f
   SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
   Yoga: 236056dd74cda4d9d76c20306fd8c20bb087614d
   YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

+ 4 - 4
package.json

@@ -3,25 +3,25 @@
   "version": "0.0.1",
   "private": true,
   "scripts": {
-    "android": "react-native run-android",
-    "ios": "react-native run-ios",
+    "android": "DENET_ENV=dev react-native run-android",
+    "ios": "DENET_ENV=dev react-native run-ios",
+    "ios-test": "DENET_ENV=test react-native run-ios",
     "start": "react-native start",
     "test": "jest",
     "lint": "eslint . --ext .js,.jsx,.ts,.tsx"
   },
   "dependencies": {
     "@react-native-async-storage/async-storage": "^1.17.9",
-    "@react-native-cookies/cookies": "^6.2.1",
     "@react-navigation/bottom-tabs": "^6.3.2",
     "@react-navigation/native": "^6.0.11",
     "@react-navigation/native-stack": "^6.7.0",
     "axios": "^0.27.2",
+    "babel-plugin-inline-dotenv": "^1.7.0",
     "babel-plugin-inline-import": "^3.0.0",
     "cross-env": "^7.0.3",
     "react": "18.0.0",
     "react-native": "0.69.2",
     "react-native-animatable": "^1.3.3",
-    "react-native-cookie": "^0.3.0",
     "react-native-dotenv": "^3.3.1",
     "react-native-eventemitter": "^0.0.1",
     "react-native-linear-gradient": "^2.6.2",

+ 3 - 3
src/components/useLogin.tsx

@@ -78,7 +78,7 @@ export const useLoginCom = (props: any) => {
 	useEffect(() => {
 		const getUserInfo = async () => {
 			const user = await getStorageData('userInfo');
-			if (user.accessToken) {
+			if (user?.accessToken) {
 				setUserInfo(user);
 				setIsLogin(true);
 			}
@@ -89,10 +89,10 @@ export const useLoginCom = (props: any) => {
 	useEffect(() => {
 		const unsubscribe = props.navigation.addListener('focus', async () => {
 			const user = await getStorageData('userInfo');
-			if (user.verifier) {
+			if (user?.verifier) {
 				setIsLogin(false);
 				twitterLogin(user.verifier);
-			} else if (user.accessToken) {
+			} else if (user?.accessToken) {
 				setUserInfo(user);
 				setIsLogin(true);
 			} else {

+ 20 - 1
src/components/webview.tsx

@@ -3,6 +3,8 @@
  */
 import React from 'react';
 import { WebView } from 'react-native-webview';
+import { getStorageData } from '@/storage/';
+import { getMid } from '@/utils/';
 
 interface Props {
 	uri: any;
@@ -13,6 +15,23 @@ interface Props {
 	style?: any;
 }
 export const DenetWebview = (props: Props) => {
+	const innerRefHandle = async (r: any) => {
+		const mid = await getMid();
+		const userInfo = await getStorageData('userInfo');
+		if (props.refHandle) {
+			props.refHandle(r);
+		}
+		if (mid && userInfo && r) {
+			r.injectJavaScript(`
+			window.denetData = ${JSON.stringify({
+				mid,
+				userInfo,
+			})};
+		  true;
+		`);
+		}
+	};
+
 	return (
 		<WebView
 			applicationNameForUserAgent={'denet/1.1.0'}
@@ -26,7 +45,7 @@ export const DenetWebview = (props: Props) => {
 			allowUniversalAccessFromFileURLs={true}
 			allowFileAccessFromFileURLs={true}
 			onLoadEnd={props.onLoadEndHandle}
-			ref={props.refHandle}
+			ref={r => innerRefHandle(r)}
 			onMessage={props.onMessageHandle}
 			onNavigationStateChange={props.handleWebViewNavigationStateChange}
 			style={props.style}

+ 2 - 1
src/pages/navigations/NFTs.tsx

@@ -3,6 +3,7 @@ import { LoginView } from '@/components/loginView';
 import { DenetWebview } from '@/components/webview';
 import { useLoginCom } from '@/components/useLogin';
 import messageCenter from '@/utils/messageCenter';
+import { REACT_APP_IFRAME_HOST } from '@env';
 
 interface Props {
     navigation: any;
@@ -32,7 +33,7 @@ const NFTs = (props: Props) => {
             <DenetWebview
                 onMessageHandle={onMessage}
                 refHandle={r => (webref = r)}
-                uri="http://localhost:3000/nav-nft-index">
+                uri={`${REACT_APP_IFRAME_HOST}/nav-nft-index`}>
             </DenetWebview>
         );
     }

+ 27 - 29
src/pages/navigations/message.tsx

@@ -3,45 +3,43 @@ import { LoginView } from '@/components/loginView';
 import { DenetWebview } from '@/components/webview';
 import { useLoginCom } from '@/components/useLogin';
 import messageCenter from '@/utils/messageCenter';
-
+import { REACT_APP_IFRAME_HOST } from '@env';
 interface Props {
-    navigation: any;
+	navigation: any;
 }
 
 let webref: any;
 let webprops: any;
 
 const onMessage = async (event: any) => {
-    let { info, data } = (event.nativeEvent.data && JSON.parse(event.nativeEvent.data)) || {};
-    switch (info.actionType) {
-        case 'IFRAME_GET_EXTENSION_STORGE_DATA':
-            info.target = webref;
-            messageCenter.send({ info, data });
-            break;
-        case 'IFRAME_MESSAGE_PAGE_CREATE_TAB':
-            webprops.navigation.navigate('WebView', data);
-            break;
-    }
-}
+	let { info, data } =
+		(event.nativeEvent.data && JSON.parse(event.nativeEvent.data)) || {};
+	switch (info.actionType) {
+		case 'IFRAME_GET_EXTENSION_STORGE_DATA':
+			info.target = webref;
+			messageCenter.send({ info, data });
+			break;
+		case 'IFRAME_MESSAGE_PAGE_CREATE_TAB':
+			webprops.navigation.navigate('WebView', data);
+			break;
+	}
+};
 
 const Message = (props: Props) => {
-    const { isLogin, goTwitterAuthorize } = useLoginCom(props);
-    // global
-    webprops = props;
+	const { isLogin, goTwitterAuthorize } = useLoginCom(props);
+	// global
+	webprops = props;
 
-    if (isLogin === false) {
-        return (
-            <LoginView goLogin={goTwitterAuthorize}></LoginView>
-        );
-    } else {
-        return (
-            <DenetWebview
-                onMessageHandle={onMessage}
-                refHandle={r => (webref = r)}
-                uri="http://localhost:3000/nav-message">
-            </DenetWebview>
-        );
-    }
+	if (isLogin === false) {
+		return <LoginView goLogin={goTwitterAuthorize}></LoginView>;
+	} else {
+		return (
+			<DenetWebview
+				onMessageHandle={onMessage}
+				refHandle={r => (webref = r)}
+				uri={`${REACT_APP_IFRAME_HOST}/nav-message`}></DenetWebview>
+		);
+	}
 };
 
 export default Message;

+ 22 - 22
src/pages/navigations/wallet.tsx

@@ -3,39 +3,39 @@ import { LoginView } from '@/components/loginView';
 import { DenetWebview } from '@/components/webview';
 import { useLoginCom } from '@/components/useLogin';
 import messageCenter from '@/utils/messageCenter';
+import { REACT_APP_IFRAME_HOST } from '@env';
 
 interface Props {
-    navigation: any;
+	navigation: any;
 }
 
 let webref: any;
 
 const onMessage = async (event: any) => {
-    let { info, data } = (event.nativeEvent.data && JSON.parse(event.nativeEvent.data)) || {};
-    switch (info.actionType) {
-        case 'IFRAME_GET_EXTENSION_STORGE_DATA':
-            info.target = webref;
-            messageCenter.send({ info, data });
-            break;
-    }
-}
+	let { info, data } =
+		(event.nativeEvent.data && JSON.parse(event.nativeEvent.data)) || {};
+	switch (info.actionType) {
+		case 'IFRAME_GET_EXTENSION_STORGE_DATA':
+			info.target = webref;
+			messageCenter.send({ info, data });
+			break;
+	}
+};
 
 const Wallet = (props: Props) => {
 	const { isLogin, goTwitterAuthorize } = useLoginCom(props);
 
-    if (isLogin === false) {
-        return (
-            <LoginView goLogin={goTwitterAuthorize}></LoginView>
-        );
-    } else {
-        return (
-            <DenetWebview
-                onMessageHandle={onMessage}
-                refHandle={r => (webref = r)}
-                uri="http://localhost:3000/nav-wallet-index">
-            </DenetWebview>
-        );
-    }
+	if (isLogin === false) {
+		return <LoginView goLogin={goTwitterAuthorize}></LoginView>;
+	} else {
+		return (
+			<DenetWebview
+				onMessageHandle={onMessage}
+				refHandle={r => (webref = r)}
+				uri={`${REACT_APP_IFRAME_HOST}/nav-wallet-index`}
+			/>
+		);
+	}
 };
 
 export default Wallet;

+ 2 - 1
src/pages/screens/redpack.tsx

@@ -11,6 +11,7 @@ import {
 import { DenetWebview } from '@/components/webview';
 import { guid } from '@/utils/';
 import messageCenter from '@/utils/messageCenter';
+import { REACT_APP_IFRAME_HOST } from '@env';
 import {
 	Modal,
 	BottomModal,
@@ -108,7 +109,7 @@ class Redpack extends Component<Props, State> {
 					refHandle={r => (this.webref = r)}
 					onMessageHandle={this.onMessageHandle}
 					handleWebViewNavigationStateChange={() => {}}
-					uri={`http://localhost:3001/red-pack?postId=${post_Id}&tweetId=${tweet_Id}&tweet_author=&window_origin=https://twitter.com&page_type=${page_type}&iframeId=${iframe_id}&appVersionCode=22`}
+					uri={`${REACT_APP_IFRAME_HOST}/red-pack?postId=${post_Id}&tweetId=${tweet_Id}&tweet_author=&window_origin=https://twitter.com&page_type=${page_type}&iframeId=${iframe_id}&appVersionCode=22`}
 				/>
 
 				<BottomModal

+ 23 - 23
src/utils/cookie.ts

@@ -1,26 +1,26 @@
-import CookieManager from '@react-native-cookies/cookies';
+// import CookieManager from '@react-native-cookies/cookies';
 
-const TOP_LEVEL_DOMAIN = 'https://denetme.net';
+// const TOP_LEVEL_DOMAIN = 'https://denetme.net';
 
-export const setCookie = (key: any, value: any, options?: any) => {
-	return CookieManager.set(TOP_LEVEL_DOMAIN, {
-		name: key,
-		value,
-		domain: options?.domain,
-		path: options?.path,
-		version: options?.version,
-		expires: options?.expires,
-	});
-};
+// export const setCookie = (key: any, value: any, options?: any) => {
+// 	return CookieManager.set(TOP_LEVEL_DOMAIN, {
+// 		name: key,
+// 		value,
+// 		domain: options?.domain,
+// 		path: options?.path,
+// 		version: options?.version,
+// 		expires: options?.expires,
+// 	});
+// };
 
-export const getCookie = (key: any) => {
-	return new Promise(res => {
-		CookieManager.get(TOP_LEVEL_DOMAIN).then((data: any) => {
-			if (data && data[key]) {
-				res(data[key].value);
-			} else {
-				res(null);
-			}
-		});
-	});
-};
+// export const getCookie = (key: any) => {
+// 	return new Promise(res => {
+// 		CookieManager.get(TOP_LEVEL_DOMAIN).then((data: any) => {
+// 			if (data && data[key]) {
+// 				res(data[key].value);
+// 			} else {
+// 				res(null);
+// 			}
+// 		});
+// 	});
+// };

+ 4 - 3
src/utils/index.ts

@@ -1,4 +1,5 @@
-import { setCookie, getCookie } from './cookie';
+// import { setCookie, getCookie } from './cookie';
+import { getStorageData, setStorageData } from '@/storage/index';
 
 export const APPTYPE = 3;
 
@@ -17,13 +18,13 @@ export const guid = () => {
 // 获取mid
 export const getMid = async () => {
 	let _mid;
-	let _cookie_mid = await getCookie('mid');
+	let _cookie_mid = await getStorageData('mid');
 	if (_cookie_mid) {
 		_mid = _cookie_mid;
 	} else {
 		_mid = guid();
 		console.log('_mid', _mid);
-		await setCookie('mid', _mid);
+		await setStorageData('mid', _mid);
 	}
 	return _mid;
 };

+ 1 - 0
tsconfig.json

@@ -2,6 +2,7 @@
 {
   "extends": "@tsconfig/react-native/tsconfig.json",     /* Recommended React Native TSConfig base */
   "compilerOptions": {
+	"jsx": "react",
     /* Visit https://aka.ms/tsconfig.json to read more about this file */
 
     /* Completeness */

Diferenças do arquivo suprimidas por serem muito extensas
+ 299 - 298
yarn.lock


Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff