Bläddra i källkod

添加 aio 一体机编译参数

cc12458 1 månad sedan
förälder
incheckning
45cd765034

+ 39 - 2
app/build.gradle.kts

@@ -1,3 +1,13 @@
+import com.android.build.gradle.internal.api.BaseVariantOutputImpl
+import java.text.SimpleDateFormat
+import java.util.Date
+
+fun getVersionCode(): Int {
+  val dateFormat = SimpleDateFormat("yyyyMMdd")
+  val versionCodeStr = dateFormat.format(Date())
+  return versionCodeStr.toInt()
+}
+
 plugins {
   alias(libs.plugins.android.application)
   alias(libs.plugins.kotlin.android)
@@ -13,8 +23,8 @@ android {
     applicationId = "com.hzliuzhi.applet.container"
     minSdk = 26
     targetSdk = 35
-    versionCode = 1
-    versionName = "1.0"
+    versionCode = getVersionCode()
+    versionName = "2.0.0"
 
     testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
   }
@@ -24,7 +34,34 @@ android {
       isMinifyEnabled = false
       proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
     }
+    create("aio") {
+      resValue("string", "build_type_tag", "AIO")
+      initWith(getByName("debug"))
+      matchingFallbacks += listOf("debug")
+    }
+    create("aio-test") {
+      initWith(getByName("aio"))
+      matchingFallbacks += listOf("aio", "debug")
+    }
+    create("aio-CQ") {
+      initWith(getByName("aio-test"))
+      matchingFallbacks += listOf("aio-test", "aio", "debug")
+    }
   }
+  applicationVariants.all {
+    outputs.all {
+      val appName = "six" // 你的自定义名称
+      val buildType = buildType.name
+      val versionName = versionName
+      val versionCode = versionCode
+
+      val fileName = "${appName}.${buildType}-${versionName}-${versionCode}.apk"
+      (this as BaseVariantOutputImpl).apply {
+        outputFileName = fileName
+      }
+    }
+  }
+
   compileOptions {
     sourceCompatibility = JavaVersion.VERSION_11
     targetCompatibility = JavaVersion.VERSION_11

+ 6 - 0
app/src/aio-CQ/res/values/application.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+  <string name="app_id">AIO</string>
+  <string name="app_name">中医健康辨识仪(区域版.CQ)</string>
+  <string name="app_screen">browser/kiosk?url=http://10.227.137.3:98/aio/screen</string>
+</resources>

+ 12 - 0
app/src/aio-CQ/res/values/browser_proxy.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+  <bool name="browser_http_proxy_enabled">true</bool>
+  <string-array name="browser_proxy_pool">
+    <item>https://hybrid.reborn-tech.com -> http://10.227.137.3:98/mz/hybrid</item>
+    <item>https://api.reborn-tech.com -> http://10.227.137.2/mz/api</item>
+    <item>https://taiyi.oss-accelerate.aliyuncs.com -> http://10.227.137.2/mz/oss</item>
+    <item>https://taiyi.oss-cn-beijing.aliyuncs.com -> http://10.227.137.2/mz/oss</item>
+    <item>https://oss-accelerate.aliyuncs.com/taiyi -> http://10.227.137.2/mz/oss</item>
+    <item>https://oss-cn-beijing.aliyuncs.com/taiyi -> http://10.227.137.2/mz/oss</item>
+  </string-array>
+</resources>

+ 5 - 0
app/src/aio-CQ/res/values/pulse.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+  <bool name="taiyi_skip_report">true</bool>
+  <integer name="taiyi_delay_disconnect">300</integer>
+</resources>

+ 6 - 0
app/src/aio-test/res/values/application.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+  <string name="app_id">AIO</string>
+  <string name="app_name">中医健康辨识仪(测试版)</string>
+  <string name="app_screen">browser/kiosk?url=https://wx.hzliuzhi.com:4433/aio/</string>
+</resources>

+ 12 - 0
app/src/aio-test/res/values/browser_proxy.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+  <bool name="browser_http_proxy_enabled">true</bool>
+  <string-array name="browser_proxy_pool">
+    <item>https://hybrid.reborn-tech.com -> https://wx.hzliuzhi.com/mz/hybrid</item>
+    <item>https://api.reborn-tech.com -> https://wx.hzliuzhi.com/mz/api</item>
+    <item>https://taiyi.oss-accelerate.aliyuncs.com -> https://wx.hzliuzhi.com/mz/oss</item>
+    <item>https://taiyi.oss-cn-beijing.aliyuncs.com -> https://wx.hzliuzhi.com/mz/oss</item>
+    <item>https://oss-accelerate.aliyuncs.com/taiyi -> https://wx.hzliuzhi.com/mz/oss</item>
+    <item>https://oss-cn-beijing.aliyuncs.com/taiyi -> https://wx.hzliuzhi.com/mz/oss</item>
+  </string-array>
+</resources>

+ 5 - 0
app/src/aio-test/res/values/pulse.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+  <bool name="taiyi_skip_report">true</bool>
+  <integer name="taiyi_delay_disconnect">300</integer>
+</resources>

+ 64 - 0
app/src/aio/assets/browser/bridge.js

@@ -0,0 +1,64 @@
+class Bridge extends EventTarget {
+  #pool = new Map();
+
+  static getInstance() {
+    return Bridge._instance ?? (Bridge._instance = new Bridge());
+  }
+
+  static get Platform() {
+    return window['AndroidBridge'];
+  }
+
+  static get UUID() {
+    return crypto.randomUUID();
+  }
+
+  static pulse(userId) {
+    const { promise, ...resolvers } = Promise.withResolvers();
+    this.getInstance().#postMessage('pulse', { userId }, resolvers);
+    return promise;
+  }
+
+  static print(payload) {
+    const { promise, ...resolvers } = Promise.withResolvers();
+    this.getInstance().#postMessage('print', payload, resolvers);
+    return promise;
+  }
+
+  dispatch(message) {
+    console.log('log:bridge:js', `[dispatch] 接收消息: ${message}`);
+    try {
+      const { type, callbackId, payload }  = JSON.parse(message);
+      if (callbackId) {
+        const { resolve, reject } = this.#pool.get(callbackId) ?? {};
+        this.#pool.delete(callbackId);
+        if (payload.code === 0) resolve(payload.data)
+        else reject(payload.message)
+      } else {
+        event = new CustomEvent(type, { detail: payload });
+        super.dispatchEvent(event);
+      }
+    } catch (e) {
+      console.log('log:bridge:js', `[analysis] 解析消息错误: ${e.message}`);
+      throw e;
+    }
+  }
+
+  addEventListener(type, callback, options) {
+    super.addEventListener(type, callback, options);
+    return () => super.removeEventListener(type, callback);
+  }
+
+  #postMessage(type, payload, resolvers) {
+    const callbackId = `${type}:${Bridge.UUID}`;
+    this.#pool.set(callbackId, resolvers);
+    const message = JSON.stringify({ type, payload, callbackId })
+    Bridge.Platform.postMessage(message);
+    console.log('log:bridge:js', `[dispatch] 发送消息: ${message}`);
+  }
+}
+
+window['Bridge'] = Bridge;
+window['bridge'] = Bridge.getInstance();
+
+window.print = Bridge.print.bind(Bridge);

+ 8 - 0
app/src/aio/res/values/application.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+  <string name="app_id">AIO</string>
+  <string name="app_name">中医健康辨识仪(开发版)</string>
+  <string name="app_screen">browser/kiosk?url=https://wx.hzliuzhi.com:4433/aio/?sn=45dde49f100eb0cb</string>
+  <!-- <string name="app_screen">browser/kiosk?url=http://192.168.1.14:4173/aio/?sn=45dde49f100eb0cb</string> -->
+  <!-- <string name="app_screen">browser/kiosk?url=http://192.168.31.184:4173/aio/?sn=45dde49f100eb0cb</string> -->
+</resources>

+ 12 - 0
app/src/aio/res/values/browser_proxy.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+  <bool name="browser_http_proxy_enabled">true</bool>
+  <string-array name="browser_proxy_pool">
+    <item>https://hybrid.reborn-tech.com -> https://wx.hzliuzhi.com/mz/hybrid</item>
+    <item>https://api.reborn-tech.com -> https://wx.hzliuzhi.com/mz/api</item>
+    <item>https://taiyi.oss-accelerate.aliyuncs.com -> https://wx.hzliuzhi.com/mz/oss</item>
+    <item>https://taiyi.oss-cn-beijing.aliyuncs.com -> https://wx.hzliuzhi.com/mz/oss</item>
+    <item>https://oss-accelerate.aliyuncs.com/taiyi -> https://wx.hzliuzhi.com/mz/oss</item>
+    <item>https://oss-cn-beijing.aliyuncs.com/taiyi -> https://wx.hzliuzhi.com/mz/oss</item>
+  </string-array>
+</resources>

+ 5 - 0
app/src/aio/res/values/pulse.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+  <bool name="taiyi_skip_report">false</bool>
+  <integer name="taiyi_delay_disconnect">300</integer>
+</resources>