mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-19 15:30:40 +08:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d666e8c0f3 | ||
![]() |
5e89fb4a25 | ||
![]() |
ab01b6010a | ||
![]() |
92bc830d98 |
@@ -94,7 +94,7 @@ apply from: "../../node_modules/react-native/react.gradle"
|
|||||||
* Upload all the APKs to the Play Store and people will download
|
* Upload all the APKs to the Play Store and people will download
|
||||||
* the correct one based on the CPU architecture of their device.
|
* the correct one based on the CPU architecture of their device.
|
||||||
*/
|
*/
|
||||||
def enableSeparateBuildPerCPUArchitecture = false
|
def enableSeparateBuildPerCPUArchitecture = true
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run Proguard to shrink the Java bytecode in release builds.
|
* Run Proguard to shrink the Java bytecode in release builds.
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
"react-native-camera-kit": "^14.0.0-beta15",
|
"react-native-camera-kit": "^14.0.0-beta15",
|
||||||
"react-native-paper": "^5.12.1",
|
"react-native-paper": "^5.12.1",
|
||||||
"react-native-safe-area-context": "^4.8.2",
|
"react-native-safe-area-context": "^4.8.2",
|
||||||
"react-native-update": "^10.11.2",
|
"react-native-update": "^10.11.3",
|
||||||
"react-native-vector-icons": "^10.0.3"
|
"react-native-vector-icons": "^10.0.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable react/no-unstable-nested-components */
|
/* eslint-disable react/no-unstable-nested-components */
|
||||||
/* eslint-disable react-native/no-inline-styles */
|
/* eslint-disable react-native/no-inline-styles */
|
||||||
import React, {useState} from 'react';
|
import React, {useRef, useState} from 'react';
|
||||||
import {
|
import {
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Platform,
|
Platform,
|
||||||
@@ -47,6 +47,7 @@ function App() {
|
|||||||
const snackbarVisible =
|
const snackbarVisible =
|
||||||
!useDefaultAlert && showUpdateSnackbar && updateInfo?.update;
|
!useDefaultAlert && showUpdateSnackbar && updateInfo?.update;
|
||||||
const [showCamera, setShowCamera] = useState(false);
|
const [showCamera, setShowCamera] = useState(false);
|
||||||
|
const lastParsedCode = useRef('');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
@@ -73,9 +74,16 @@ function App() {
|
|||||||
style={{minHeight: 320}}
|
style={{minHeight: 320}}
|
||||||
scanBarcode={true}
|
scanBarcode={true}
|
||||||
onReadCode={({nativeEvent: {codeStringValue}}) => {
|
onReadCode={({nativeEvent: {codeStringValue}}) => {
|
||||||
console.log(codeStringValue);
|
// 防止重复扫码
|
||||||
parseTestQrCode(codeStringValue);
|
if (lastParsedCode.current === codeStringValue) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastParsedCode.current = codeStringValue;
|
||||||
|
setTimeout(() => {
|
||||||
|
lastParsedCode.current = '';
|
||||||
|
}, 1000);
|
||||||
setShowCamera(false);
|
setShowCamera(false);
|
||||||
|
parseTestQrCode(codeStringValue);
|
||||||
}} // optional
|
}} // optional
|
||||||
showFrame={true} // (default false) optional, show frame with transparent layer (qr code or barcode will be read on this area ONLY), start animation for scanner, that stops when a code has been found. Frame always at center of the screen
|
showFrame={true} // (default false) optional, show frame with transparent layer (qr code or barcode will be read on this area ONLY), start animation for scanner, that stops when a code has been found. Frame always at center of the screen
|
||||||
laserColor="red" // (default red) optional, color of laser in scanner frame
|
laserColor="red" // (default red) optional, color of laser in scanner frame
|
||||||
|
@@ -6236,10 +6236,10 @@ react-native-safe-area-context@^4.8.2:
|
|||||||
resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-4.8.2.tgz#e6b3d8acf3c6afcb4b5db03a97f9c37df7668f65"
|
resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-4.8.2.tgz#e6b3d8acf3c6afcb4b5db03a97f9c37df7668f65"
|
||||||
integrity sha512-ffUOv8BJQ6RqO3nLml5gxJ6ab3EestPiyWekxdzO/1MQ7NF8fW1Mzh1C5QE9yq573Xefnc7FuzGXjtesZGv7cQ==
|
integrity sha512-ffUOv8BJQ6RqO3nLml5gxJ6ab3EestPiyWekxdzO/1MQ7NF8fW1Mzh1C5QE9yq573Xefnc7FuzGXjtesZGv7cQ==
|
||||||
|
|
||||||
react-native-update@^10.11.2:
|
react-native-update@^10.11.3:
|
||||||
version "10.11.2"
|
version "10.11.3"
|
||||||
resolved "https://registry.yarnpkg.com/react-native-update/-/react-native-update-10.11.2.tgz#d80f0c0f3705713d302b6c36d3fd8ff2f0fba340"
|
resolved "https://registry.yarnpkg.com/react-native-update/-/react-native-update-10.11.3.tgz#5fa44fdd12514eb5e7901a5d664f00fd082d6774"
|
||||||
integrity sha512-5WlJ3TRodHSftqDxi3OCAnI/OIq70Kh8gr1xa9OqEG2+UwD1SA+gqHRHunKED4J7N7OUtmxIDX+hvdf8xJEgRA==
|
integrity sha512-adI3sly0yFt1DfaPqICJ9VwzUoa/XAngv/N7SnICkLxO3jgccBgy0OrXDBxRn43Zeumdq40Z+ADTE5qrY4BWAw==
|
||||||
dependencies:
|
dependencies:
|
||||||
nanoid "^3.3.3"
|
nanoid "^3.3.3"
|
||||||
react-native-url-polyfill "^2.0.0"
|
react-native-url-polyfill "^2.0.0"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update",
|
"name": "react-native-update",
|
||||||
"version": "10.11.3",
|
"version": "10.11.5",
|
||||||
"description": "react-native hot update",
|
"description": "react-native hot update",
|
||||||
"main": "src/index",
|
"main": "src/index",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@@ -172,7 +172,6 @@ export class Pushy {
|
|||||||
return await this.lastRespJson;
|
return await this.lastRespJson;
|
||||||
}
|
}
|
||||||
this.lastChecking = now;
|
this.lastChecking = now;
|
||||||
this.report({ type: 'checking' });
|
|
||||||
const fetchBody = {
|
const fetchBody = {
|
||||||
packageVersion,
|
packageVersion,
|
||||||
hash: currentVersion,
|
hash: currentVersion,
|
||||||
@@ -183,16 +182,21 @@ export class Pushy {
|
|||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
delete fetchBody.buildTime;
|
delete fetchBody.buildTime;
|
||||||
}
|
}
|
||||||
|
const body = JSON.stringify(fetchBody);
|
||||||
const fetchPayload = {
|
const fetchPayload = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify(fetchBody),
|
body,
|
||||||
};
|
};
|
||||||
let resp;
|
let resp;
|
||||||
try {
|
try {
|
||||||
|
this.report({
|
||||||
|
type: 'checking',
|
||||||
|
message: this.options.appKey + ': ' + body,
|
||||||
|
});
|
||||||
resp = await fetch(this.getCheckUrl(), fetchPayload);
|
resp = await fetch(this.getCheckUrl(), fetchPayload);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
this.report({
|
this.report({
|
||||||
@@ -221,6 +225,8 @@ export class Pushy {
|
|||||||
|
|
||||||
const result: CheckResult = await this.lastRespJson;
|
const result: CheckResult = await this.lastRespJson;
|
||||||
|
|
||||||
|
log('checking result:', result);
|
||||||
|
|
||||||
if (resp.status !== 200) {
|
if (resp.status !== 200) {
|
||||||
this.report({
|
this.report({
|
||||||
type: 'errorChecking',
|
type: 'errorChecking',
|
||||||
|
@@ -147,7 +147,7 @@ export const PushyProvider = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const checkUpdate = useCallback(
|
const checkUpdate = useCallback(
|
||||||
async (extra?: Record<string, any>) => {
|
async ({ extra }: { extra?: Record<string, any> } | undefined = {}) => {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
if (lastChecking.current && now - lastChecking.current < 1000) {
|
if (lastChecking.current && now - lastChecking.current < 1000) {
|
||||||
return;
|
return;
|
||||||
@@ -272,7 +272,7 @@ export const PushyProvider = ({
|
|||||||
Alert.alert(type, JSON.stringify(data));
|
Alert.alert(type, JSON.stringify(data));
|
||||||
};
|
};
|
||||||
if (payload.type === '__rnPushyVersionHash') {
|
if (payload.type === '__rnPushyVersionHash') {
|
||||||
checkUpdate({ toHash: payload.data }).then(() => {
|
checkUpdate({ extra: { toHash: payload.data } }).then(() => {
|
||||||
if (updateInfoRef.current && updateInfoRef.current.upToDate) {
|
if (updateInfoRef.current && updateInfoRef.current.upToDate) {
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
'提示',
|
'提示',
|
||||||
@@ -290,10 +290,9 @@ export const PushyProvider = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const parseTestQrCode = useCallback(
|
const parseTestQrCode = useCallback(
|
||||||
(code: string) => {
|
(code: string | PushyTestPayload) => {
|
||||||
let payload: PushyTestPayload;
|
|
||||||
try {
|
try {
|
||||||
payload = JSON.parse(code);
|
const payload = typeof code === 'string' ? JSON.parse(code) : code;
|
||||||
return parseTestPayload(payload);
|
return parseTestPayload(payload);
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user