Browse Source

RN 0.67.0升级

wushaodong 2 years ago
parent
commit
1891e5a260
59 changed files with 1180 additions and 905 deletions
  1. 4 0
      .eslintrc.js
  2. 40 35
      .flowconfig
  3. 11 4
      .gitignore
  4. 6 0
      .prettierrc.js
  5. 0 1
      android.bat
  6. 0 17
      android/.project
  7. 0 2
      android/.settings/org.eclipse.buildship.core.prefs
  8. 0 6
      android/app/.classpath
  9. 0 23
      android/app/.project
  10. 0 2
      android/app/.settings/org.eclipse.buildship.core.prefs
  11. 0 0
      android/app/BUCK
  12. 64 26
      android/app/build.gradle
  13. BIN
      android/app/debug.keystore
  14. 0 23
      android/app/gradle.properties
  15. 0 27
      android/app/proguard-rules.pro
  16. 0 1
      android/app/release/output.json
  17. 6 1
      android/app/src/debug/AndroidManifest.xml
  18. 72 0
      android/app/src/debug/java/com/zzliaoyuan/power_sensor/ReactNativeFlipper.java
  19. 19 21
      android/app/src/main/AndroidManifest.xml
  20. 54 37
      android/app/src/main/java/com/zzliaoyuan/power_sensor/MainActivity.java
  21. 63 58
      android/app/src/main/java/com/zzliaoyuan/power_sensor/MainApplication.java
  22. 3 6
      android/app/src/main/java/com/zzliaoyuan/power_sensor/fragment/UHFReadTagFragment.java
  23. 1 3
      android/app/src/main/java/com/zzliaoyuan/power_sensor/readUHF/ReadUHFModule.java
  24. 0 1
      android/app/src/main/java/com/zzliaoyuan/power_sensor/readUHF/ReadUHFPackage.java
  25. BIN
      android/app/src/main/res/drawable-xxxhdpi/ic_launcher.png
  26. 0 12
      android/app/src/main/res/drawable/countdown_days.xml
  27. 36 0
      android/app/src/main/res/drawable/rn_edit_text_material.xml
  28. 0 8
      android/app/src/main/res/layout/activity_jump.xml
  29. 0 6
      android/app/src/main/res/layout/activity_live.xml
  30. 0 8
      android/app/src/main/res/layout/activity_push.xml
  31. 0 62
      android/app/src/main/res/layout/notification_countdown.xml
  32. 0 15
      android/app/src/main/res/values/colors.xml
  33. 2 13
      android/app/src/main/res/values/styles.xml
  34. 4 0
      android/app/src/main/res/xml/network_security_config.xml
  35. 17 15
      android/build.gradle
  36. 14 3
      android/gradle.properties
  37. BIN
      android/gradle/wrapper/gradle-wrapper.jar
  38. 1 1
      android/gradle/wrapper/gradle-wrapper.properties
  39. 17 20
      android/gradlew
  40. 8 19
      android/gradlew.bat
  41. 0 2
      android/settings.gradle
  42. 3 0
      babel.config.js
  43. 1 5
      index.js
  44. 0 1
      ios.sh
  45. 8 8
      jscore/App.js
  46. 37 35
      jscore/pages/Desktop/Home.js
  47. 425 0
      jscore/pages/Desktop/Home2.js
  48. 13 54
      jscore/pages/Desktop/Index.js
  49. 22 16
      jscore/pages/Desktop/Set.js
  50. 8 9
      jscore/pages/Welcome.js
  51. 0 66
      jscore/root.js
  52. 91 61
      jscore/router.js
  53. 0 69
      jscore/scripts/custom-rn-theme.js
  54. 60 0
      jscore/utils/SyncStorage.js
  55. 10 0
      jscore/utils/index.js
  56. 0 42
      jscore/utils/storage.js
  57. 17 0
      metro.config.js
  58. 43 60
      package.json
  59. 0 1
      ra.bat

+ 4 - 0
.eslintrc.js

@@ -0,0 +1,4 @@
+module.exports = {
+  root: true,
+  extends: '@react-native-community',
+};

+ 40 - 35
.flowconfig

@@ -5,26 +5,24 @@
 ; Ignore "BUCK" generated dirs
 <PROJECT_ROOT>/\.buckd/
 
-; Ignore unexpected extra "@providesModule"
-.*/node_modules/.*/node_modules/fbjs/.*
+; Ignore polyfills
+node_modules/react-native/Libraries/polyfills/.*
 
-; Ignore duplicate module providers
-; For RN Apps installed via npm, "Libraries" folder is inside
-; "node_modules/react-native" but in the source repo it is in the root
-.*/Libraries/react-native/React.js
+; These should not be required directly
+; require from fbjs/lib instead: require('fbjs/lib/warning')
+node_modules/warning/.*
 
-; Ignore polyfills
-.*/Libraries/polyfills/.*
+; Flow doesn't support platforms
+.*/Libraries/Utilities/LoadingView.js
 
-; Ignore metro
-.*/node_modules/metro/.*
+[untyped]
+.*/node_modules/@react-native-community/cli/.*/.*
 
 [include]
 
 [libs]
 node_modules/react-native/Libraries/react-native/react-native-interface.js
 node_modules/react-native/flow/
-node_modules/react-native/flow-github/
 
 [options]
 emoji=true
@@ -32,39 +30,46 @@ emoji=true
 esproposal.optional_chaining=enable
 esproposal.nullish_coalescing=enable
 
-module.system=haste
-module.system.haste.use_name_reducers=true
-# get basename
-module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
-# strip .js or .js.flow suffix
-module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
-# strip .ios suffix
-module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
-module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
-module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
-module.system.haste.paths.blacklist=.*/__tests__/.*
-module.system.haste.paths.blacklist=.*/__mocks__/.*
-module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*
-module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
+module.file_ext=.js
+module.file_ext=.json
+module.file_ext=.ios.js
 
 munge_underscores=true
 
-module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
-
-module.file_ext=.js
-module.file_ext=.jsx
-module.file_ext=.json
-module.file_ext=.native.js
+module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
+module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
+module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
 
 suppress_type=$FlowIssue
 suppress_type=$FlowFixMe
 suppress_type=$FlowFixMeProps
 suppress_type=$FlowFixMeState
 
-suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
-suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
-suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
+suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
+suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
 suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
 
+[lints]
+sketchy-null-number=warn
+sketchy-null-mixed=warn
+sketchy-number=warn
+untyped-type-import=warn
+nonstrict-import=warn
+deprecated-type=warn
+unsafe-getters-setters=warn
+inexact-spread=warn
+unnecessary-invariant=warn
+signature-verification-failure=warn
+deprecated-utility=error
+
+[strict]
+deprecated-type
+nonstrict-import
+sketchy-null
+unclear-type
+unsafe-getters-setters
+untyped-import
+untyped-type-import
+
 [version]
-^0.78.0
+^0.105.0

+ 11 - 4
.gitignore

@@ -20,27 +20,31 @@ DerivedData
 *.hmap
 *.ipa
 *.xcuserstate
-project.xcworkspace
+*.zip
 
 # Android/IntelliJ
 #
 build/
 .idea
+.history
 .gradle
 local.properties
 *.iml
+*.keystore
 
 # node.js
 #
 node_modules/
 npm-debug.log
 yarn-error.log
+yarn.lock
+package-lock.json
 
 # BUCK
 buck-out/
 \.buckd/
-*.keystore
-*.lock
+#*.keystore
+!debug.keystore
 
 # fastlane
 #
@@ -55,4 +59,7 @@ buck-out/
 
 # Bundle artifact
 *.jsbundle
-package-lock.json
+
+# CocoaPods
+/ios/Pods/
+android/app/release/*

+ 6 - 0
.prettierrc.js

@@ -0,0 +1,6 @@
+module.exports = {
+  bracketSpacing: false,
+  jsxBracketSameLine: true,
+  singleQuote: true,
+  trailingComma: 'all',
+};

+ 0 - 1
android.bat

@@ -1 +0,0 @@
-react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

+ 0 - 17
android/.project

@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>power_sensor</name>
-	<comment>Project android created by Buildship.</comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
-	</natures>
-</projectDescription>

+ 0 - 2
android/.settings/org.eclipse.buildship.core.prefs

@@ -1,2 +0,0 @@
-connection.project.dir=
-eclipse.preferences.version=1

+ 0 - 6
android/app/.classpath

@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
-	<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
-	<classpathentry kind="output" path="bin/default"/>
-</classpath>

+ 0 - 23
android/app/.project

@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-	<name>app</name>
-	<comment>Project app created by Buildship.</comment>
-	<projects>
-	</projects>
-	<buildSpec>
-		<buildCommand>
-			<name>org.eclipse.jdt.core.javabuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-		<buildCommand>
-			<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
-			<arguments>
-			</arguments>
-		</buildCommand>
-	</buildSpec>
-	<natures>
-		<nature>org.eclipse.jdt.core.javanature</nature>
-		<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
-	</natures>
-</projectDescription>

+ 0 - 2
android/app/.settings/org.eclipse.buildship.core.prefs

@@ -1,2 +0,0 @@
-connection.project.dir=..
-eclipse.preferences.version=1

+ 0 - 0
android/app/_BUCK → android/app/BUCK


+ 64 - 26
android/app/build.gradle

@@ -15,10 +15,12 @@ import com.android.build.OutputFile
  *   // the name of the generated asset file containing your JS bundle
  *   bundleAssetName: "index.android.bundle",
  *
- *   // the entry file for bundle generation
+ *   // the entry file for bundle generation. If none specified and
+ *   // "index.android.js" exists, it will be used. Otherwise "index.js" is
+ *   // default. Can be overridden with ENTRY_FILE environment variable.
  *   entryFile: "index.android.js",
  *
- *   // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
+ *   // https://reactnative.dev/docs/performance#enable-the-ram-format
  *   bundleCommand: "ram-bundle",
  *
  *   // whether to bundle JS and assets in debug mode
@@ -76,8 +78,8 @@ import com.android.build.OutputFile
  */
 
 project.ext.react = [
-    entryFile: "index.js",
-    enableHermes: false,  // clean and rebuild if changing
+        enableHermes: false,  // clean and rebuild if changing
+        deleteDebugFilesForVariant: { false }
 ]
 
 apply from: "../../node_modules/react-native/react.gradle"
@@ -113,45 +115,43 @@ def jscFlavor = 'org.webkit:android-jsc:+'
 /**
  * Whether to enable the Hermes VM.
  *
- * This should be set on project.ext.react and mirrored here.  If it is not set
+ * This should be set on project.ext.react and that value will be read here. If it is not set
  * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
  * and the benefits of using Hermes will therefore be sharply reduced.
  */
 def enableHermes = project.ext.react.get("enableHermes", false);
 
+/**
+ * Architectures to build native code for in debug.
+ */
+def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
+
 android {
-    compileSdkVersion rootProject.ext.compileSdkVersion
-    buildToolsVersion = '29.0.1'
+    ndkVersion rootProject.ext.ndkVersion
 
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_8
-        targetCompatibility JavaVersion.VERSION_1_8
-    }
+    compileSdkVersion rootProject.ext.compileSdkVersion
 
     defaultConfig {
         applicationId "com.zzliaoyuan.power_sensor"
         minSdkVersion rootProject.ext.minSdkVersion
         targetSdkVersion rootProject.ext.targetSdkVersion
-        versionCode 10
-        versionName "1.0.0"
+        versionCode 20
+        versionName "2.0"
     }
-
     splits {
         abi {
             reset()
             enable enableSeparateBuildPerCPUArchitecture
-            universalApk true  // If true, also generate a universal APK
+            universalApk false  // If true, also generate a universal APK
             include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
         }
     }
     signingConfigs {
         debug {
-            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
-                storeFile file(MYAPP_RELEASE_STORE_FILE)
-                storePassword MYAPP_RELEASE_STORE_PASSWORD
-                keyAlias MYAPP_RELEASE_KEY_ALIAS
-                keyPassword MYAPP_RELEASE_KEY_PASSWORD
-            }
+            storeFile file('debug.keystore')
+            storePassword 'android'
+            keyAlias 'androiddebugkey'
+            keyPassword 'android'
         }
         release {
             if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
@@ -162,29 +162,40 @@ android {
             }
         }
     }
-
     sourceSets {
         main {
             jniLibs.srcDirs = ['src\\main\\jniLibs']
         }
     }
-
     buildTypes {
+        debug {
+            signingConfig signingConfigs.debug
+            if (nativeArchitectures) {
+                ndk {
+                    abiFilters nativeArchitectures.split(',')
+                }
+            }
+        }
         release {
+            // Caution! In production, you need to generate your own keystore file.
+            // see https://reactnative.dev/docs/signed-apk-android.
+            signingConfig signingConfigs.release
             minifyEnabled enableProguardInReleaseBuilds
             proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
         }
     }
+
     // applicationVariants are e.g. debug, release
     applicationVariants.all { variant ->
         variant.outputs.each { output ->
             // For each separate APK per architecture, set a unique version code as described here:
             // https://developer.android.com/studio/build/configure-apk-splits.html
+            // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
             def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
             def abi = output.getFilter(OutputFile.ABI)
             if (abi != null) {  // null for the universal-debug, universal-release variants
                 output.versionCodeOverride =
-                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
+                        defaultConfig.versionCode * 1000 + versionCodes.get(abi)
             }
 
         }
@@ -196,10 +207,12 @@ repositories {
     }
 }
 dependencies {
-//    implementation project(':react-native-gesture-handler')
     implementation fileTree(dir: "libs", include: ["*.jar"])
+    //noinspection GradleDynamicVersion
     implementation "com.facebook.react:react-native:+"  // From node_modules
-    implementation 'com.android.support:multidex:1.0.3'
+
+    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
+    api 'com.github.dfqin:grantor:2.5' // MainActivity获取相机权限用
 
     // rifdmastercore
     implementation(name: 'corewrapper', ext:'aar')
@@ -208,6 +221,23 @@ dependencies {
     // UHF
     implementation files('libs/cw-deviceapi20191022.jar')
 
+    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
+        exclude group: 'com.facebook.fbjni'
+    }
+
+    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
+        exclude group: 'com.facebook.flipper'
+        exclude group: 'com.squareup.okhttp3', module: 'okhttp'
+    }
+
+    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
+        exclude group: 'com.facebook.flipper'
+    }
+
+    //bugly
+//    implementation 'com.tencent.bugly:crashreport_upgrade:latest.release'
+//    implementation 'com.tencent.bugly:nativecrashreport:latest.release'
+
     if (enableHermes) {
         def hermesPath = "../../node_modules/hermes-engine/android/";
         debugImplementation files(hermesPath + "hermes-debug.aar")
@@ -215,6 +245,14 @@ dependencies {
     } else {
         implementation jscFlavor
     }
+
+}
+
+// Run this once to be able to run the application with BUCK
+// puts all compile dependencies into folder libs for BUCK to use
+task copyDownloadableDepsToLibs(type: Copy) {
+    from configurations.implementation
+    into 'libs'
 }
 
 apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

BIN
android/app/debug.keystore


+ 0 - 23
android/app/gradle.properties

@@ -1,23 +0,0 @@
-# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
-# Gradle settings configured through the IDE *will override*
-# any settings specified in this file.
-
-# For more details on how to configure your build environment visit
-# http://www.gradle.org/docs/current/userguide/build_environment.html
-
-# Specifies the JVM arguments used for the daemon process.
-# The setting is particularly useful for tweaking memory settings.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
-
-MYAPP_RELEASE_STORE_FILE=../examwin.keystore
-MYAPP_RELEASE_KEY_ALIAS=examwin
-MYAPP_RELEASE_STORE_PASSWORD=zzly508
-MYAPP_RELEASE_KEY_PASSWORD=zzly508

+ 0 - 27
android/app/proguard-rules.pro

@@ -8,30 +8,3 @@
 #   http://developer.android.com/guide/developing/tools/proguard.html
 
 # Add any project specific keep options here:
-
--keep class com.alipay.android.app.IAlixPay{*;}
--keep class com.alipay.android.app.IAlixPay$Stub{*;}
--keep class com.alipay.android.app.IRemoteServiceCallback{*;}
--keep class com.alipay.android.app.IRemoteServiceCallback$Stub{*;}
--keep class com.alipay.sdk.app.PayTask{ public *;}
--keep class com.alipay.sdk.app.AuthTask{ public *;}
--keep class com.alipay.sdk.app.H5PayCallback {
-    <fields>;
-    <methods>;
-}
--keep class com.alipay.android.phone.mrpc.core.** { *; }
--keep class com.alipay.apmobilesecuritysdk.** { *; }
--keep class com.alipay.mobile.framework.service.annotation.** { *; }
--keep class com.alipay.mobilesecuritysdk.face.** { *; }
--keep class com.alipay.tscenter.biz.rpc.** { *; }
--keep class org.json.alipay.** { *; }
--keep class com.alipay.tscenter.** { *; }
--keep class com.ta.utdid2.** { *;}
--keep class com.ut.device.** { *;}
--keep class com.tencent.mm.sdk.** {
-  *;
-}
--keep class com.umeng.** {*;}
--dontwarn com.tencent.bugly.**
--keep public class com.tencent.bugly.**{*;}
--keep class android.support.**{*;}

+ 0 - 1
android/app/release/output.json

@@ -1 +0,0 @@
-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":10,"versionName":"1.0.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]

+ 6 - 1
android/app/src/debug/AndroidManifest.xml

@@ -4,5 +4,10 @@
 
     <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
 
-    <application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
+    <application
+        android:usesCleartextTraffic="true"
+        tools:targetApi="28"
+        tools:ignore="GoogleAppIndexingWarning">
+        <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
+    </application>
 </manifest>

+ 72 - 0
android/app/src/debug/java/com/zzliaoyuan/power_sensor/ReactNativeFlipper.java

@@ -0,0 +1,72 @@
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * <p>This source code is licensed under the MIT license found in the LICENSE file in the root
+ * directory of this source tree.
+ */
+package com.zzliaoyuan.power_sensor;
+
+import android.content.Context;
+import com.facebook.flipper.android.AndroidFlipperClient;
+import com.facebook.flipper.android.utils.FlipperUtils;
+import com.facebook.flipper.core.FlipperClient;
+import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
+import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
+import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
+import com.facebook.flipper.plugins.inspector.DescriptorMapping;
+import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
+import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
+import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
+import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
+import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
+import com.facebook.react.ReactInstanceManager;
+import com.facebook.react.bridge.ReactContext;
+import com.facebook.react.modules.network.NetworkingModule;
+import okhttp3.OkHttpClient;
+
+public class ReactNativeFlipper {
+  public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
+    if (FlipperUtils.shouldEnableFlipper(context)) {
+      final FlipperClient client = AndroidFlipperClient.getInstance(context);
+
+      client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
+      client.addPlugin(new ReactFlipperPlugin());
+      client.addPlugin(new DatabasesFlipperPlugin(context));
+      client.addPlugin(new SharedPreferencesFlipperPlugin(context));
+      client.addPlugin(CrashReporterPlugin.getInstance());
+
+      NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
+      NetworkingModule.setCustomClientBuilder(
+          new NetworkingModule.CustomClientBuilder() {
+            @Override
+            public void apply(OkHttpClient.Builder builder) {
+              builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
+            }
+          });
+      client.addPlugin(networkFlipperPlugin);
+      client.start();
+
+      // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
+      // Hence we run if after all native modules have been initialized
+      ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
+      if (reactContext == null) {
+        reactInstanceManager.addReactInstanceEventListener(
+            new ReactInstanceManager.ReactInstanceEventListener() {
+              @Override
+              public void onReactContextInitialized(ReactContext reactContext) {
+                reactInstanceManager.removeReactInstanceEventListener(this);
+                reactContext.runOnNativeModulesQueueThread(
+                    new Runnable() {
+                      @Override
+                      public void run() {
+                        client.addPlugin(new FrescoFlipperPlugin());
+                      }
+                    });
+              }
+            });
+      } else {
+        client.addPlugin(new FrescoFlipperPlugin());
+      }
+    }
+  }
+}

+ 19 - 21
android/app/src/main/AndroidManifest.xml

@@ -1,7 +1,5 @@
-<?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    package="com.zzliaoyuan.power_sensor">
+  package="com.zzliaoyuan.power_sensor">
 
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
@@ -12,27 +10,27 @@
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
 
     <application
-        android:name=".MainApplication"
-        android:icon="@mipmap/ic_launcher"
-        android:usesCleartextTraffic="true"
-        android:requestLegacyExternalStorage="true"
+      android:name=".MainApplication"
+      android:label="@string/app_name"
+      android:icon="@mipmap/ic_launcher"
+      android:roundIcon="@mipmap/ic_launcher"
+      android:allowBackup="true"
+      android:networkSecurityConfig="@xml/network_security_config"
+      android:theme="@style/AppTheme">
+      <activity
+        android:exported="true"
+        android:name=".MainActivity"
         android:label="@string/app_name"
-        android:theme="@style/AppTheme">
-        <uses-library android:name="org.apache.http.legacy" android:required="false" />
-        <activity
-            android:name=".activity.MainActivity"
-            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
-            android:label="@string/app_name"
-            android:windowSoftInputMode="adjustResize">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
-        </activity>
+        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
+        android:launchMode="singleTask"
+        android:windowSoftInputMode="adjustResize">
+        <intent-filter>
+            <action android:name="android.intent.action.MAIN" />
+            <category android:name="android.intent.category.LAUNCHER" />
+        </intent-filter>
+      </activity>
 
         <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
 
     </application>
-
 </manifest>

+ 54 - 37
android/app/src/main/java/com/zzliaoyuan/power_sensor/activity/MainActivity.java → android/app/src/main/java/com/zzliaoyuan/power_sensor/MainActivity.java

@@ -1,22 +1,35 @@
-package com.zzliaoyuan.power_sensor.activity;
+package com.zzliaoyuan.power_sensor;
 
 import android.Manifest;
-import android.app.Activity;
 import android.app.AlertDialog;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
-import android.content.pm.PackageManager;
 import android.media.AudioManager;
 import android.media.SoundPool;
 import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Environment;
-import android.util.Log;
 import android.view.KeyEvent;
 import android.widget.Toast;
 
+import com.facebook.react.ReactActivity;
+
+import androidx.annotation.NonNull;
+import com.github.dfqin.grantor.PermissionListener;
+import com.github.dfqin.grantor.PermissionsUtil;
+import com.rscja.deviceapi.RFIDWithUHFUART;
+import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
+import com.zzliaoyuan.power_sensor.fragment.UHFReadTagFragment;
+import com.zzliaoyuan.rifdmastercore.LibCore;
+
+import java.io.FileInputStream;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.HashMap;
+
+
 import com.facebook.react.ReactActivity;
 import com.facebook.react.ReactActivityDelegate;
 import com.facebook.react.ReactRootView;
@@ -33,59 +46,64 @@ import com.rscja.deviceapi.RFIDWithUHFUART;
 import com.zzliaoyuan.power_sensor.fragment.UHFReadTagFragment;
 import com.zzliaoyuan.rifdmastercore.LibCore;
 
-import androidx.core.app.ActivityCompat;
 public class MainActivity extends ReactActivity {
+
     /**
      * Returns the name of the main component registered from JavaScript. This is used to schedule
      * rendering of the component.
      */
-    public RFIDWithUHFUART mReader;
-
     @Override
     protected String getMainComponentName() {
         return "power_sensor";
     }
 
+    public RFIDWithUHFUART mReader;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
+        super.onCreate(null);
+        requirePerms();
         setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // 禁用横屏
 
-        verifyStoragePermissions(this);
+//        verifyStoragePermissions(this);
         checkLicense();
     }
 
-    // Storage Permissions
-    private static final int REQUEST_EXTERNAL_STORAGE = 1;
-    private static String[] PERMISSIONS_STORAGE = {
-            Manifest.permission.READ_EXTERNAL_STORAGE,
-            Manifest.permission.WRITE_EXTERNAL_STORAGE
-    };
-    public static void verifyStoragePermissions(Activity activity) {
-        // Check if we have write permission
-        int permission_w = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
-        int permission_r = ActivityCompat.checkSelfPermission(activity, Manifest.permission.READ_EXTERNAL_STORAGE);
-        if (permission_w != PackageManager.PERMISSION_GRANTED || permission_r != PackageManager.PERMISSION_GRANTED) {
-            // We don't have permission so prompt the user
-            ActivityCompat.requestPermissions(
-                    activity,
-                    PERMISSIONS_STORAGE,
-                    REQUEST_EXTERNAL_STORAGE
-            );
-        }
-    }
+    private void requirePerms() {
+//        String[] permissions = {Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE};
 
-    @Override
-    protected ReactActivityDelegate createReactActivityDelegate() {
-        return new ReactActivityDelegate(this, getMainComponentName()) {
-            @Override
-            protected ReactRootView createRootView() {
-                return new RNGestureHandlerEnabledRootView(MainActivity.this);
-            }
+        String[] mPermissionList = new String[]{
+                Manifest.permission.READ_EXTERNAL_STORAGE,
+                Manifest.permission.WRITE_EXTERNAL_STORAGE,
         };
+        if (!PermissionsUtil.hasPermission(this, mPermissionList)) {
+            PermissionsUtil.requestPermission(this, new PermissionListener() {
+                @Override
+                public void permissionGranted(@NonNull String[] mPermissionList) {
+                    //用户授予了权限
+
+                }
+
+                @Override
+                public void permissionDenied(@NonNull String[] mPermissionList) {
+                    //用户拒绝了申请
+                    Toast.makeText(MainActivity.this, "您拒绝了相关的权限,将无法使用部分功能!", Toast.LENGTH_SHORT).show();
+                }
+            }, mPermissionList);
+        }
     }
 
+
+//    @Override
+//    protected ReactActivityDelegate createReactActivityDelegate() {
+//        return new ReactActivityDelegate(this, getMainComponentName()) {
+//            @Override
+//            protected ReactRootView createRootView() {
+//                return new RNGestureHandlerEnabledRootView(MainActivity.this);
+//            }
+//        };
+//    }
+
     @Override
     public boolean onKeyDown(int keyCode, KeyEvent event) {
         if (keyCode == 139 || keyCode == 280 || keyCode == 293) {
@@ -239,5 +257,4 @@ public class MainActivity extends ReactActivity {
         }
         super.onDestroy();
     }
-
 }

+ 63 - 58
android/app/src/main/java/com/zzliaoyuan/power_sensor/MainApplication.java

@@ -4,85 +4,90 @@ import android.app.Application;
 import android.content.Context;
 import com.facebook.react.PackageList;
 import com.facebook.react.ReactApplication;
-import com.reactnativecommunity.asyncstorage.AsyncStoragePackage;
+import com.facebook.react.ReactInstanceManager;
 import com.facebook.react.ReactNativeHost;
 import com.facebook.react.ReactPackage;
 import com.facebook.soloader.SoLoader;
-
 import java.lang.reflect.InvocationTargetException;
 import java.util.List;
+//import com.tencent.bugly.Bugly;
+//import com.zzliaoyuan.power_sensor.bugly.BuglyPackage;
 import com.zzliaoyuan.power_sensor.readUHF.ReadUHFPackage;
 
 public class MainApplication extends Application implements ReactApplication {
-  public static MainApplication CONTEXT;
-  public static final MyReactPackage reactPackage = new MyReactPackage();
+    public static MainApplication CONTEXT;
+    public static final MyReactPackage reactPackage = new MyReactPackage();
 
-  private final ReactNativeHost mReactNativeHost =
-      new ReactNativeHost(this) {
-        @Override
-        public boolean getUseDeveloperSupport() {
-          return BuildConfig.DEBUG;
-        }
+    private final ReactNativeHost mReactNativeHost =
+            new ReactNativeHost(this) {
+                @Override
+                public boolean getUseDeveloperSupport() {
+                    return BuildConfig.DEBUG;
+                }
 
-        @Override
-        protected List<ReactPackage> getPackages() {
-          @SuppressWarnings("UnnecessaryLocalVariable")
-          List<ReactPackage> packages = new PackageList(this).getPackages();
-          // Packages that cannot be autolinked yet can be added manually here, for example:
-          // packages.add(new MyReactNativePackage());
-          packages.add(reactPackage);
-          packages.add(new ReadUHFPackage());
+                @Override
+                protected List<ReactPackage> getPackages() {
+                    @SuppressWarnings("UnnecessaryLocalVariable")
+                    List<ReactPackage> packages = new PackageList(this).getPackages();
+                    // Packages that cannot be autolinked yet can be added manually here, for example:
+//                    packages.add(new BuglyPackage());
+                    packages.add(reactPackage);
+                    packages.add(new ReadUHFPackage());
+                    return packages;
+                }
 
-          return packages;
-        }
-
-        @Override
-        protected String getJSMainModuleName() {
-          return "index";
-        }
-      };
+                @Override
+                protected String getJSMainModuleName() {
+                    return "index";
+                }
+            };
 
-  @Override
-  public ReactNativeHost getReactNativeHost() {
-    return mReactNativeHost;
-  }
-
-  @Override
-  public void onCreate() {
-    super.onCreate();
-    SoLoader.init(this, /* native exopackage */ false);
-    initializeFlipper(this); // Remove this line if you don't want Flipper enabled
+    @Override
+    public ReactNativeHost getReactNativeHost() {
+        return mReactNativeHost;
+    }
 
-      CONTEXT = this;
-  }
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        SoLoader.init(this, /* native exopackage */ false);
+        initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
+        //bugly
+//        Bugly.init(getApplicationContext(), "41ee687faa", false);
 
+    }
     public static MyReactPackage GetReactPackage(){
         return reactPackage;
     }
 
-  /**
-   * Loads Flipper in React Native templates.
-   *
-   * @param context
-   */
-  private static void initializeFlipper(Context context) {
-    if (BuildConfig.DEBUG) {
-      try {
+    /**
+     * Loads Flipper in React Native templates. Call this in the onCreate method with something like
+     * initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
+     *
+     * @param context
+     * @param reactInstanceManager
+     */
+    private static void initializeFlipper(
+            Context context, ReactInstanceManager reactInstanceManager) {
+        if (BuildConfig.DEBUG) {
+            try {
         /*
          We use reflection here to pick up the class that initializes Flipper,
         since Flipper library is not available in release mode
         */
-        Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
-        aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
-      } catch (ClassNotFoundException e) {
-        e.printStackTrace();
-      } catch (NoSuchMethodException e) {
-        e.printStackTrace();
-      } catch (IllegalAccessException e) {
-        e.printStackTrace();
-      } catch (InvocationTargetException e) {
-        e.printStackTrace();
-      }
+                Class<?> aClass = Class.forName("com.zzliaoyuan.power_sensor.ReactNativeFlipper");
+                aClass
+                        .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
+                        .invoke(null, context, reactInstanceManager);
+            } catch (ClassNotFoundException e) {
+                e.printStackTrace();
+            } catch (NoSuchMethodException e) {
+                e.printStackTrace();
+            } catch (IllegalAccessException e) {
+                e.printStackTrace();
+            } catch (InvocationTargetException e) {
+                e.printStackTrace();
+            }
+        }
     }
-  }
 }

+ 3 - 6
android/app/src/main/java/com/zzliaoyuan/power_sensor/fragment/UHFReadTagFragment.java

@@ -1,14 +1,11 @@
 package com.zzliaoyuan.power_sensor.fragment;
 
-import android.Manifest;
-import android.media.MediaScannerConnection;
 import android.os.Environment;
-import android.util.Log;
 
+import com.rscja.deviceapi.entity.UHFTAGInfo;
 import com.zzliaoyuan.power_sensor.MainApplication;
-import com.zzliaoyuan.power_sensor.activity.MainActivity;
+import com.zzliaoyuan.power_sensor.MainActivity;
 import com.zzliaoyuan.power_sensor.tools.UIHelper;
-import com.rscja.deviceapi.entity.UHFTAGInfo;
 import com.zzliaoyuan.rifdmastercore.LibCore;
 import com.zzliaoyuan.rifdmastercore.ProductInfo;
 
@@ -30,7 +27,7 @@ public class UHFReadTagFragment {
     private Timer mTimer = null;
     private TimerTask mTimerTask = null;
     private static int delayTime = 100;  //ms
-    private static int periodTime = 200;  //ms
+    private static int periodTime = 300;  //ms
     private boolean isStop = true;
     private ArrayList<String> assetsList = new ArrayList<String>();
 

+ 1 - 3
android/app/src/main/java/com/zzliaoyuan/power_sensor/readUHF/ReadUHFModule.java

@@ -1,14 +1,12 @@
 package com.zzliaoyuan.power_sensor.readUHF;
 
 import android.content.Context;
-import android.util.Log;
 
+import com.facebook.react.bridge.Callback;
 import com.facebook.react.bridge.ReactApplicationContext;
 import com.facebook.react.bridge.ReactContextBaseJavaModule;
 import com.facebook.react.bridge.ReactMethod;
 import com.zzliaoyuan.power_sensor.fragment.UHFReadTagFragment;
-import com.zzliaoyuan.power_sensor.MainApplication;
-import com.facebook.react.bridge.Callback;
 
 public class ReadUHFModule extends ReactContextBaseJavaModule {
     Context context;

+ 0 - 1
android/app/src/main/java/com/zzliaoyuan/power_sensor/readUHF/ReadUHFPackage.java

@@ -4,7 +4,6 @@ import com.facebook.react.ReactPackage;
 import com.facebook.react.bridge.NativeModule;
 import com.facebook.react.bridge.ReactApplicationContext;
 import com.facebook.react.uimanager.ViewManager;
-import com.zzliaoyuan.power_sensor.readUHF.ReadUHFModule;
 
 import java.util.ArrayList;
 import java.util.Collections;

BIN
android/app/src/main/res/drawable-xxxhdpi/ic_launcher.png


+ 0 - 12
android/app/src/main/res/drawable/countdown_days.xml

@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<shape xmlns:android="http://schemas.android.com/apk/res/android"
-    android:shape="rectangle">
-    <!-- rectangle表示为矩形 -->
-
-    <!-- 填充的颜色 -->
-    <solid android:color="@color/colorPrimary" />
-
-    <!-- android:radius 圆角的半径 -->
-    <corners android:radius="5dp" />
-
-</shape>

+ 36 - 0
android/app/src/main/res/drawable/rn_edit_text_material.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+       android:insetLeft="@dimen/abc_edit_text_inset_horizontal_material"
+       android:insetRight="@dimen/abc_edit_text_inset_horizontal_material"
+       android:insetTop="@dimen/abc_edit_text_inset_top_material"
+       android:insetBottom="@dimen/abc_edit_text_inset_bottom_material">
+
+    <selector>
+        <!-- 
+          This file is a copy of abc_edit_text_material (https://bit.ly/3k8fX7I).
+          The item below with state_pressed="false" and state_focused="false" causes a NullPointerException.
+          NullPointerException:tempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)'
+
+          <item android:state_pressed="false" android:state_focused="false" android:drawable="@drawable/abc_textfield_default_mtrl_alpha"/>
+
+          For more info, see https://bit.ly/3CdLStv (react-native/pull/29452) and https://bit.ly/3nxOMoR.
+        -->
+        <item android:state_enabled="false" android:drawable="@drawable/abc_textfield_default_mtrl_alpha"/>
+        <item android:drawable="@drawable/abc_textfield_activated_mtrl_alpha"/>
+    </selector>
+
+</inset>

+ 0 - 8
android/app/src/main/res/layout/activity_jump.xml

@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:gravity="center"
-    android:orientation="vertical">
-
-</LinearLayout>

+ 0 - 6
android/app/src/main/res/layout/activity_live.xml

@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent" style="@style/LiveStyle">
-
-</LinearLayout>

+ 0 - 8
android/app/src/main/res/layout/activity_push.xml

@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="wrap_content"
-    android:layout_height="wrap_content"
-    android:gravity="center"
-    android:orientation="vertical">
-
-</LinearLayout>

+ 0 - 62
android/app/src/main/res/layout/notification_countdown.xml

@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="horizontal" android:layout_width="match_parent"
-    android:background="@color/colorWhite"
-    android:layout_height="90dp"
-    android:padding="10dp">
-    <LinearLayout
-        android:id="@+id/daysContainer"
-        android:orientation="horizontal"
-        android:layout_width="80dp"
-        android:padding="5dp"
-        android:background="@drawable/countdown_days"
-        android:layout_height="match_parent"
-        android:gravity="center"
-        android:layout_alignParentEnd="true">
-        <TextView
-            android:id="@+id/days"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:textAlignment="center"
-            android:textColor="@color/colorWhite"
-            android:textSize="30dp"/>
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:background="@drawable/countdown_days"
-            android:textAlignment="center"
-            android:textColor="@color/color_f5f5f5"
-            android:textSize="10dp"
-            android:layout_marginTop="10dp"
-            android:text="天"/>
-    </LinearLayout>
-    <LinearLayout
-        android:orientation="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:gravity="center_vertical"
-        android:layout_toLeftOf="@id/daysContainer">
-        <LinearLayout
-            android:orientation="horizontal"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content">
-            <TextView
-                android:id="@+id/name"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textSize="18dp"
-                android:textColor="@color/colorAccent"/>
-            <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:textSize="14dp"
-                android:textColor="@color/color_333333"
-                android:text=" 仅剩"/>
-        </LinearLayout>
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:textSize="15dp"
-            android:id="@+id/targetDate"/>
-    </LinearLayout>
-</RelativeLayout>

+ 0 - 15
android/app/src/main/res/values/colors.xml

@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-    <color name="colorPrimary">#03C762</color>
-    <color name="colorPrimaryDark">#03C762</color>
-    <color name="colorAccent">#03C762</color>
-    <color name="colorWhite">#FFFFFF</color>
-    <color name="colorTip">#F44336</color>
-
-    <color name="color_f5f5f5">#f5f5f5</color>
-    <color name="color_666666">#666666</color>
-    <color name="color_333333">#333333</color>
-    <color name="color_212121">#212121</color>
-    <color name="color_757575">#757575</color>
-    <color name="color_aaaaaa">#aaaaaa</color>
-</resources>

+ 2 - 13
android/app/src/main/res/values/styles.xml

@@ -1,20 +1,9 @@
 <resources>
 
     <!-- Base application theme. -->
-    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
+    <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
         <!-- Customize your theme here. -->
+        <item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
     </style>
 
-    <style name="FullScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
-        <item name="android:windowFullscreen">true</item>
-        <item name="android:windowNoTitle">true</item>
-    </style>
-    <style name="LiveStyle">
-        <item name="android:windowBackground">@android:color/transparent</item>
-        <!--<item name="android:windowBackground">@color/colorPrimaryDark</item>-->
-        <item name="android:windowContentOverlay">@null</item>
-        <item name="android:windowIsTranslucent">true</item>
-        <item name="android:windowNoDisplay">false</item>
-        <item name="android:windowDisablePreview">true</item>
-    </style>
 </resources>

+ 4 - 0
android/app/src/main/res/xml/network_security_config.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<network-security-config>
+    <base-config cleartextTrafficPermitted="true" />
+</network-security-config>

+ 17 - 15
android/build.gradle

@@ -2,19 +2,19 @@
 
 buildscript {
     ext {
-        buildToolsVersion = "29.0.1"
-        minSdkVersion = 19
-        compileSdkVersion = 29
-        targetSdkVersion = 29
-        androidXCore = "1.0.2"
+        buildToolsVersion = "30.0.2"
+        minSdkVersion = 21
+        compileSdkVersion = 31
+        targetSdkVersion = 31
+        ndkVersion = "21.4.7075529"
     }
     repositories {
+        // maven{ url = "https://maven.aliyun.com/repository/public/" }
         google()
-        jcenter()
+        mavenCentral()
     }
     dependencies {
-        classpath("com.android.tools.build:gradle:3.4.2")
-
+        classpath("com.android.tools.build:gradle:4.2.2")
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
     }
@@ -22,7 +22,7 @@ buildscript {
 
 allprojects {
     repositories {
-        mavenLocal()
+        //maven{ url = "https://maven.aliyun.com/repository/public/" }
         maven {
             // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
             url("$rootDir/../node_modules/react-native/android")
@@ -31,12 +31,14 @@ allprojects {
             // Android JSC is installed from npm
             url("$rootDir/../node_modules/jsc-android/dist")
         }
-
+        mavenCentral {
+            // We don't want to fetch react-native from Maven Central as there are
+            // older versions over there.
+            content {
+                excludeGroup "com.facebook.react"
+            }
+        }
         google()
-        jcenter()
-        maven { url 'https://jitpack.io' }
-        maven { url "http://dl.bintray.com/lukaville/maven" }
-        maven { url 'https://dl.bintray.com/umsdk/release' }
-
+        maven { url 'https://www.jitpack.io' }
     }
 }

+ 14 - 3
android/gradle.properties

@@ -9,14 +9,25 @@
 
 # Specifies the JVM arguments used for the daemon process.
 # The setting is particularly useful for tweaking memory settings.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
+# Default value: -Xmx1024m -XX:MaxPermSize=256m
 # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
+org.gradle.jvmargs=-Xmx1024m
 # When configured, Gradle will run in incubating parallel mode.
 # This option should only be used with decoupled projects. More details, visit
 # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
 # org.gradle.parallel=true
 
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app's APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
 android.useAndroidX=true
+# Automatically convert third-party libraries to use AndroidX
 android.enableJetifier=true
-android.injected.testOnly=false
+
+# Version of flipper SDK to use with React Native
+FLIPPER_VERSION=0.99.0
+
+MYAPP_RELEASE_STORE_FILE=examwin.keystore
+MYAPP_RELEASE_KEY_ALIAS=examwin
+MYAPP_RELEASE_STORE_PASSWORD=zzly508
+MYAPP_RELEASE_KEY_PASSWORD=zzly508

BIN
android/gradle/wrapper/gradle-wrapper.jar


+ 1 - 1
android/gradle/wrapper/gradle-wrapper.properties

@@ -1,5 +1,5 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists

+ 17 - 20
android/gradlew

@@ -7,7 +7,7 @@
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
 #
-#      http://www.apache.org/licenses/LICENSE-2.0
+#      https://www.apache.org/licenses/LICENSE-2.0
 #
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
@@ -82,6 +82,7 @@ esac
 
 CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
 
+
 # Determine the Java command to use to start the JVM.
 if [ -n "$JAVA_HOME" ] ; then
     if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -125,10 +126,11 @@ if $darwin; then
     GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
 fi
 
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
     APP_HOME=`cygpath --path --mixed "$APP_HOME"`
     CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
     JAVACMD=`cygpath --unix "$JAVACMD"`
 
     # We build the pattern for arguments to be converted via cygpath
@@ -154,19 +156,19 @@ if $cygwin ; then
         else
             eval `echo args$i`="\"$arg\""
         fi
-        i=$((i+1))
+        i=`expr $i + 1`
     done
     case $i in
-        (0) set -- ;;
-        (1) set -- "$args0" ;;
-        (2) set -- "$args0" "$args1" ;;
-        (3) set -- "$args0" "$args1" "$args2" ;;
-        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
-        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
-        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
-        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
-        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
-        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+        0) set -- ;;
+        1) set -- "$args0" ;;
+        2) set -- "$args0" "$args1" ;;
+        3) set -- "$args0" "$args1" "$args2" ;;
+        4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
     esac
 fi
 
@@ -175,14 +177,9 @@ save () {
     for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
     echo " "
 }
-APP_ARGS=$(save "$@")
+APP_ARGS=`save "$@"`
 
 # Collect all arguments for the java command, following the shell quoting and substitution rules
 eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
 
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
-  cd "$(dirname "$0")"
-fi
-
 exec "$JAVACMD" "$@"

+ 8 - 19
android/gradlew.bat

@@ -5,7 +5,7 @@
 @rem you may not use this file except in compliance with the License.
 @rem You may obtain a copy of the License at
 @rem
-@rem      http://www.apache.org/licenses/LICENSE-2.0
+@rem      https://www.apache.org/licenses/LICENSE-2.0
 @rem
 @rem Unless required by applicable law or agreed to in writing, software
 @rem distributed under the License is distributed on an "AS IS" BASIS,
@@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
 set APP_BASE_NAME=%~n0
 set APP_HOME=%DIRNAME%
 
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
 @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
 set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
 
@@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
 
 set JAVA_EXE=java.exe
 %JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if "%ERRORLEVEL%" == "0" goto execute
 
 echo.
 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -51,7 +54,7 @@ goto fail
 set JAVA_HOME=%JAVA_HOME:"=%
 set JAVA_EXE=%JAVA_HOME%/bin/java.exe
 
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
 
 echo.
 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -61,28 +64,14 @@ echo location of your Java installation.
 
 goto fail
 
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
 :execute
 @rem Setup the command line
 
 set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
 
+
 @rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
 
 :end
 @rem End local scope for the variables with windows NT shell

+ 0 - 2
android/settings.gradle

@@ -1,5 +1,3 @@
 rootProject.name = 'power_sensor'
-//include ':react-native-gesture-handler'
-//project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
 apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
 include ':app'

+ 3 - 0
babel.config.js

@@ -0,0 +1,3 @@
+module.exports = {
+  presets: ['module:metro-react-native-babel-preset'],
+};

+ 1 - 5
index.js

@@ -3,13 +3,9 @@
  */
 
 import {AppRegistry} from 'react-native';
-import SyncStorage from 'sync-storage';
+// import AsyncStorage from '@react-native-async-storage/async-storage';
 
 import App from './jscore/App';
 import {name as appName} from './app.json';
 
-// SyncStorage.set('baseURL','http://demo.zzliaoyuan.com');
-SyncStorage.set('baseURL','http://ykx.zzly.vip');
-// SyncStorage.set('baseURL','http://192.168.2.45:8888');
-
 AppRegistry.registerComponent(appName, () => App);

+ 0 - 1
ios.sh

@@ -1 +0,0 @@
-node node_modules/react-native/local-cli/cli.js bundle --entry-file index.ios.js  --platform ios --dev false --bundle-output ./ios/bundle/index.ios.jsbundle --assets-dest ./ios/bundle

+ 8 - 8
jscore/App.js

@@ -1,16 +1,16 @@
-import React from 'react'
-
-import dva from './utils/dva'
-import Router, {routerMiddleware, routerReducer} from './router'
+import React from 'react';
+import dva from './utils/dva';
+import Router from './router';
 
 const app = dva({
     initialState: {},
     models: [],
-    extraReducers: {router: routerReducer},
-    onAction: [routerMiddleware],
+    // extraReducers: {router: routerReducer},
+    // onAction: [routerMiddleware],
     onError(e) {
-        console.log('onError', e)
+        console.log('onError', e);
     },
-})
+});
+
 const App = app.start(<Router/>);
 export default App;

+ 37 - 35
jscore/pages/Desktop/Home.js

@@ -3,7 +3,8 @@ import {StyleSheet, View, Text, DeviceEventEmitter, ScrollView, TouchableOpacity
 import {Button} from '@ant-design/react-native';
 import ReadUHF from "../../utils/ReadUHF";
 import Barcode from "react-native-barcode-builder";
-import SyncStorage from "sync-storage";
+// import SyncStorage from "sync-storage";
+import {SyncStorage} from '../../utils';
 
 let screenW = Dimensions.get('window').width;
 
@@ -12,7 +13,7 @@ class DesktopHome extends Component {
         super(props);
         this.state = {
             data: [],
-            userData: [],
+            userData: [], //防止重复扫描
             no_begin: '8',
             no_length: '14',
             error: 0,
@@ -21,42 +22,44 @@ class DesktopHome extends Component {
         };
     }
 
-    static navigationOptions = ({navigation}) => {
-        return {
-            headerRight: (
-                <TouchableOpacity onPress={() => navigation.navigate("setPower")}>
-                    <Text style={{
-                        // fontSize: 22,
-                        color: '#fff',
-                        marginRight: 10
-                    }}>设置</Text>
-
-                </TouchableOpacity>
-            )
-        };
+    static navigationOptions = {
+        headerRight: () => (
+            <Text
+                onPress={() => DeviceEventEmitter.emit('onSet')}
+                style={{
+                    fontSize: 18,
+                    color: '#fff',
+                    // marginRight: 5,
+                }}>设置</Text>
+        ),
     };
 
-    componentDidMount() {
+    async componentDidMount() {
         // ReadUHF.changeFlag(0)
+        DeviceEventEmitter.addListener('onSet', (param) => {
+            this.props.navigation.navigate("SetPower")
+        });
         DeviceEventEmitter.addListener('MsgFromAndroid', this._addCode);
         DeviceEventEmitter.addListener('onKeyDown', this.onKeyDown);
-        const show_type = SyncStorage.get('show_type')
-        if (show_type === undefined) {
-            SyncStorage.set('show_type', true)
+        const show_type = await SyncStorage.get('show_type')
+        if (show_type === null) {
+            SyncStorage.set('show_type', '1')
         }
+        const zuhe_temp = await SyncStorage.get('zuhe_temp');
+        this.setState({zuhe_temp});
     }
 
-    _addCode = (item) => {
+    _addCode = async (item) => {
         const str = JSON.parse(item)
         // 防止重复扫描
-        const show_type = SyncStorage.get('show_type')
+        const show_type =  await SyncStorage.get('show_type') // ?? '1'
         let {data, userData, error} = this.state;
         const product_index = userData.indexOf(str['userData'])
         if (product_index < 0) {
-            // 只显示本类别
-            if (show_type) {
+            // 只显示本类别,不显示错误信息
+            if (show_type == '1') {
                 // 且没有错误
-                if (!str['error']) {
+                if (str['error'] == 0) {
                     userData.push(str['userData'])
                     data.unshift(str)
                 }
@@ -72,9 +75,9 @@ class DesktopHome extends Component {
         }
     }
 
-    _start = () => {
-        const no_begin = SyncStorage.get('no_begin')
-        const no_length = SyncStorage.get('no_length')
+    _start = async () => {
+        const no_begin = await SyncStorage.get('no_begin')
+        const no_length = await SyncStorage.get('no_length')
         if (no_begin && no_begin) {
             this.setState({no_begin, no_length})
         }
@@ -85,9 +88,9 @@ class DesktopHome extends Component {
     _clear = () => {
         this.setState({userData: [], data: [], error: 0})
     }
-    onKeyDown = () => {
-        const no_begin = SyncStorage.get('no_begin')
-        const no_length = SyncStorage.get('no_length')
+    onKeyDown = async () => {
+        const no_begin = await SyncStorage.get('no_begin')
+        const no_length = await SyncStorage.get('no_length')
         if (no_begin && no_begin) {
             this.setState({no_begin, no_length})
         }
@@ -108,7 +111,7 @@ class DesktopHome extends Component {
         }
         return (
             <View
-                key={index}
+                key={item.userData}
                 style={styles.mainView}
             >
                 <Text style={styles.textColor}>计量{item.kind}</Text>
@@ -196,7 +199,7 @@ class DesktopHome extends Component {
         }
         return (
             <View
-                key={index}
+                key={item.userData}
                 style={styles.mainView}
             >
                 <Text style={styles.textColor}>计量{item.kind}</Text>
@@ -283,9 +286,8 @@ class DesktopHome extends Component {
     }
 
     render() {
-        let {isStart} = this.state;
+        let {isStart, zuhe_temp} = this.state;
         const start_text = isStart ? '开始识别' : '停止识别'
-        const show_type = SyncStorage.get('zuhe_temp')
         return (
             <View style={styles.container}>
                 <ScrollView style={styles.container}>
@@ -302,7 +304,7 @@ class DesktopHome extends Component {
                             }
                             else {
                                 // 组合互感器,没有设置,默认用电压模板
-                                if(show_type === '2'){
+                                if (zuhe_temp === '2') {
                                     return this.dianLiuRender(item, index)
                                 } else {
                                     return this.dianYaRender(item, index)

+ 425 - 0
jscore/pages/Desktop/Home2.js

@@ -0,0 +1,425 @@
+import React, {Component} from 'react';
+import {StyleSheet, View, Text, DeviceEventEmitter, ScrollView, TouchableOpacity, Dimensions} from 'react-native';
+import {Button} from '@ant-design/react-native';
+import ReadUHF from '../../utils/ReadUHF';
+import Barcode from 'react-native-barcode-builder';
+// import SyncStorage from "sync-storage";
+import {SyncStorage} from '../../utils';
+
+let screenW = Dimensions.get('window').width;
+let lastBackPressed = 0;
+
+class DesktopHome2 extends Component {
+    constructor(props) {
+        super(props);
+        this.state = {
+            data: [],
+            userData: [],
+            no_begin: '8',
+            no_length: '14',
+            zuhe_temp: '1',
+            error: 0,
+            isStart: true,
+            timerID: [],
+        };
+    }
+
+    static navigationOptions = {
+        headerRight: () => (
+            <Text
+                onPress={() => DeviceEventEmitter.emit('onSet')}
+                style={{
+                    fontSize: 18,
+                    color: '#fff',
+                    // marginRight: 5,
+                }}>设置</Text>
+        ),
+    };
+
+    async componentDidMount() {
+        // ReadUHF.changeFlag(0)
+        DeviceEventEmitter.addListener('onSet', (param) => {
+            this.props.navigation.navigate("SetPower")
+        });
+        DeviceEventEmitter.addListener('MsgFromAndroid', this._addCode);
+        DeviceEventEmitter.addListener('onKeyDown', this.onKeyDown);
+        const show_type = await SyncStorage.get('show_type');
+        if (show_type === undefined) {
+            SyncStorage.set('show_type', '1');
+        }
+        const zuhe_temp = await SyncStorage.get('zuhe_temp');
+        this.setState({zuhe_temp});
+    }
+
+    _addCode = async (item) => {
+        const str = JSON.parse(item);
+        // 防止重复扫描
+        const show_type = await SyncStorage.get('show_type') ?? '1';
+        let {data, userData, error} = this.state;
+        const product_index = userData.indexOf(str['userData']);
+        console.log(66666666, product_index, show_type, str['error'], str['error_msg'])
+        if (product_index < 0) {
+            // 只显示本类别 不显示错误信息
+            if (show_type == '1') {
+                // 且没有错误
+                console.log('000kkk')
+                if (str['error'] == '0') {
+                    userData.push(str['userData']);
+                    data.unshift(str);
+                }
+            } else {
+                // 全部都显示
+                console.log('eeerrr')
+                if (str['error']) {
+                    error += 1;
+                }
+                userData.push(str['userData']);
+                data.unshift(str);
+            }
+            console.log(7777777, data)
+            console.log(8888888, error)
+            console.log(8888888, userData)
+            this.setState({data, userData, error});
+        }
+    };
+
+    _start = async () => {
+        const no_begin = await SyncStorage.get('no_begin');
+        const no_length = await SyncStorage.get('no_length');
+        if (no_begin && no_begin) {
+            this.setState({no_begin, no_length});
+        }
+        let {isStart} = this.state;
+        ReadUHF.doRead();
+        this.setState({isStart: !isStart});
+    };
+    _clear = () => {
+        this.setState({userData: [], data: [], error: 0});
+    };
+    onKeyDown = async () => {
+        const no_begin = await SyncStorage.get('no_begin');
+        const no_length = await SyncStorage.get('no_length');
+        if (no_begin && no_begin) {
+            this.setState({no_begin, no_length});
+        }
+        let {isStart} = this.state;
+        this.setState({isStart: !isStart});
+    };
+
+    dianYaRender = (item, index) => {
+        const assetID = item.assetID.slice(parseInt(this.state.no_begin) - 1, parseInt(this.state.no_begin) + parseInt(this.state.no_length) - 1);
+        const releaseDates = item.releaseDate.split('-');
+        const releaseDate = releaseDates[0] + '年' + releaseDates[1] + '月';
+        let districtText = '';
+        if (parseInt(item.district) > 10000) {
+            districtText = item.districtText;
+        } else {
+            const len1 = item.districtText.split('-')[1].length;
+            districtText = '国网' + item.districtText.split('-')[1].slice(0, len1 - 1) + '电力';
+        }
+        return (
+            <View
+                key={index}
+                style={styles.mainView}
+            >
+                <Text style={styles.textColor}>计量{item.kind}</Text>
+                <View style={styles.betweenView}>
+                    <Text style={styles.textColor3}>型号:{item.model}</Text>
+                    <View style={styles.centerWidth}>
+                        <Text style={styles.textColor3}>电压等级:{item.voltageLevel}kV</Text>
+                    </View>
+                    <Text style={styles.textColor3}>绕组数量:{item.secondWindingCount}</Text>
+                </View>
+                <View style={styles.betweenView}>
+                    <Text style={styles.textColor4}>二次电压</Text>
+                    <View style={styles.centerWidth}>
+                        <Text style={styles.textColor4}>准确等级</Text>
+                    </View>
+                    <View style={styles.rightWidth}>
+                        <Text style={styles.textColor4}>功率因数</Text>
+                    </View>
+                    <Text style={styles.textColor4}>生产日期</Text>
+                </View>
+                <View style={styles.betweenView}>
+                    <View style={styles.centerView}>
+                        <Text style={styles.textColor4}>{item.secondVoltage}kV</Text>
+                    </View>
+                    <View style={styles.centerWidth}>
+                        <Text style={styles.textColor4}>{item.accuracy}</Text>
+                    </View>
+                    <View style={styles.rightWidth}>
+                        <Text style={styles.textColor4}>{item.powerFactor}</Text>
+                    </View>
+                    <View style={styles.centerView}>
+                        <Text style={styles.textColor4}>{releaseDate}</Text>
+                    </View>
+                </View>
+                <View style={styles.betweenView}>
+                    <Text style={styles.textColor3}>安装场所:{item.place}</Text>
+                    <View style={styles.centerWidth}>
+                        <Text style={styles.textColor3}>额定负荷:{item.ratedLoad}VA</Text>
+                    </View>
+                    <Text style={styles.textColor3}>电压因数:{item.voltageFactor}</Text>
+                </View>
+                <View style={styles.betweenView}>
+                    <View style={styles.centerView}>
+                        <Text style={styles.textColor3}>{item.manufacturer}</Text>
+                    </View>
+                    <View style={{
+                        width: (screenW - 10) / 3 * 2,
+                        borderLeftWidth: 0.5,
+                        borderLeftColor: '#7b7b7b',
+                    }}>
+                        <View style={{
+                            flexDirection: 'row',
+                            marginHorizontal: 3,
+                        }}>
+                            <View style={{
+                                flex: 1,
+                            }}>
+                                <Text style={[styles.textColor, {textAlign: 'left'}]}>{districtText}</Text>
+                            </View>
+                            <Text style={[styles.textColor, {textAlign: 'right', paddingRight: 5}]}>NO.{assetID}</Text>
+                        </View>
+                        <View style={{
+                            marginHorizontal: 5,
+                        }}>
+                            <Barcode value={item.assetID} format="CODE128" height={35} width={1.1}/>
+                            <Text style={styles.textColor}>{item.assetID}</Text>
+                        </View>
+                    </View>
+                </View>
+
+            </View>
+        );
+    };
+
+    dianLiuRender = (item, index) => {
+        const assetID = item.assetID.slice(parseInt(this.state.no_begin) - 1, parseInt(this.state.no_begin) + parseInt(this.state.no_length) - 1);
+        const releaseDates = item.releaseDate.split('-');
+        const releaseDate = releaseDates[0] + '年' + releaseDates[1] + '月';
+        let districtText = '';
+        if (parseInt(item.district) > 10000) {
+            districtText = item.districtText;
+        } else {
+            const len1 = item.districtText.split('-')[1].length;
+            districtText = '国网' + item.districtText.split('-')[1].slice(0, len1 - 1) + '电力';
+        }
+        return (
+            <View
+                key={index}
+                style={styles.mainView}
+            >
+                <Text style={styles.textColor}>计量{item.kind}</Text>
+                <View style={styles.betweenView}>
+                    <Text style={styles.textColor3}>型号:{item.model}</Text>
+                    <View style={styles.centerWidth}>
+                        <Text style={styles.textColor3}>电压等级:{item.voltageLevel}kV</Text>
+                    </View>
+                    <Text style={styles.textColor3}>绕组数量:{item.secondWindingCount}</Text>
+                </View>
+                <View style={styles.betweenView}>
+                    <Text style={styles.textColor4}>一次电流</Text>
+                    <View style={styles.centerWidth}>
+                        <Text style={styles.textColor4}>二次电流</Text>
+                    </View>
+                    <View style={styles.rightWidth}>
+                        <Text style={styles.textColor4}>功率因数</Text>
+                    </View>
+                    <Text style={styles.textColor4}>生产日期</Text>
+                </View>
+                <View style={styles.betweenView}>
+                    <View style={styles.centerView}>
+                        <Text style={styles.textColor4}>{item.firstCurrent}A</Text>
+                    </View>
+                    <View style={styles.centerWidth}>
+                        <Text style={styles.textColor4}>{item.senondCurrent}A</Text>
+                    </View>
+                    <View style={styles.rightWidth}>
+                        <Text style={styles.textColor4}>{item.powerFactor}</Text>
+                    </View>
+                    <View style={styles.centerView}>
+                        <Text style={styles.textColor4}>{releaseDate}</Text>
+                    </View>
+                </View>
+                <View style={styles.betweenView}>
+                    <Text style={styles.textColor3}>安装场所:{item.place}</Text>
+                    <View style={styles.centerWidth}>
+                        <Text style={styles.textColor3}>额定负荷:{item.ratedLoad}VA</Text>
+                    </View>
+                    <Text style={styles.textColor3}>准确等级:{item.accuracy}</Text>
+                </View>
+                <View style={styles.betweenView}>
+                    <View style={styles.centerView}>
+                        <Text style={styles.textColor3}>{item.manufacturer}</Text>
+                    </View>
+                    <View style={{
+                        width: (screenW - 10) / 3 * 2,
+                        borderLeftWidth: 0.5,
+                        borderLeftColor: '#7b7b7b',
+                    }}>
+                        <View style={{
+                            flexDirection: 'row',
+                            marginHorizontal: 3,
+                        }}>
+                            <View style={{
+                                flex: 1,
+                            }}>
+                                <Text style={[styles.textColor, {textAlign: 'left'}]}>{districtText}</Text>
+                            </View>
+                            <Text style={[styles.textColor, {textAlign: 'right', paddingRight: 5}]}>NO.{assetID}</Text>
+                        </View>
+                        <View style={{
+                            marginHorizontal: 5,
+                        }}>
+                            <Barcode value={item.assetID} format="CODE128" height={35} width={1.1}/>
+                            <Text style={styles.textColor}>{item.assetID}</Text>
+                        </View>
+                    </View>
+                </View>
+
+            </View>
+        );
+    };
+
+    errorRender = (item, index) => {
+        return (
+            <View
+                key={index}
+                style={[styles.mainView, {padding: 10}]}
+            >
+                <Text style={{color: 'red'}}>{item.error_msg}</Text>
+            </View>
+        );
+    };
+
+    render() {
+        let {isStart, zuhe_temp} = this.state;
+        const start_text = isStart ? '开始识别' : '停止识别';
+        return (
+            <View style={styles.container}>
+                <ScrollView style={styles.container}>
+                    {
+                        this.state.data.map((item, index) => {
+                            if (item.error) {
+                                return this.errorRender(item, index);
+                            }
+                            else if (item.kind.indexOf('电压') > -1) {
+                                return this.dianYaRender(item, index);
+                            }
+                            else if (item.kind.indexOf('电流') > -1) {
+                                return this.dianLiuRender(item, index);
+                            }
+                            else {
+                                // 组合互感器,没有设置,默认用电压模板
+                                if (zuhe_temp === '2') {
+                                    return this.dianLiuRender(item, index);
+                                } else {
+                                    return this.dianYaRender(item, index);
+                                }
+                            }
+
+                        })
+                    }
+                </ScrollView>
+                <Text
+                    style={{marginLeft: 10, color: '#f77b22'}}>合计:{this.state.data.length} 失败:{this.state.error}</Text>
+                <View style={{flexDirection: 'row'}}>
+                    <Button onPress={() => this._start()}
+                            type="primary"
+                            style={[styles.button, {
+                                backgroundColor: isStart ? '#0099FF' : 'red',
+                                width: '65%',
+                            }]}
+                    >
+                        <Text style={{color: '#fff'}}>
+                            {start_text}
+                        </Text>
+                    </Button>
+                    <Button onPress={() => this._clear()}
+                            type="warning"
+                            style={{
+                                width: '25%',
+                                borderRadius: 5,
+                                marginHorizontal: 10,
+                                marginTop: 5,
+                                marginBottom: 2,
+                                borderWidth: 0,
+                                backgroundColor: '#de7642',
+                            }}
+                    >
+                        <Text style={{color: '#fff'}}>
+                            清除
+                        </Text>
+                    </Button>
+                </View>
+            </View>
+        );
+    }
+}
+
+const styles = StyleSheet.create({
+    container: {
+        flex: 1,
+    },
+    button: {
+        borderRadius: 5,
+        marginHorizontal: 10,
+        marginBottom: 2,
+        marginTop: 5,
+        borderWidth: 0,
+        backgroundColor: '#2b90ea',
+    },
+    textColor: {
+        color: '#333',
+        textAlign: 'center',
+    },
+    textColor3: {
+        color: '#333',
+        textAlign: 'center',
+        width: (screenW - 9) / 3,
+
+    },
+    textColor4: {
+        color: '#333',
+        textAlign: 'center',
+        width: (screenW - 8) / 4,
+
+    },
+    textColor2: {
+        color: '#333',
+        textAlign: 'center',
+        width: (screenW - 10) / 2,
+    },
+    mainView: {
+        margin: 5,
+        borderWidth: 0.5,
+        borderColor: '#7b7b7b',
+    },
+    betweenView: {
+        flexDirection: 'row',
+        justifyContent: 'space-between',
+        borderTopWidth: 0.5,
+        borderTopColor: '#7b7b7b',
+    },
+    centerWidth: {
+        borderLeftWidth: 0.5,
+        borderRightWidth: 0.5,
+        borderLeftColor: '#7b7b7b',
+        borderRightColor: '#7b7b7b',
+        alignItems: 'center',
+        flexDirection: 'row',
+    },
+    centerView: {
+        alignItems: 'center',
+        flexDirection: 'row',
+    },
+    rightWidth: {
+        borderRightWidth: 0.5,
+        borderRightColor: '#7b7b7b',
+        alignItems: 'center',
+        flexDirection: 'row',
+    },
+});
+
+export default DesktopHome2;

+ 13 - 54
jscore/pages/Desktop/Index.js

@@ -1,63 +1,22 @@
 'use strict'
-import React, { Component } from 'react'
-import { Platform } from 'react-native'
-import { createStackNavigator } from 'react-navigation'
+import React  from 'react'
 
 import DesktopHome from './Home'
-import setPower from './setPower'
+import SetPower from './Set'
 
-const TITLE_OFFSET = Platform.OS === 'ios' ? 70 : 56;
-
-const HomeStack = createStackNavigator({
-    DesktopHome: {
-        screen: DesktopHome,
-        navigationOptions: {
-            title: '电金睛'
-        },
-    },
-    setPower: {
-        screen: setPower,
-        navigationOptions: {
-            title: '设置'
-        },
-    },
-},
-{
-    defaultNavigationOptions: {
-        headerStyle: {
-            backgroundColor: "#5394e4",
-            borderBottomWidth: 0,
-            borderColor: '#ccc',
-            fontColor: '#fff',
-            elevation: 0,
-            height: 40
-        },
-        headerTintColor: '#ffffff',
-        headerTitleStyle: {
-            fontWeight: 'normal',
-            fontSize: 18,
-            color: '#ffffff',
-            alignSelf:'center',
-            textAlign: 'center',
-            flex:1
+const HomeStack = {
+        DesktopHome: {
+            screen: DesktopHome,
+            navigationOptions: {
+                title: '电金睛',
+            }
         },
-        headerTitleContainerStyle:{
-            left: TITLE_OFFSET,
-            right: TITLE_OFFSET,
+        SetPower: {
+            screen: SetPower,
+            navigationOptions: {
+                title: '设置',
+            }
         },
-        headerBackTitle: null         // ~注意~ 这个地方是隐藏返回按钮文字的
     }
-})
-
-HomeStack.navigationOptions = ({ navigation }) => {  // ~注意~ 如果想实现隐藏Tabbar的功能要调用这个方法
-    let tabBarVisible = true
-    if (navigation.state.index > 0) {
-        tabBarVisible = false
-    }
-    return {
-        tabBarVisible
-    }
-}
-
 
 module.exports = HomeStack

+ 22 - 16
jscore/pages/Desktop/setPower.js → jscore/pages/Desktop/Set.js

@@ -2,43 +2,49 @@ import React, {Component} from 'react';
 import {Text, TouchableOpacity, View, TextInput, StyleSheet} from 'react-native';
 import {Button, Slider, Provider, Toast,} from "@ant-design/react-native";
 import ReadUHF from "../../utils/ReadUHF";
-import SyncStorage from "sync-storage";
+// import SyncStorage from "sync-storage";
+import {SyncStorage} from "../../utils";
 import ComponentsStyles from "../../components/ComponentsStyles";
 import RadioModal from "../../components/RadioModal";
 
-class setPower extends Component {
+class SetPower extends Component {
     constructor(props) {
         super(props);
-        let zuhe_temp = SyncStorage.get('zuhe_temp')
-        zuhe_temp = zuhe_temp ? zuhe_temp.toString() : '1'
         this.state = {
             power: 30,
             no_begin: '8',
             no_length: '14',
-            show_type: true,
-            zuhe_temp: zuhe_temp,
+            show_type: '1',
+            zuhe_temp: '1',
         };
     }
 
-    componentDidMount() {
+    async componentDidMount() {
         ReadUHF.getPower((ver) => {
             this.setState({
                 power: parseInt(ver)
             })
         });
-        const no_begin = SyncStorage.get('no_begin')
-        const no_length = SyncStorage.get('no_length')
+        const no_begin = await SyncStorage.get('no_begin')
+        const no_length = await SyncStorage.get('no_length')
         if (no_begin && no_begin) {
             this.setState({no_begin, no_length})
         }
-        const show_type = SyncStorage.get('show_type')
-        this.setState({show_type})
+        let show_type = await SyncStorage.get('show_type')
+        let zuhe_temp = await SyncStorage.get('zuhe_temp')
+        zuhe_temp = zuhe_temp ? zuhe_temp.toString() : '1'
+        show_type = show_type ? show_type.toString() : '1'
+        this.setState({zuhe_temp, show_type})
     }
 
     onTypeChange = () => {
-        this.setState({show_type: !this.state.show_type})
+        if (this.state.show_type == '1') {
+            this.setState({show_type: '0'})
+        } else {
+            this.setState({show_type: '1'})
+        }
     }
-    _savePower = () => {
+    _savePower = async () => {
         let {no_begin, no_length, show_type, zuhe_temp} = this.state;
         no_begin = parseInt(no_begin)
         no_length = parseInt(no_length)
@@ -106,7 +112,7 @@ class setPower extends Component {
                                 marginHorizontal: 3,
                                 flexDirection: 'row',
                             }}>
-                            {this.state.show_type ?
+                            {this.state.show_type === '1' ?
                                 <Text style={{
                                     borderWidth: 1,
                                     width: 18,
@@ -123,7 +129,7 @@ class setPower extends Component {
                             }<Text style={styles.font14}> 只显示本类别芯片</Text>
                         </TouchableOpacity>
                     </View>
-                    <View style={{marginTop: 10, flexDirection:'row'}}>
+                    <View style={{marginTop: 10, flexDirection: 'row'}}>
                         <View style={styles.titleCenter}>
                             <Text style={styles.font14}>组合互感器模板:</Text>
                         </View>
@@ -173,4 +179,4 @@ const styles = StyleSheet.create({
         justifyContent: 'center',
     },
 })
-export default setPower
+export default SetPower

+ 8 - 9
jscore/pages/Welcome.js

@@ -1,6 +1,5 @@
 import React, {Component} from 'react'
 import {StyleSheet, View, Text, Image} from 'react-native'
-import SyncStorage from 'sync-storage';
 import {connect} from 'react-redux'
 import {NavigationActions, StackActions, ScreenUtil} from '../utils'
 import {ComponentsStyles} from '../components'
@@ -13,16 +12,16 @@ class Welcome extends Component {
 
     componentDidMount() {
         const {navigation} = this.props;
-
-        const resetAction = NavigationActions.navigate({
-            routeName: "DesktopHome",
-            actions: [NavigationActions.navigate({routeName: 'DesktopHome'})],
-        })
+        // const resetAction = NavigationActions.navigate({
+        //     routeName: "DesktopHome",
+        //     actions: [NavigationActions.navigate({routeName: 'DesktopHome'})],
+        // })
         this.timer = setTimeout(
             () => {
-                navigation.dispatch(resetAction);
+                // navigation.dispatch(resetAction);
+                navigation.navigate('DesktopHome');
             },
-            2000
+            1000
         );
     }
 
@@ -38,7 +37,7 @@ class Welcome extends Component {
                     <Text style={styles.title}>电金睛</Text>
                 </View>
                 <View style={styles.down}>
-                    <Text style={styles.rights}>©2021 郑州市凯贝特互感器有限公司 All rights reserved.</Text>
+                    <Text style={styles.rights}>©2023 郑州市凯贝特互感器有限公司 All rights reserved.</Text>
                 </View>
             </View>
         )

+ 0 - 66
jscore/root.js

@@ -1,66 +0,0 @@
-import React from 'react';
-import {
-    Animated,
-    Easing,
-    StyleSheet,
-} from 'react-native';
-import {
-    createAppContainer, createStackNavigator,
-} from 'react-navigation';
-
-import Welcome from './pages/Welcome';
-import HomePage from './pages/Desktop/Index';
-
-const styles = StyleSheet.create({
-    iconFont: {
-        fontFamily: 'iconfont',
-        fontSize: 24,
-        color: '#757575'
-    },
-    iconFontFocused: {
-        fontFamily: 'iconfont',
-        fontSize: 24,
-        color: '#2b90ea'
-    }
-})
-
-const AppNavigator = createStackNavigator(
-    {
-        Welcome: {screen: Welcome},
-        Main: {screen: HomePage},
-    },
-    {
-        headerMode: 'none',
-        mode: 'modal',
-        navigationOptions: {
-            gesturesEnabled: false,
-        },
-        transitionConfig: () => ({
-            transitionSpec: {
-                duration: 300,
-                easing: Easing.out(Easing.poly(4)),
-                timing: Animated.timing,
-            },
-            screenInterpolator: sceneProps => {
-                const {layout, position, scene} = sceneProps
-                const {index} = scene
-
-                const height = layout.initHeight
-                const translateY = position.interpolate({
-                    inputRange: [index - 1, index, index + 1],
-                    outputRange: [height, 0, 0],
-                })
-
-                const opacity = position.interpolate({
-                    inputRange: [index - 1, index - 0.99, index],
-                    outputRange: [0, 1, 1],
-                })
-
-                return {opacity, transform: [{translateY}]}
-            },
-        }),
-    }
-);
-export const RootNavigator = createAppContainer(AppNavigator);
-
-export default RootNavigator;

+ 91 - 61
jscore/router.js

@@ -1,79 +1,109 @@
 import React from 'react';
-import {
-    ToastAndroid,
-    BackHandler,
-    DeviceEventEmitter,
-    Platform
-} from 'react-native';
+import {NavigationContainer} from '@react-navigation/native';
+import {Platform, Text, BackHandler, ToastAndroid, StyleSheet} from 'react-native';
 import {connect} from 'react-redux';
-import {
-    createReduxContainer,
-    createReactNavigationReduxMiddleware,
-    createNavigationReducer,
-} from 'react-navigation-redux-helpers';
-import {
-    NavigationActions,
-} from 'react-navigation';
+import {createNativeStackNavigator} from '@react-navigation/native-stack';
 
-import RootStack from './root'
+// 忽略不必要的警告日志
+import {LogBox} from 'react-native';
 
-export const routerReducer = createNavigationReducer(RootStack);
+LogBox.ignoreLogs([
+    'Non-serializable values were found in the navigation state',
+    'componentWillReceiveProps',
+    'EventEmitter.removeListener',
+]);
 
-export const routerMiddleware = createReactNavigationReduxMiddleware(
-    Platform.OS === 'ios' ? (state) => state.router : state => state.nav,
-);
-const AppStack = createReduxContainer(RootStack, 'root');
+import Welcome from './pages/Welcome';
+import HomeStack from './pages/Desktop/Index';
+
+const Stack = createNativeStackNavigator();
 let lastBackPressed = 0;
+const NavigationOptions = {
+    headerStyle: {
+        backgroundColor: '#5394e4',
+        height: 40,
+    },
+    headerShadowVisible: false, // 取消导航下面的阴影
+    headerTitleAlign: 'center', // 标题文字居中
+    headerTintColor: '#fff',
+    headerTitleStyle: {
+        fontSize: 20,
+        marginTop: Platform.OS === 'ios' ? 10 : 0,
+    },
+    headerBackTitle: Platform.OS === 'ios' ? ' ' : null,         // ~注意~ 这个地方是隐藏返回按钮文字的
+};
 
-function getActiveRouteName(navigationState) {
-    if (!navigationState) {
-        return null;
-    }
-    const route = navigationState.routes[navigationState.index];
-    if (route.routes) {
-        return getActiveRouteName(route);
-    }
-    return route.routeName;
-}
 
 @connect(({app, router}) => ({app, router}))
 class Router extends React.PureComponent {
-    componentDidMount() {
-        BackHandler.addEventListener('hardwareBackPress', this.backHandle);
-    }
+    // componentDidMount() {
+    //     BackHandler.addEventListener('hardwareBackPress', this.backAction);
+    // }
+    //
+    // componentWillUnmount() {
+    //     BackHandler.removeEventListener('hardwareBackPress', this.backAction);
+    // }
+    //
+    // backAction = () => {
+    //     const currentScreen = getActiveRouteName(this.props.navigation.getState());
+    //     const MainRouteNames = ['DesktopHome'];
+    //     if (MainRouteNames.indexOf(currentScreen) > -1) {
+    //         if (lastBackPressed && lastBackPressed + 2000 >= Date.now()) {
+    //             //最近2秒内按过back键,可以退出应用。
+    //             BackHandler.exitApp();
+    //             return false;
+    //         }
+    //         lastBackPressed = Date.now();
+    //         ToastAndroid.show('再按一次退出应用', ToastAndroid.SHORT);
+    //         return true;
+    //     }
+    // };
 
-    componentWillUnmount() {
-        BackHandler.removeEventListener('hardwareBackPress', this.backHandle);
-    }
-
-    backHandle = () => {
-        const currentScreen = getActiveRouteName(this.props.router);
-        if (currentScreen === 'Main') {
-            return true;
-        }
-        const MainRouteNames = ['DesktopHome',];
-        if (MainRouteNames.indexOf(currentScreen) === -1) {
-            this.props.dispatch(NavigationActions.back());
-            return true;
-        } else {
-            if (lastBackPressed && lastBackPressed + 2000 >= Date.now()) {
-                //最近2秒内按过back键,可以退出应用。
-                return false;
-            }
-            lastBackPressed = Date.now();
-            ToastAndroid.show('再按一次退出应用', ToastAndroid.SHORT);
-            return true;
+    render() {
+        const StackDict = {
+            ...HomeStack,
+        };
+        let stackList = [];
+        for (let key in StackDict) {
+            const item = {
+                name: key,
+                screen: StackDict[key].screen,
+                options: {
+                    ...NavigationOptions, ...StackDict[key].navigationOptions, ...StackDict[key].screen.navigationOptions,
+                },
+            };
+            stackList.push(item);
         }
+        return (
+            <NavigationContainer>
+                <Stack.Navigator>
+                    {/*<Stack.Screen name="Welcome" component={Welcome} options={{headerShown: false}}/>*/}
+                    {/*<Stack.Screen name="DesktopHome" component={DesktopHome} options={NavigationOptions}/>*/}
+                    {/*<Stack.Screen name="SetPower" component={SetPower} options={{headerShown: true}}/>*/}
+                    {
+                        stackList.map((stack, index) => (
+                            <Stack.Screen key={index} name={stack.name} component={stack.screen}
+                                          options={stack.options}/>
+                        ))
+                    }
 
-    };
+                </Stack.Navigator>
+            </NavigationContainer>
 
-    render() {
-        const {dispatch, router} = this.props;
-        return <AppStack
-            dispatch={dispatch}
-            state={router}
-        />;
+        );
     }
 }
 
+const styles = StyleSheet.create({
+    iconFont: {
+        fontFamily: 'iconfont',
+        fontSize: 20,
+        color: '#757575',
+    },
+    iconFontFocused: {
+        fontFamily: 'iconfont',
+        fontSize: 20,
+        color: '#2b90ea',
+    },
+});
 export default Router;

+ 0 - 69
jscore/scripts/custom-rn-theme.js

@@ -1,69 +0,0 @@
-
-const path = require('path');
-const fs = require('fs');
-
-const FileOption = {
-  encoding: 'utf8'
-};
-// for 1.x
-// const defaultVars = require('antd-mobile/lib/style/themes/default');
-// for 2.x
-const themePath = path.resolve(require.resolve('@ant-design/react-native'), '../style/themes/default.js');
-
-
-// 提前变更文件的品牌变量,防止js引入时,到处的对象内属性值已经被解析为原始品牌变量值
-let themeFileStr = fs.readFileSync(themePath, FileOption);
-let reg = /('|")#\w*('|");/g;
-function handleReplace(str) {
-  let flag = str;
-  if (str && str === "'#108ee9';") {
-    flag = "'#03C762';";
-  }
-  return flag;
-}
-const newFile = themeFileStr.replace(reg, handleReplace);
-fs.writeFileSync(
-  themePath,
-  newFile,
-  FileOption
-);
-
-const defaultVars = require('@ant-design/react-native/lib/style/themes/default');
-const customVars = require('../theme');
-
-const themeVars = Object.assign({}, defaultVars, customVars);
-
-if (fs.statSync(themePath).isFile()) {
-  fs.writeFileSync(
-    themePath,
-    `var brandPrimary = "#03C762"; var brandPrimaryTap = "#03C762";module.exports = ${JSON.stringify(themeVars)}`
-  );
-}
-
-
-
-
-
-
-
-/*
-const path = require('path');
-const fs = require('fs');
-// for 1.x
-// const defaultVars = require('antd-mobile/lib/style/themes/default');
-// for 2.x
-const defaultVars = require('@ant-design/react-native/lib/style/themes/default');
-const customVars = require('../theme');
-// for 1.x
-// const themePath = path.resolve(require.resolve('antd-mobile'), '../style/themes/default.js');
-// for 2.x
-const themePath = path.resolve(require.resolve('@ant-design/react-native'), '../style/themes/default.js');
-const themeVars = Object.assign({}, defaultVars, customVars);
-
-if (fs.statSync(themePath).isFile()) {
-  fs.writeFileSync(
-    themePath,
-    'var brandPrimary = "#03C762"; var brandPrimaryTap = "#2fd07d";module.exports = ' + JSON.stringify(themeVars)
-  );
-}
-*/

+ 60 - 0
jscore/utils/SyncStorage.js

@@ -0,0 +1,60 @@
+import {Alert} from 'react-native';
+import AsyncStorage from '@react-native-async-storage/async-storage';
+// https://react-native-async-storage.github.io/async-storage/docs/usage
+// https://blog.csdn.net/AnitaSun/article/details/115204134
+
+const set = async (key, value, obj = null) => {
+
+    try {
+        if (obj) {
+            value = JSON.stringify(value);
+        }
+        await AsyncStorage.setItem(key, value);
+    } catch (e) {
+        // saving error
+        console.log('设置内部存储失败', e);
+        Alert.alert('设置内部存储失败');
+    }
+};
+
+const get = async (key, obj = null) => {
+    try {
+        const value = await AsyncStorage.getItem(key);
+        if (obj) {
+            return value != null ? JSON.parse(value) : null;
+        }
+        return value;
+    } catch (e) {
+        // error reading value
+        console.log('获取内部存储失败', e);
+        Alert.alert('获取内部存储失败');
+    }
+};
+
+const remove = async (key) => {
+    try {
+        await AsyncStorage.removeItem(key);
+    } catch (e) {
+        // remove error
+        console.log('删除内部存储失败', e);
+        Alert.alert('删除内部存储失败');
+    }
+};
+
+const clear = async (key) => {
+    try {
+        await AsyncStorage.clear();
+    } catch (e) {
+        // remove error
+        console.log('清空内部存储失败', e);
+        Alert.alert('清空内部存储失败');
+    }
+};
+
+
+export default {
+    clear,
+    remove,
+    get,
+    set,
+};

+ 10 - 0
jscore/utils/index.js

@@ -1,3 +1,13 @@
 export { NavigationActions, StackActions } from 'react-navigation'
 
+export { default as SyncStorage } from './SyncStorage'
 export { default as ScreenUtil } from './screen'
+
+export const createAction = type => payload => ({ type, payload })
+
+export function getUrlParameter(name, str) {
+    const reg = new RegExp(`(^|&)${name}=([^&]*)(&|$)`);
+    const r = str.substr(1).match(reg);
+    if (r != null) return  decodeURIComponent(r[2]);
+    return null;
+}

+ 0 - 42
jscore/utils/storage.js

@@ -1,42 +0,0 @@
-import { AsyncStorage } from 'react-native'
-
-function clear() {
-  return AsyncStorage.clear()
-}
-
-function get(key, defaultValue = null) {
-  return AsyncStorage.getItem(key).then(
-    value => (value !== null ? JSON.parse(value) : defaultValue)
-  )
-}
-
-function set(key, value) {
-  return AsyncStorage.setItem(key, JSON.stringify(value))
-}
-
-function remove(key) {
-  return AsyncStorage.removeItem(key)
-}
-
-function multiGet(...keys) {
-  return AsyncStorage.multiGet([...keys]).then(stores => {
-    const data = {}
-    stores.forEach((result, i, store) => {
-      data[store[i][0]] = JSON.parse(store[i][1])
-    })
-    return data
-  })
-}
-
-function multiRemove(...keys) {
-  return AsyncStorage.multiRemove([...keys])
-}
-
-export default {
-  clear,
-  get,
-  set,
-  remove,
-  multiGet,
-  multiRemove,
-}

+ 17 - 0
metro.config.js

@@ -0,0 +1,17 @@
+/**
+ * Metro configuration for React Native
+ * https://github.com/facebook/react-native
+ *
+ * @format
+ */
+
+module.exports = {
+  transformer: {
+    getTransformOptions: async () => ({
+      transform: {
+        experimentalImportSupport: false,
+        inlineRequires: false,
+      },
+    }),
+  },
+};

+ 43 - 60
package.json

@@ -1,73 +1,56 @@
 {
   "name": "power_sensor",
-  "version": "1.0.0",
-  "description": "电金睛",
+  "version": "0.0.1",
   "private": true,
   "scripts": {
     "android": "react-native run-android",
     "ios": "react-native run-ios",
-    "start": "node jscore/scripts/custom-rn-theme && react-native start",
-    "bundle-ios": "cross-env BABEL_ENV=production react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios"
+    "start": "react-native start",
+    "test": "jest",
+    "lint": "eslint ."
   },
-  "author": "firefish",
-  "license": "ISC",
   "dependencies": {
-    "@ant-design/react-native": "^3.2.2",
-    "@react-native-community/async-storage": "1.8.0",
-    "@react-native-community/toolbar-android": "^0.1.0-rc.2",
-    "@react-native-community/viewpager": "^3.3.0",
-    "babel-preset-react-app": "^9.0.0",
-    "dva-core": "^1.4.0",
-    "glog": "^1.7.0",
-    "less": "^3.9.0",
-    "less-loader": "^4.1.0",
-    "mobx": "^5.9.0",
-    "native-echarts": "^0.5.0",
-    "package.json": "^2.0.1",
-    "qs": "^6.6.0",
-    "react": "16.9.0",
-    "react-dom": "^16.8.1",
-    "react-native": "0.61.5",
-    "react-native-barcode-builder": "^2.0.0",
-    "react-native-gesture-handler": "^1.3.0",
-    "react-native-icon-badge": "^1.1.3",
-    "react-native-looped-carousel": "^0.1.13",
-    "react-native-navigationbar": "^0.4.5",
-    "react-native-paper": "^4.7.2",
-    "react-native-refresh-flatlist": "^1.0.1",
-    "react-native-refreshable-flatlist": "^0.1.1",
-    "react-native-screens": "^2.16.1",
-    "react-native-super-grid": "^3.0.0",
-    "react-native-swiper": "^1.5.14",
-    "react-native-tab-navigator": "^0.3.4",
-    "react-native-tableview-simple": "^2.0.1",
-    "react-native-vector-icons": "^6.6.0",
-    "react-navigation": "^3.0.9",
-    "react-navigation-material-bottom-tabs": "2.1.5",
-    "react-navigation-redux-helpers": "4.0.1",
-    "react-redux": "7.2.0",
-    "redux": "^4.0.5",
-    "sync-storage": "^0.3.0"
-  },
-  "resolutions": {
-    "@react-native-community/viewpager": "^3.3.0"
-  },
-  "rnpm": {
-    "assets": [
-      "./assets/fonts/"
-    ]
+    "@ant-design/react-native": "4.2.0",
+    "@react-native-async-storage/async-storage": "^1.17.10",
+    "@react-native-community/art": "^1.2.0",
+    "@react-native-community/cameraroll": "^4.1.2",
+    "@react-native-community/datetimepicker": "^6.7.0",
+    "@react-native-community/segmented-control": "^2.2.2",
+    "@react-native-community/slider": "^4.3.3",
+    "@react-native-picker/picker": "^2.4.8",
+    "@react-navigation/bottom-tabs": "^6.4.0",
+    "@react-navigation/native": "^6.0.13",
+    "@react-navigation/native-stack": "^6.9.1",
+    "dva-core": "^2.0.4",
+    "fbjs": "^3.0.4",
+    "jsc-android": "^250230.2.1",
+    "qs": "^6.11.0",
+    "react": "17.0.2",
+    "react-native": "0.67.0",
+    "react-native-barcode-builder": "2.0.0",
+    "react-native-gesture-handler": "2.8.0",
+    "react-native-pager-view": "^6.1.0",
+    "react-native-paper": "^4.12.5",
+    "react-native-safe-area-context": "^4.4.1",
+    "react-native-screens": "^3.18.2",
+    "react-native-svg": "12.1.1",
+    "react-native-tableview-simple": "^4.3.1",
+    "react-native-webview": "^11.26.1",
+    "react-navigation": "^4.4.4",
+    "react-navigation-stack": "^2.10.4",
+    "react-redux": "^8.0.5",
+    "redux": "^4.2.0"
   },
   "devDependencies": {
-    "@babel/core": "^7.8.4",
-    "@babel/plugin-proposal-decorators": "^7.8.3",
-    "@babel/runtime": "^7.8.4",
-    "@react-native-community/eslint-config": "^0.0.7",
-    "babel-jest": "^25.1.0",
-    "babel-preset-react-app": "^9.0.0",
-    "eslint": "^6.8.0",
-    "jest": "^25.1.0",
-    "metro-react-native-babel-preset": "^0.58.0",
-    "react-test-renderer": "16.9.0"
+    "@babel/core": "^7.20.2",
+    "@babel/plugin-proposal-decorators": "^7.20.2",
+    "@babel/runtime": "^7.20.1",
+    "@react-native-community/eslint-config": "^3.2.0",
+    "babel-jest": "^29.3.1",
+    "eslint": "^8.27.0",
+    "jest": "^29.3.1",
+    "metro-react-native-babel-preset": "^0.73.3",
+    "react-test-renderer": "17.0.2"
   },
   "jest": {
     "preset": "react-native"

+ 0 - 1
ra.bat

@@ -1 +0,0 @@
-react-native run-android