Compare commits
14 Commits
8318b3a688
...
fd3228eac3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd3228eac3 | ||
|
|
c924b5c0fb | ||
|
|
f137ff9ec6 | ||
|
|
6b3779ca6a | ||
|
|
e93faeda0a | ||
|
|
34263169ed | ||
|
|
1067352c4c | ||
|
|
807b545506 | ||
|
|
3251be25a4 | ||
|
|
f9327397d6 | ||
|
|
bf44b33abd | ||
|
|
06d58a5a71 | ||
|
|
ba33f9c59a | ||
|
|
5ae92e0f63 |
11
.env.example
Normal file
11
.env.example
Normal file
@ -0,0 +1,11 @@
|
||||
# 环境变量模板:复制为 .env.development.local 并填写真实值(该文件不提交 git)
|
||||
#
|
||||
# 生效范围:仅 NODE_ENV=development 的构建(npm run dev:h5 / dev:app-plus)
|
||||
# 发布构建(npm run build:h5 / build:app-plus)固定使用 src/env.js 中的
|
||||
# PROD_API_BASE,不会读取本文件的地址,详见 src/env.js 顶部说明。
|
||||
#
|
||||
# ⚠️ 不要用 .env.local:它在 production 模式同样会被加载,并会被构建工具注入到
|
||||
# 客户端代码里,导致内网地址出现在正式包中(scripts/check-build-env.cjs 会中止构建)。
|
||||
# ⚠️ 不要把 VUE_APP_API_BASE_OVERRIDE 写进 .env* 文件:它只允许由命令行显式注入。
|
||||
VUE_APP_API_BASE_URL=http://your-server-ip:6060
|
||||
VUE_APP_IMG_URL=https://ye4s.file.gzxunren.com
|
||||
20
.gitignore
vendored
20
.gitignore
vendored
@ -21,6 +21,9 @@ yarn-error.log*
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# dev:adb 记住的目标设备(本地状态)
|
||||
.dev-adb.local.json
|
||||
|
||||
# VSCode
|
||||
.vscode/
|
||||
|
||||
@ -38,4 +41,21 @@ yarn-error.log*
|
||||
# 静态资源缓存
|
||||
static/uview/
|
||||
|
||||
# ===== Android 离线打包(详见 android-offline/README.md) =====
|
||||
# 签名密钥与本地配置(含密码)不提交
|
||||
android-offline/keystore/
|
||||
config/android.json
|
||||
# DCloud 离线 SDK(体积大,按需下载解压,勿提交)
|
||||
android-offline/SDK/
|
||||
# 原生工程的本地产物(工程源码本身提交,保证发布基座一致)
|
||||
android-offline/HBuilder-Integrate-AS/local.properties
|
||||
android-offline/HBuilder-Integrate-AS/.gradle/
|
||||
android-offline/HBuilder-Integrate-AS/.idea/
|
||||
android-offline/HBuilder-Integrate-AS/**/build/
|
||||
android-offline/HBuilder-Integrate-AS/**/*.iml
|
||||
# 打包时拷入的 App 资源(由 dist/build/app-plus 生成)
|
||||
android-offline/HBuilder-Integrate-AS/simpleDemo/src/main/assets/apps/__UNI__0B3DAD3/
|
||||
# APK / exe 产物
|
||||
release/
|
||||
|
||||
# 其他可根据实际情况添加
|
||||
|
||||
70
README.md
70
README.md
@ -88,3 +88,73 @@
|
||||
3. 再看接口返回结构是否包含 token
|
||||
4. 最后看登录后是否成功调用 `user.info`
|
||||
|
||||
## 构建与运行(uni-app Vue2 CLI 工程)
|
||||
|
||||
> 本项目已从 HBuilderX 工程迁移为 `@vue/cli` 脚手架工程(2026-10-02):
|
||||
> 业务源码全部位于 `src/`,H5 模板由 `public/index.html` 提供(即原根目录的 `template.h5.html`)。
|
||||
|
||||
### 命令
|
||||
|
||||
| 命令 | 作用 | 产物 |
|
||||
| --- | --- | --- |
|
||||
| `npm run dev:h5` | H5 开发服务器(默认 http://localhost:8080) | 内存编译 |
|
||||
| `npm run build:h5` | H5 生产构建 | `dist/build/h5` |
|
||||
| `npm run dev:app-plus` | App 资源监听编译 | `dist/dev/app-plus` |
|
||||
| `npm run build:app-plus` | App 生产构建 | `dist/build/app-plus` |
|
||||
| `npm run build:apk` | Android **发行包**(生产地址 + 产物地址校验) | `release/android/wms-pda_v*.apk` |
|
||||
| `npm run dev:adb` | Android **测试包**(注入开发地址)→ 装机 → 启动 | `release/android/dev/wms-pda_v*_dev.apk` |
|
||||
| `npm run android:pack:raw` | 仅打包(用现有 `dist/build/app-plus`,不重编前端) | 同上 |
|
||||
| `npm run check:env` | 手动校验产物接口地址 | - |
|
||||
| `npm run lint` | ESLint 自动修复 | - |
|
||||
|
||||
### App 端如何选择接口环境(测试模式)
|
||||
|
||||
| 场景 | 命令 | 接口地址来源 |
|
||||
| --- | --- | --- |
|
||||
| 发行包 | `npm run build:apk` | `src/env.js` 的 `PROD_API_BASE`(固定),构建后强制校验产物不含内网地址 |
|
||||
| 测试包 | `npm run dev:adb` | 默认 `.env.development.local` 的 `VUE_APP_API_BASE_URL`;可用 `--api=http://x.x.x.x:6060` 指定 |
|
||||
| 测试包(与发行一致) | `npm run dev:adb -- --prod-api` | 不注入,指向生产(用于排查线上问题) |
|
||||
|
||||
- 注入方式:编译期命令行环境变量 `VUE_APP_API_BASE_OVERRIDE`(**不写入任何 .env 文件、不落盘**),在 `src/env.js` 中优先级最高。与工作台项目的 `VITE_API_BASE_OVERRIDE` 是同一套思路。
|
||||
- 测试包产物单独放 `release/android/dev/` 且文件名带 `_dev`,**不会覆盖发行包**,也不会触发发布上传(自动加 `-Dev -NoUpload`)。
|
||||
- 设备选择:命令行 `--serial=` > 上次选择的设备(记在 `.dev-adb.local.json`,不提交)> 只有一台时自动选中 > 多台时交互选择。
|
||||
- 若在 cmd / 默认代码页(936)的窗口里运行看到中文乱码:先执行 `chcp 65001`(VS Code 内置终端、Windows Terminal 默认无需处理)。
|
||||
- 两道校验方向相反:发行包**反向**校验(产物中不得出现 `192.168.x.x`/`127.0.0.1`);测试包**正向**校验(产物中必须出现注入的地址,否则中止,避免装成生产包却以为在测开发环境)。
|
||||
- 真机 JS 日志:**离线 release 包默认不会把 `console.log` 输出到 logcat**(HBuilderX「运行到手机」靠的是 debug 基座)。测试包由 `src/core/utils/dev-log.js` 用 `plus.android` 桥接 `android.util.Log`,把 console 转发到 logcat 的 `jsLog` tag(`dev:adb` 会自动注入开关并实时跟随打印):
|
||||
```powershell
|
||||
& "$env:ANDROID_HOME\platform-tools\adb.exe" -s <序列号> logcat jsLog:V UniConsole:V UniViewConsole:V *:S
|
||||
```
|
||||
|
||||
### App 端调试与打包
|
||||
|
||||
- CLI 不提供「运行到手机」:`build:app-plus` 只产出 App 资源,用 HBuilderX 导入 `dist/build/app-plus` 运行(或使用自定义基座、离线打包)。
|
||||
- 正式云打包仍建议走 HBuilderX;`src/manifest.json` 中的 appid、模块、权限配置均保持原样。
|
||||
|
||||
### 注意事项
|
||||
|
||||
- **Node 版本**:当前在 Node 24 下构建,依赖两个脚本内开关——`--openssl-legacy-provider`(webpack 4 需要)与 `--require=./scripts/node-compat.cjs`(补回 Node 23+ 移除的 `util.isRegExp` 等历史 API)。若改用 Node 16/18,这两项会自动变成无害的空操作。
|
||||
- **`ROUTES` 常量**:由根目录 `vue.config.js`(`uni-read-pages` + DefinePlugin)注入,`uni-simple-router` 内部依赖它;缺失会在运行时抛 `ReferenceError: ROUTES is not defined`,请勿删除该配置。
|
||||
- **@dcloudio 版本必须整体一致**:当前锁定 `2.0.2-5020620260917001`(Vue2 线),升级时需全量同版本替换。
|
||||
- **依赖镜像**:`.npmrc` 指向 `registry.npmmirror.com`。
|
||||
- `src/pages/componentsA|B|C` 是 uView 官方示例页(含 67 个 `.nvue` 文件),未被 `pages.json` 注册、不参与编译,可按需删除。
|
||||
|
||||
### 接口地址与环境变量(防呆)
|
||||
|
||||
| 场景 | 地址来源 | 命令 |
|
||||
| --- | --- | --- |
|
||||
| 发布构建(H5 / App) | `src/env.js` 的 `PROD_API_BASE`(固定,不采用 .env 文件里的地址) | `npm run build:h5` / `build:app-plus` |
|
||||
| 本地开发 | `.env.development.local` 的 `VUE_APP_API_BASE_URL`(git 不跟踪) | `npm run dev:h5` / `dev:app-plus` |
|
||||
| 临时指向指定后端 | 命令行显式注入 `VUE_APP_API_BASE_OVERRIDE`(不落盘) | 见下 |
|
||||
|
||||
- 首次拉取代码后:复制 `.env.example` 为 `.env.development.local` 并填写内网地址。
|
||||
- 临时改后端(不写任何文件):`npx cross-env UNI_PLATFORM=h5 NODE_ENV=development VUE_APP_API_BASE_OVERRIDE=http://192.168.1.10:6060 vue-cli-service uni-serve`
|
||||
- **两道防线**:
|
||||
1. 生产构建只认 `PROD_API_BASE`,源码里也不再保留任何内网地址字面量;
|
||||
2. `npm run build:h5` / `build:app-plus` 结束后自动执行 `scripts/check-build-env.cjs`,产物中出现 `192.168.x.x` / `127.0.0.1`,或缺少生产域名 `qimen.wms.gztbyc.com`,即**构建失败**。手动校验:`npm run check:env`。
|
||||
- ⚠️ 开发地址**不要**写进 `.env.local`:该文件在 production 模式同样会被加载,并会被构建工具注入到客户端代码里(会被上面的校验拦下,但没必要绕这一圈)。
|
||||
- 现场排查设备连的是哪个后端:可用 `pages/settings/networkTest` 页面查看/测试接口地址。
|
||||
|
||||
### 回退方式
|
||||
|
||||
原 HBuilderX 工程完整备份在 `d:\WMS_PDA_bak_20261002-1936`(含 `node_modules`、`.hbuilderx`、`template.h5.html`、`vue.config.js`、`package.json`、`package-lock.json`)。需要回退时,把备份内容覆盖回项目根目录即可。
|
||||
|
||||
|
||||
28
android-offline/HBuilder-Integrate-AS/build.gradle
Normal file
28
android-offline/HBuilder-Integrate-AS/build.gradle
Normal file
@ -0,0 +1,28 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
maven {url 'https://maven.aliyun.com/repository/google'}
|
||||
maven {url 'https://maven.aliyun.com/repository/gradle-plugin'}
|
||||
maven {url 'https://maven.aliyun.com/repository/public'}
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:8.7.3'
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
maven {url 'https://maven.aliyun.com/repository/google'}
|
||||
maven {url 'https://maven.aliyun.com/repository/gradle-plugin'}
|
||||
maven {url 'https://maven.aliyun.com/repository/public'}
|
||||
google()
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
20
android-offline/HBuilder-Integrate-AS/gradle.properties
Normal file
20
android-offline/HBuilder-Integrate-AS/gradle.properties
Normal file
@ -0,0 +1,20 @@
|
||||
# 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.
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
|
||||
# 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
|
||||
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
BIN
android-offline/HBuilder-Integrate-AS/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
android-offline/HBuilder-Integrate-AS/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
android-offline/HBuilder-Integrate-AS/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
android-offline/HBuilder-Integrate-AS/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
#Mon Dec 28 18:07:31 CST 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.11.1-bin.zip
|
||||
172
android-offline/HBuilder-Integrate-AS/gradlew
vendored
Normal file
172
android-offline/HBuilder-Integrate-AS/gradlew
vendored
Normal file
@ -0,0 +1,172 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
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
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
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
|
||||
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
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((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" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
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" "$@"
|
||||
84
android-offline/HBuilder-Integrate-AS/gradlew.bat
vendored
Normal file
84
android-offline/HBuilder-Integrate-AS/gradlew.bat
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@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=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
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%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
1
android-offline/HBuilder-Integrate-AS/settings.gradle
Normal file
1
android-offline/HBuilder-Integrate-AS/settings.gradle
Normal file
@ -0,0 +1 @@
|
||||
include ':simpleDemo'
|
||||
@ -0,0 +1,97 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
// ===== 统一配置:动态读取项目根 config/android.json 与 package.json(见 config/README.md)=====
|
||||
// 本文件不包含任何密码/包名等可变配置,可直接提交 git。
|
||||
def projectRoot = file('../../..')
|
||||
def cfgFile = new File(projectRoot, 'config/android.json')
|
||||
if (!cfgFile.exists()) {
|
||||
throw new GradleException('config/android.json not found. Copy config/android.example.json to config/android.json first. See config/README.md')
|
||||
}
|
||||
def cfg = new groovy.json.JsonSlurper().parseText(cfgFile.getText('UTF-8'))
|
||||
|
||||
def pkgFile = new File(projectRoot, 'package.json')
|
||||
def pkg = new groovy.json.JsonSlurper().parseText(pkgFile.getText('UTF-8'))
|
||||
def versionNameValue = pkg.version
|
||||
def versionParts = versionNameValue.tokenize('.')
|
||||
if (versionParts.size() < 3) {
|
||||
throw new GradleException("package.json version must be three-part X.Y.Z, got: ${versionNameValue}")
|
||||
}
|
||||
// versionCode = X*1000000 + Y*1000 + Z (each part 0-999)
|
||||
def versionCodeValue = versionParts[0].toInteger() * 1000000 + versionParts[1].toInteger() * 1000 + versionParts[2].toInteger()
|
||||
|
||||
android {
|
||||
compileSdkVersion 35
|
||||
buildToolsVersion '35.0.0'
|
||||
namespace cfg.packageName
|
||||
defaultConfig {
|
||||
applicationId cfg.packageName
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 33
|
||||
versionCode versionCodeValue
|
||||
versionName versionNameValue
|
||||
multiDexEnabled true
|
||||
resValue 'string', 'app_name', cfg.appName
|
||||
manifestPlaceholders = [
|
||||
'dcloud_appkey': cfg.appKey ?: ''
|
||||
]
|
||||
ndk {
|
||||
abiFilters = cfg.abis
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
signingConfigs {
|
||||
config {
|
||||
keyAlias cfg.signing.keyAlias
|
||||
keyPassword cfg.signing.keyPassword
|
||||
storeFile file('../../../' + cfg.signing.keystore)
|
||||
storePassword cfg.signing.storePassword
|
||||
v1SigningEnabled true
|
||||
v2SigningEnabled true
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
signingConfig signingConfigs.config
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
release {
|
||||
signingConfig signingConfigs.config
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
aaptOptions {
|
||||
additionalParameters '--auto-add-overlay'
|
||||
ignoreAssetsPattern "!.svn:!.git:.*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
|
||||
}
|
||||
}
|
||||
|
||||
// 每次构建前从 config 生成 dcloud_control.xml(appid)
|
||||
task generateDcloudControl {
|
||||
doLast {
|
||||
def controlFile = file('src/main/assets/data/dcloud_control.xml')
|
||||
controlFile.parentFile.mkdirs()
|
||||
controlFile.setText("<hbuilder>\n<apps>\n <app appid=\"${cfg.appId}\" appver=\"\"/>\n</apps>\n</hbuilder>\n", 'UTF-8')
|
||||
}
|
||||
}
|
||||
preBuild.dependsOn generateDcloudControl
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'], exclude: [])
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
|
||||
implementation 'androidx.core:core:1.1.0'
|
||||
implementation "androidx.fragment:fragment:1.1.0"
|
||||
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||
implementation 'com.facebook.fresco:fresco:2.5.0'
|
||||
implementation "com.facebook.fresco:animated-gif:2.5.0"
|
||||
implementation 'com.github.bumptech.glide:glide:4.9.0'
|
||||
implementation 'com.alibaba:fastjson:1.2.83'
|
||||
implementation 'androidx.webkit:webkit:1.5.0'
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
21
android-offline/HBuilder-Integrate-AS/simpleDemo/proguard-rules.pro
vendored
Normal file
21
android-offline/HBuilder-Integrate-AS/simpleDemo/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@ -0,0 +1,102 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<!-- 应用内更新安装 APK:
|
||||
INSTALL_PACKAGES 为 5+ Runtime plus.runtime.install 静默安装路径所需声明(非系统应用实际仍走 UI 安装器);
|
||||
REQUEST_INSTALL_PACKAGES 为 Android 8+ 未知来源安装授权,7.x 及以下仅依赖全局未知来源开关 -->
|
||||
<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<!-- ===== 以下权限集与 src/manifest.json 的 app-plus.distribute.android.permissions 保持一致 =====
|
||||
离线打包不会读取 manifest.json 的权限声明,必须在此处显式声明,
|
||||
增删权限时请同步两处,否则会出现「云打包能用、离线包缺权限」的差异。 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.FLASHLIGHT" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
|
||||
<!-- 日志/文件:DCloud base 运行时与打印/图片上传相关 -->
|
||||
<uses-permission android:name="android.permission.READ_LOGS" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<!-- 蓝牙打印/扫码枪:Android 12(API31) 起需用 BLUETOOTH_SCAN/CONNECT 取代 BLUETOOTH/BLUETOOTH_ADMIN -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:allowClearUserData="true"
|
||||
android:icon="@drawable/icon"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:extractNativeLibs="true"
|
||||
android:supportsRtl="true"
|
||||
android:usesCleartextTraffic="true">
|
||||
<activity
|
||||
android:name="io.dcloud.PandoraEntry"
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|navigation"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTask"
|
||||
android:hardwareAccelerated="true"
|
||||
android:theme="@style/TranslucentTheme"
|
||||
android:screenOrientation="user"
|
||||
android:exported="true"
|
||||
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="io.dcloud.PandoraEntryActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize|mcc|mnc|fontScale|keyboard|smallestScreenSize|screenLayout|screenSize|uiMode"
|
||||
android:hardwareAccelerated="true"
|
||||
android:permission="com.miui.securitycenter.permission.AppPermissionsEditor"
|
||||
android:screenOrientation="user"
|
||||
android:theme="@style/DCloudTheme"
|
||||
android:exported="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
<intent-filter>
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<data android:scheme=" " />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<meta-data
|
||||
android:name="dcloud_appkey"
|
||||
android:value="${dcloud_appkey}" />
|
||||
<!-- 开机自启:系统启动完成后自动拉起应用(见 BootReceiver.java) -->
|
||||
<receiver
|
||||
android:name=".BootReceiver"
|
||||
android:enabled="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@ -0,0 +1,5 @@
|
||||
<hbuilder>
|
||||
<apps>
|
||||
<app appid="__UNI__0B3DAD3" appver=""/>
|
||||
</apps>
|
||||
</hbuilder>
|
||||
@ -0,0 +1,92 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="MobileOptimized" content="320"/>
|
||||
<title>Error</title>
|
||||
<script type="text/javascript">
|
||||
// H5 plus事件处理
|
||||
var ws=null;
|
||||
function plusReady(){
|
||||
// Android处理返回键
|
||||
plus.key.addEventListener('backbutton',function(){
|
||||
(history.length==1)&&ws.close();
|
||||
var c=setTimeout(function(){
|
||||
ws.close();
|
||||
},1000);
|
||||
window.onbeforeunload=function(){
|
||||
clearTimeout(c);
|
||||
}
|
||||
history.go(-2);
|
||||
},false);
|
||||
ws=plus.webview.currentWebview();
|
||||
}
|
||||
if(window.plus){
|
||||
plusReady();
|
||||
}else{
|
||||
document.addEventListener('plusready',plusReady,false);
|
||||
}
|
||||
document.addEventListener('touchstart',function(){
|
||||
return false;
|
||||
},true);
|
||||
// 禁止选择
|
||||
document.oncontextmenu=function(){
|
||||
return false;
|
||||
};
|
||||
// 获取错误信息
|
||||
document.addEventListener("error",function(e){
|
||||
info.innerText="请求的页面("+e.url+")无法打开";
|
||||
console.log("请求的页面无法打开:"+e.href);
|
||||
},false);
|
||||
</script>
|
||||
<style>
|
||||
*{
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
html,body{
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
word-break: break-all;
|
||||
-webkit-touch-callout:none;
|
||||
-webkit-tap-highlight-color:rgba(0,0,0,0);
|
||||
}
|
||||
.button{
|
||||
width: 50%;
|
||||
font-size: 18px;
|
||||
font-weight: normal;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
padding: .5em 0em;
|
||||
margin: .5em auto;
|
||||
color: #333333;
|
||||
background-color: #EEEEEE;
|
||||
border: 1px solid #CCCCCC;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.button:active{
|
||||
background-color: #CCCCCC;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style="width:100%;height:20%;"></div>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 512 512" style="height:20%;width:30%">
|
||||
<g id="icomoon-ignore">
|
||||
<line stroke-width="1" x1="" y1="" x2="" y2="" stroke="#449FDB" opacity=""></line>
|
||||
</g>
|
||||
<path d="M256 0c-141.385 0-256 114.615-256 256s114.615 256 256 256 256-114.615 256-256-114.615-256-256-256zM352 128c17.673 0 32 14.327 32 32s-14.327 32-32 32-32-14.327-32-32 14.327-32 32-32zM160 128c17.673 0 32 14.327 32 32s-14.327 32-32 32-32-14.327-32-32 14.327-32 32-32zM352.049 390.37c-19.587-32.574-55.272-54.37-96.049-54.37s-76.462 21.796-96.049 54.37l-41.164-24.698c27.98-46.535 78.958-77.672 137.213-77.672s109.232 31.137 137.213 77.672l-41.164 24.698z" fill="#666666"></path>
|
||||
</svg>
|
||||
<p style="font-size:18px;font-weight:bolder;">We're sorry ...</p>
|
||||
<p id="info" style="font-size:12px;"></p>
|
||||
<!--<div class="button" onclick="history.back()">Retry</div>-->
|
||||
<div class="button" onclick="if(history.length == 1){ws.close();}else{ws.back();ws.back();}">Back</div>
|
||||
<div class="button" onclick="ws.close()">Close</div>
|
||||
<div class="button" onclick="plus.runtime.restart()">Restart</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -0,0 +1,46 @@
|
||||
<properties>
|
||||
<features>
|
||||
<feature name="Barcode" value="io.dcloud.feature.barcode2.BarcodeFeatureImpl"/>
|
||||
<feature name="Bluetooth" value="io.dcloud.feature.bluetooth.BluetoothFeature"/>
|
||||
<feature name="Maps" value="io.dcloud.js.map.amap.JsMapPluginImpl"/>
|
||||
<!--<feature name="Maps" value="io.dcloud.js.map.JsMapPluginImpl"/>-->
|
||||
<feature name="Contacts" value="io.dcloud.feature.contacts.ContactsFeatureImpl"/>
|
||||
<feature name="Messaging" value="io.dcloud.adapter.messaging.MessagingPluginImpl"/>
|
||||
<feature name="Camera" value="io.dcloud.js.camera.CameraFeatureImpl"/>
|
||||
<feature name="Console" value="io.dcloud.feature.pdr.LoggerFeatureImpl"/>
|
||||
<feature name="Device" value="io.dcloud.feature.device.DeviceFeatureImpl"/>
|
||||
<feature name="File" value="io.dcloud.js.file.FileFeatureImpl"/>
|
||||
<feature name="Proximity" value="io.dcloud.feature.sensor.ProximityFeatureImpl"/>
|
||||
<feature name="Storage" value="io.dcloud.feature.pdr.NStorageFeatureImpl"/>
|
||||
<feature name="Cache" value="io.dcloud.feature.pdr.CoreCacheFeatureImpl"/>
|
||||
<feature name="Invocation" value="io.dcloud.invocation.Invocation"/>
|
||||
<feature name="Navigator" value="io.dcloud.feature.ui.navigator.NavigatorUIFeatureImpl"/>
|
||||
<feature name="NativeUI" value="io.dcloud.feature.ui.nativeui.NativeUIFeatureImpl"/>
|
||||
<feature name="UI" value="io.dcloud.feature.ui.UIFeatureImpl">
|
||||
<module name="Navigator" value="io.dcloud.feature.ui.NavView"/>
|
||||
</feature>
|
||||
<feature name="Gallery" value="io.dcloud.js.gallery.GalleryFeatureImpl"/>
|
||||
<feature name="Downloader" value="io.dcloud.net.DownloaderFeatureImpl"/>
|
||||
<feature name="Uploader" value="io.dcloud.net.UploadFeature"/>
|
||||
<feature name="Zip" value="io.dcloud.feature.pdr.ZipFeature"/>
|
||||
<feature name="Audio" value="io.dcloud.feature.audio.AudioFeatureImpl"/>
|
||||
<feature name="Runtime" value="io.dcloud.feature.pdr.RuntimeFeatureImpl"/>
|
||||
<feature name="VideoPlayer" value="io.dcloud.media.MediaFeatureImpl"/>
|
||||
<feature name="LivePusher" value="io.dcloud.media.live.LiveMediaFeatureImpl"/>
|
||||
<feature name="XMLHttpRequest" value="io.dcloud.net.XMLHttpRequestFeature"/>
|
||||
<feature name="Statistic" value="io.dcloud.feature.statistics.StatisticsFeatureImpl"/>
|
||||
<feature name="Accelerometer" value="io.dcloud.feature.sensor.AccelerometerFeatureImpl"/>
|
||||
<feature name="Orientation" value="io.dcloud.feature.sensor.OrientationFeatureImpl"/>
|
||||
<feature name="NativeObj" value="io.dcloud.feature.nativeObj.FeatureImpl"/>
|
||||
<feature name="Geolocation" value="io.dcloud.js.geolocation.GeolocationFeatureImpl"/>
|
||||
<feature name="Stream" value="io.dcloud.appstream.js.StreamAppFeatureImpl"/>
|
||||
<feature name="plugintest" value="com.example.H5PlusPlugin.PGPlugintest"/>
|
||||
</features>
|
||||
|
||||
<services>
|
||||
<service name="push" value="io.dcloud.feature.aps.APSFeatureImpl"/>
|
||||
<service name="Statistic" value="io.dcloud.feature.statistics.StatisticsBootImpl"/>
|
||||
<service name="Downloader" value="io.dcloud.net.DownloaderBootImpl"/>
|
||||
<!--<service name="Maps" value="io.dcloud.js.map.MapInitImpl"/>-->
|
||||
</services>
|
||||
</properties>
|
||||
@ -0,0 +1,34 @@
|
||||
package com.gztbyc.pda_wms;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
/**
|
||||
* 开机自启:监听系统开机完成广播,自动拉起应用。
|
||||
* 说明:Android 3.1+ 要求应用至少被用户启动过一次后,BOOT_COMPLETED 才会送达。
|
||||
*/
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final String ACTION_QUICKBOOT_POWERON = "android.intent.action.QUICKBOOT_POWERON";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent == null || intent.getAction() == null) {
|
||||
return;
|
||||
}
|
||||
final String action = intent.getAction();
|
||||
if (!Intent.ACTION_BOOT_COMPLETED.equals(action) && !ACTION_QUICKBOOT_POWERON.equals(action)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Intent launch = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
|
||||
if (launch != null) {
|
||||
launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
context.startActivity(launch);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 启动失败不阻断系统广播
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<!-- app_name 由 build.gradle 从 config/android.json 动态注入(resValue),此处不再定义 -->
|
||||
</resources>
|
||||
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="DCloudActivityTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:colorEdgeEffect">#333333</item>
|
||||
<item name="android:windowBackground">@color/ime_background</item>
|
||||
<item name="android:forceDarkAllowed">false</item>
|
||||
</style>
|
||||
</resources>
|
||||
101
android-offline/README.md
Normal file
101
android-offline/README.md
Normal file
@ -0,0 +1,101 @@
|
||||
# Android 离线打包(WMS_PDA)
|
||||
|
||||
本目录是 DCloud 官方 **Android 离线打包**集成工程,用于在本地用命令行出 APK(不需要 Android Studio,也不依赖 DCloud 云打包)。
|
||||
|
||||
## 目录
|
||||
|
||||
| 路径 | 说明 | git |
|
||||
|---|---|---|
|
||||
| `HBuilder-Integrate-AS/` | Android Studio 集成工程,**已提交**(保证发布基座一致)。包名/版本/签名/应用名/appid/appKey 全部由 `simpleDemo/build.gradle` 在构建时从 `config/android.json` 与根 `package.json` 动态读取,工程内不含任何密码 | ✅ |
|
||||
| `HBuilder-Integrate-AS/simpleDemo/libs/` | 5+ Runtime 等 aar(`lib.5plus.base-release.aar`、`uniapp-v8-release.aar`、`breakpad`、`install-apk` 等) | ✅ |
|
||||
| `keystore/` | 签名密钥文件 | ❌ (忽略) |
|
||||
| `icon/` `splash/` | 图标与启动图源文件,`prepare.cjs` 用它们覆盖 `res/` 下同名资源 | ✅ |
|
||||
| `SDK/` | DCloud 离线 SDK 解压目录(体积大,约 165MB),仅在需要额外原生模块时才下载 | ❌ (忽略) |
|
||||
| `pack.ps1` | 命令行打包主脚本(JDK/SDK 探测 → 注入 → `gradlew assembleRelease`) | ✅ |
|
||||
| `prepare.cjs` | 注入 App 资源、覆盖图标/启动图、对齐 `compilerVersion` | ✅ |
|
||||
|
||||
## 一键打包
|
||||
|
||||
```powershell
|
||||
npm run build:apk # 发行包:生产编译 + 产物地址校验 + 离线打包
|
||||
npm run build:apk -- -Clean # gradle 全量重编
|
||||
npm run build:apk -- -NoInject # 跳过资源注入(已注入过时用)
|
||||
npm run android:pack:raw # 跳过前端编译,仅用现有 dist/build/app-plus 打包
|
||||
|
||||
npm run dev:adb # 测试包:注入开发地址 → 打包 → 装机 → 启动(产物进 release/android/dev)
|
||||
npm run dev:adb -- --prod-api # 测试包但指向生产(排查线上问题时用)
|
||||
npm run dev:adb -- --api=http://192.168.1.10:6060 --no-install
|
||||
```
|
||||
|
||||
产物:`release/android/wms-pda_v{版本}_release.apk`(测试包为 `release/android/dev/wms-pda_v{版本}_release_dev.apk`)。版本唯一来源是根 `package.json` 的 `version`(X.Y.Z),`versionCode` 自动推导为 `X*1000000 + Y*1000 + Z`。
|
||||
|
||||
> ⚠ **版本号要两处同步**:`package.json.version` 与 `src/manifest.json` 的 `versionName`/`versionCode`(后者供 HBuilderX 云打包使用)。`prepare.cjs` 会在打包前校验两者并告警,避免云包/离线包版本号不一致。
|
||||
>
|
||||
> 历名包在线上的 `versionCode` 是云打包时手工填的小数字(如 1.0.121 → 125),而离线方案会得到 `1000122` 这类值。**今后统一用 `package.json` 推导,不要再手工填小数字**,否则切回云打包时会变成「降级安装」被系统拦下。
|
||||
|
||||
## 图标与启动图
|
||||
|
||||
| 文件 | 来源 | 尺寸 |
|
||||
|---|---|---|
|
||||
| `icon/app-icon.png` | 从线上 APK(v1.0.121)`res/9T.png` 提取 | 512×512 |
|
||||
| `splash/splash.png` | 从线上 APK `res/-u.png` 提取 | 1242×2208(竖屏) |
|
||||
|
||||
`prepare.cjs` 会把它们覆盖到 `simpleDemo/src/main/res/drawable/{icon,splash}.png`。有更高清的原始图标(如 1024×1024)时直接覆盖 `icon/app-icon.png` 即可。
|
||||
|
||||
从任意 APK 里重新取素材的办法:
|
||||
|
||||
```powershell
|
||||
# 解包 APK 后用 aapt2 查出图标文件名,再按尺寸挑最大的一张
|
||||
& "$env:ANDROID_HOME\build-tools\35.0.0\aapt2.exe" dump badging <apk路径> | Select-String 'application-icon'
|
||||
```
|
||||
|
||||
环境要求:JDK 17+(脚本会自动探测 `JAVA_HOME`、Android Studio JBR 等常见位置)、Android SDK(`ANDROID_HOME`/`ANDROID_SDK_ROOT`/`local.properties` 任一即可)。
|
||||
|
||||
## 与云打包的差异(重要)
|
||||
|
||||
- **签名不同**:云打包用的是 DCloud 的证书,本地离线打包用 `config/android.json` 配置的 keystore。若此前对外发布过云打包版本,切换后**签名不一致、无法覆盖安装**(需先卸载重装);若包名+签名已被第三方 SDK/推送/应用商店绑定,需要重新登记。
|
||||
- **权限来自 AndroidManifest**:离线打包**不会**读取 `src/manifest.json` 的权限声明,权限必须写在 `HBuilder-Integrate-AS/simpleDemo/src/main/AndroidManifest.xml`。增删权限时请两处同步,否则会出现「云打包能用、离线包缺权限」的差异。
|
||||
- **明文 HTTP**:生产接口是 `http://qimen.wms.gztbyc.com`,所以 `<application>` 上显式声明了 `android:usesCleartextTraffic="true"`(Android 9+ 默认禁止明文 HTTP)。日后切 HTTPS 可移除。
|
||||
- **appKey 校验**:`appKey` 与 `appId` + 包名 + 证书 SHA-256 严格绑定,不匹配时 APK 能装能开但启动白屏提示「未配置appkey或配置错误」。详见 `config/README.md`。
|
||||
- **Runtime 版本提示**:`prepare.cjs` 会把 www 内 `manifest.json`/`app-config-service.js` 的 `compilerVersion` 对齐到 `config/android.json` 的 `runtimeVersion`,用于消除启动时「本应用使用 HBuilderX %s 编译,而手机端 SDK 版本是 %s」的提示。
|
||||
|
||||
## 5+ 模块(aar)与 manifest 里勾选的模块
|
||||
|
||||
离线打包**不会**自动带上 `src/manifest.json` 里勾选的模块,必须同时满足两个条件:
|
||||
|
||||
1. 该模块的 aar 放进 `HBuilder-Integrate-AS/simpleDemo/libs/`;
|
||||
2. 在 `simpleDemo/src/main/assets/data/dcloud_properties.xml` 里声明对应 `<feature>`。
|
||||
|
||||
否则运行时才报错(例如蓝牙会提示「缺少蓝牙模块」,且代码里找不到该文案——它来自 5+ 运行时)。
|
||||
|
||||
当前已包含:
|
||||
|
||||
| 模块 | 提供物 | 备注 |
|
||||
|---|---|---|
|
||||
| Bluetooth(蓝牙打印 / 蓝牙扫码枪) | `libs/Bluetooth-release.aar` + `<feature name="Bluetooth" value="io.dcloud.feature.bluetooth.BluetoothFeature"/>` | 从离线 SDK 的 `SDK/libs/` 复制;本工程最初缺这一项(骨架克隆自不使用蓝牙的项目) |
|
||||
| Barcode / Camera / File / Storage / Console 等 | `libs/lib.5plus.base-release.aar` | 基础运行时自带 |
|
||||
| Webview-x5 | 未单独引入 | 已比对线上云打包 APK:其原生库与本工程完全一致(无 X5 专属 so),故保持一致 |
|
||||
|
||||
新增其他模块时:到离线 SDK 的 `SDK/libs/` 找同名 aar(命名通常是 `<模块>-release.aar`,如 `geolocation-amap-release.aar`、`share-weixin-release.aar`、`speech-release.aar`),复制到 `libs/`,并在 `dcloud_properties.xml` 增加同名 `<feature>` 行——**类名最快来源是从已发布的云端 APK 里抄**:
|
||||
|
||||
```powershell
|
||||
# 解包云端 APK 后对比两份配置,差异即为缺失的模块声明
|
||||
# (线上包 assets/data/dcloud_properties.xml vs 本工程同名文件)
|
||||
```
|
||||
|
||||
验证模块是否真的打进包里:
|
||||
|
||||
```powershell
|
||||
tar -xf release\android\wms-pda_v*.apk -C $env:TEMP\apkchk
|
||||
findstr /m /c:"io/dcloud/feature/bluetooth" $env:TEMP\apkchk\*.dex
|
||||
```
|
||||
|
||||
## 首次使用清单
|
||||
|
||||
1. 在 `config/android.json` 填 `appKey`、`keyAlias`、`storePassword`、`keyPassword`(该文件不提交 git);
|
||||
2. 把对应证书放入 `android-offline/keystore/`;
|
||||
3. `npm run build:apk`。
|
||||
|
||||
> ⚠️ **`appKey` 必须与签名证书指纹匹配**。线上已发布 APK(云打包,签名证书 SHA-256 `d9689a9b…25d6ff`)内的 appKey 为 `f523d8541674ad75105fa604f5a51a54`——它**只对该 SHA-256 对应的证书有效**。若本地离线打包用的是自有 keystore(`android-offline/keystore/` 里那把),需先比对指纹,不一致则到 dev.dcloud.net.cn 重新申请,否则 APK 启动会白屏提示「未配置appkey或配置错误」。比对办法见 `config/README.md`。
|
||||
|
||||
> 发布上传(scp + `latest.json`)在 `pack.ps1` 内,但只有存在 `config/deploy.json` 时才会执行;本仓库不提供该文件,因此默认不会上传。
|
||||
BIN
android-offline/icon/app-icon.png
Normal file
BIN
android-offline/icon/app-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
3
android-offline/icon/璇存槑.txt
Normal file
3
android-offline/icon/璇存槑.txt
Normal file
@ -0,0 +1,3 @@
|
||||
app-icon.png 已生成(1024x1024,深蓝渐变 + 包裹箱 + 扫描线,无文字)。
|
||||
如需重新生成或调整设计,编辑 scripts/gen-android-assets.ps1 后运行:
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\gen-android-assets.ps1
|
||||
54
android-offline/license.md
Normal file
54
android-offline/license.md
Normal file
@ -0,0 +1,54 @@
|
||||
# html5plus runtime 使用许可协议
|
||||
本协议是数字天堂(北京)网络技术有限公司(以下称“DCloud”)与您之间达成的关于html5plus runtime及相关配套软件(以下简称本软件)的协议。
|
||||
本协议签订地点为中华人民共和国北京市海淀区。
|
||||
您使用本软件即视为您已阅读并同意受本协议的约束。
|
||||
|
||||
## 定义
|
||||
html5plus runtime,即DCloud公司提供的App端引擎,该引擎可用于5+App、wap2app、uni-app的App端打包,及5+sdk、uni小程序sdk等离线打包用sdk。
|
||||
本软件包含iOS版和Android版。
|
||||
|
||||
本软件包括很多模块,包括DCloud的uni统计、uni-AD、uniPush等业务的客户端sdk部分,也属于本产品的模块。但这些模块都可以由您自行选择是否启用。
|
||||
|
||||
## 知识产权及使用授权
|
||||
您可以自由下载、使用、复制本软件而不需要向DCloud付费。无时间和地域限制。
|
||||
DCloud所拥有的知识产权,包括但不限于商标、专利、著作权、商业秘密、专有数据、源码,并不发生转移或共享。
|
||||
您使用本软件开发的代码及输出物,即手机端移动应用,其知识产权归属您所有。
|
||||
类似于您开发的应用内嵌了jvm或.net framework,虽然您的java代码的著作权属于您,但jvm等三方runtime的知识产权仍归原作者所有。
|
||||
如果DCloud开源了某些代码,这些代码会有单独的开源许可协议并提供在github等网站的DCloud官方账号下。您可以在遵守这些开源协议的基础上使用DCloud开源的代码。
|
||||
本软件可能会使用第三方软件或技术,例如三方开源代码,这类使用已经确保遵循这些三方软件的授权协议。详细的列表在本软件目录下的ThirdPartyNotices文件中查阅。
|
||||
特别的,如果您使用uni小程序sdk,该产品的授权范围仅限制在原生App中将某个栏目或模块进行小程序化而使用,不可用于将uni-app前端代码打包成App。
|
||||
您不得破解、反编译、逆向工程本软件,不得破解或劫持本软件网络请求,不得对DCloud服务进行网络攻击,不得利用DCloud系统漏洞谋利或侵害DCloud利益,不得替换、删改本软件自带的非用户自定义文件。
|
||||
未经书面许可您不可利用DCloud产品的全部或部分文件、模块、组件来制作与DCloud争夺用户的产品。
|
||||
|
||||
|
||||
## 隐私条款
|
||||
DCloud尊重用户隐私,遵循国家对数据隐私保护的相关法律法规,并在此公开所有本软件会上报DCloud服务器的数据清单,以及说明数据采集的必要性。
|
||||
1. 异常崩溃、错误日志
|
||||
本软件发生错误异常、崩溃时,会将错误信息发送给DCloud服务器。
|
||||
这些信息除了错误内容,也包括应用基本信息(如appid、包名)和环境信息(如设备型号、os名称、版本、网络类型等)。
|
||||
同时DCloud会提供web界面供您查看了解崩溃情况。您可以分析错误在什么情况下产生,不同设备的崩溃率分布情况,并进行改进。
|
||||
由于开发者的代码为前端代码,无法捕获原生异常和崩溃。如果DCloud不提供此信息,您将无法了解相关情况,所以采集和输出报告是帮助您顺利使用本软件的必要举措。
|
||||
2. 启动速度性能分析
|
||||
本软件每次启动会记录启动时长,也包括上述应用基本信息和环境信息。
|
||||
同时DCloud会提供web界面供你了解相关性能报表。您可以分析在不同的设备、网络环境下您的应用的启动速度是否异常,并进行改进。
|
||||
由于开发者的代码为前端代码,无法记录App初始启动计时点。如果DCloud不提供此信息,您将无法了解相关情况,所以采集和输出报告是帮助您顺利使用本软件的必要举措。
|
||||
3. 本软件不会采集用户的短信、通讯录、相册、剪贴板信息,不会采集用户的摄像头、麦克风数据。
|
||||
4. 除非国家法律法规规定或得到您的许可,否则DCloud不会将采集的数据授权给任何第三方。
|
||||
5. 如果您使用了DCloud的其他联网业务,比如uni统计、uni-AD、uniPush,这些业务的隐私条款不包括在本协议中。
|
||||
|
||||
## 安全
|
||||
您理解并同意,本软件同其他软件一样,无法承诺绝对的安全性。
|
||||
当DCloud发现本软件的任何安全漏洞时,将及时在[社区](https://ask.dcloud.net.cn/explore/)发送公告,并将及时发布紧急更新补丁和升级推送通知。
|
||||
|
||||
## 免责声明和违约条款
|
||||
您在使用本软件前应进行有效评估,DCloud不因您使用本软件而承担任何法律责任或经济赔偿责任。
|
||||
如果您违反本协议,包括但不限于破解本软件,DCloud将有权停止您使用本软件,造成的损失由您自行承担。
|
||||
如果您给DCloud造成重大损失,或者在接收到DCloud的停止违约通知后拒不改正,DCloud将有权停止对您的DCloud所有产品和服务的使用授权,罚没您在DCloud所有产品服务中的预付款项和应收款项,因此造成的损失由您自行承担。
|
||||
如果您的行为产生法律问题,DCloud有权追责您的法律责任。
|
||||
|
||||
## 协议修订
|
||||
根据发展,DCloud可能会对本协议进行修改。修改时,DCloud会在产品或者网页中显著的位置发布相关信息以便及时通知到用户。如果您选择继续使用本软件,即表示您同意接受这些修改。
|
||||
|
||||
## 联系我们
|
||||
若您对本软件有任何疑问、意见和建议,欢迎联系我们:[网站](https://DCloud.io)
|
||||
若您对本协议有任何不满,希望更改条款,可以通过与 bd@dcloud.io 沟通,商谈您需要的付费版使用协议。
|
||||
338
android-offline/pack.ps1
Normal file
338
android-offline/pack.ps1
Normal file
@ -0,0 +1,338 @@
|
||||
# Command-line APK packaging for WMS_PDA (no Android Studio needed).
|
||||
# Flow: detect JDK/SDK -> inject config (prepare.cjs) -> gradlew assembleRelease -> copy APK to release/android/
|
||||
#
|
||||
# 发布上传默认关闭:未提供 config/deploy.json 时会跳过(本仓库不提供该文件)。
|
||||
#
|
||||
# Usage:
|
||||
# .\pack.ps1 # package release APK
|
||||
# .\pack.ps1 -Clean # full rebuild
|
||||
# .\pack.ps1 -Timestamp # keep timestamped artifact name
|
||||
# .\pack.ps1 -VersionName "1.0.2" # override version (written back to package.json; versionCode auto-derived)
|
||||
# .\pack.ps1 -VersionCode 10002 # manually set versionCode (rarely needed)
|
||||
# .\pack.ps1 -NoInject # skip prepare.cjs injection (already injected)
|
||||
# .\pack.ps1 -NoUpload # package only, skip publish upload (scp + latest.json)
|
||||
# .\pack.ps1 -JavaHome '...' -AndroidSdk '...'
|
||||
param(
|
||||
[switch]$Clean,
|
||||
[switch]$Timestamp,
|
||||
[switch]$NoInject,
|
||||
[switch]$NoUpload,
|
||||
[switch]$Dev,
|
||||
[string]$VersionName = "",
|
||||
[string]$VersionCode = "",
|
||||
[string]$JavaHome = "",
|
||||
[string]$AndroidSdk = ""
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
# ============ paths ============
|
||||
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$projRoot = Split-Path -Parent $root
|
||||
Set-Location $root
|
||||
|
||||
$asDir = Join-Path $root 'HBuilder-Integrate-AS'
|
||||
$module = 'simpleDemo'
|
||||
$appFile = 'wms-pda'
|
||||
$gradlew = Join-Path $asDir 'gradlew.bat'
|
||||
$distDir = Join-Path $projRoot 'release\android'
|
||||
# -Dev: 真机调试包(接口地址可能指向开发环境),单独目录 + 文件名后缀,绝不覆盖发行包
|
||||
if ($Dev) { $distDir = Join-Path $distDir 'dev' }
|
||||
$apkSource = Join-Path $asDir "$module\build\outputs\apk\release\$module-release.apk"
|
||||
$buildGradle = Join-Path $asDir "$module\build.gradle"
|
||||
$configPath = Join-Path $projRoot 'config\android.json'
|
||||
|
||||
# ============ JDK detect (JDK 17+ required) ============
|
||||
function Get-JavaMajorVersion([string]$javaExe) {
|
||||
$prev = $ErrorActionPreference
|
||||
$ErrorActionPreference = 'Continue'
|
||||
try {
|
||||
$out = (cmd /c "`"$javaExe`" -version 2>&1" | Out-String)
|
||||
} finally {
|
||||
$ErrorActionPreference = $prev
|
||||
}
|
||||
if ($out -match 'version\s+"1\.(\d+)') { return [int]$Matches[1] }
|
||||
if ($out -match 'version\s+"(\d+)') { return [int]$Matches[1] }
|
||||
return 0
|
||||
}
|
||||
|
||||
$jdkCandidates = @()
|
||||
if ($JavaHome) { $jdkCandidates += $JavaHome }
|
||||
if ($env:JAVA_HOME) { $jdkCandidates += $env:JAVA_HOME }
|
||||
$jdkCandidates += @(
|
||||
"$env:LOCALAPPDATA\Programs\EclipseAdoptium",
|
||||
"$env:LOCALAPPDATA\Programs\Android Studio\jbr",
|
||||
"C:\Program Files\Android\Android Studio\jbr",
|
||||
"D:\Program Files\Android\Android Studio\jbr",
|
||||
"$env:USERPROFILE\.jdks",
|
||||
"C:\Program Files\Java",
|
||||
"C:\Program Files\Eclipse Adoptium"
|
||||
)
|
||||
|
||||
$selectedJava = ""
|
||||
foreach ($c in $jdkCandidates) {
|
||||
if (-not $c) { continue }
|
||||
$javaExe = Join-Path $c 'bin\java.exe'
|
||||
if (-not (Test-Path $javaExe)) {
|
||||
$found = Get-ChildItem $c -Recurse -Filter java.exe -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
if ($found) { $javaExe = $found.FullName }
|
||||
}
|
||||
if (Test-Path $javaExe) {
|
||||
$major = Get-JavaMajorVersion $javaExe
|
||||
if ($major -ge 17) {
|
||||
$selectedJava = Split-Path -Parent (Split-Path -Parent $javaExe)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($selectedJava -and (Test-Path (Join-Path $selectedJava 'bin\java.exe'))) {
|
||||
$JavaHome = $selectedJava
|
||||
$env:JAVA_HOME = $JavaHome
|
||||
$env:Path = "$JavaHome\bin;$env:Path"
|
||||
} else {
|
||||
Write-Host ""
|
||||
Write-Host "[error] JDK 17+ not found. Install JDK 17+ (or Android Studio JBR) or use -JavaHome '...'." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# ============ Android SDK detect ============
|
||||
if (-not $AndroidSdk) { $AndroidSdk = $env:ANDROID_HOME }
|
||||
if (-not $AndroidSdk) { $AndroidSdk = $env:ANDROID_SDK_ROOT }
|
||||
$localProps = Join-Path $asDir 'local.properties'
|
||||
if (-not $AndroidSdk -and (Test-Path $localProps)) {
|
||||
$line = Select-String -Path $localProps -Pattern '^sdk\.dir=(.+)$'
|
||||
if ($line) { $AndroidSdk = [regex]::Replace($line.Matches[0].Groups[1].Value, '\\([\\:])', '$1') }
|
||||
}
|
||||
if (-not $AndroidSdk -or -not (Test-Path (Join-Path $AndroidSdk 'platform-tools'))) {
|
||||
$sdkCandidates = @(
|
||||
"$env:LOCALAPPDATA\Android\Sdk",
|
||||
"$env:USERPROFILE\AppData\Local\Android\Sdk",
|
||||
"C:\Android\Sdk",
|
||||
"D:\Android\Sdk"
|
||||
)
|
||||
foreach ($c in $sdkCandidates) {
|
||||
if (Test-Path (Join-Path $c 'platform-tools')) { $AndroidSdk = $c; break }
|
||||
}
|
||||
}
|
||||
if ($AndroidSdk -and (Test-Path (Join-Path $AndroidSdk 'platform-tools'))) {
|
||||
$env:ANDROID_HOME = $AndroidSdk
|
||||
$env:ANDROID_SDK_ROOT = $AndroidSdk
|
||||
$escaped = $AndroidSdk -replace '\\', '\\'
|
||||
$sdkLine = "sdk.dir=$escaped"
|
||||
if (Test-Path $localProps) {
|
||||
$props = Get-Content $localProps -Raw
|
||||
if ($props -match '(?m)^sdk\.dir=') {
|
||||
$props = $props -replace '(?m)^sdk\.dir=.*$', $sdkLine
|
||||
} else {
|
||||
$props = $props.TrimEnd() + "`r`n" + $sdkLine + "`r`n"
|
||||
}
|
||||
Set-Content -Path $localProps -Value $props -Encoding ASCII
|
||||
} else {
|
||||
Set-Content -Path $localProps -Value $sdkLine -Encoding ASCII
|
||||
}
|
||||
} else {
|
||||
Write-Host ""
|
||||
Write-Host "[error] Android SDK not found. Set ANDROID_HOME or use -AndroidSdk." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# ============ pre-check ============
|
||||
if (-not (Test-Path $gradlew)) { Write-Host "[error] gradlew not found: $gradlew" -ForegroundColor Red; exit 1 }
|
||||
if (-not (Test-Path $configPath)) { Write-Host "[error] config/android.json not found. Copy config/android.example.json to config/android.json first." -ForegroundColor Red; exit 1 }
|
||||
if (-not (Test-Path $buildGradle)) { Write-Host "[error] build.gradle not found: $buildGradle" -ForegroundColor Red; exit 1 }
|
||||
|
||||
# ============ version: single source of truth = package.json ============
|
||||
# versionName = package.json "version" (X.Y.Z, three-part)
|
||||
# versionCode = X*1000000 + Y*1000 + Z (derived; each part must be 0-999)
|
||||
$pkgPath = Join-Path $projRoot 'package.json'
|
||||
if (-not (Test-Path $pkgPath)) { Write-Host "[error] package.json not found: $pkgPath" -ForegroundColor Red; exit 1 }
|
||||
|
||||
$pkg = Get-Content $pkgPath -Raw -Encoding UTF8 | ConvertFrom-Json
|
||||
$verName = [string]$pkg.version
|
||||
|
||||
# -VersionName overrides and writes back to package.json (keeps exe/apk in sync)
|
||||
if ($VersionName) {
|
||||
$verName = $VersionName
|
||||
$raw = [System.IO.File]::ReadAllText($pkgPath, [System.Text.Encoding]::UTF8)
|
||||
$raw = $raw -replace '("version"\s*:\s*")[^"]*(")', ('${1}' + $VersionName + '${2}')
|
||||
[System.IO.File]::WriteAllText($pkgPath, $raw, (New-Object System.Text.UTF8Encoding($false)))
|
||||
Write-Host ""
|
||||
Write-Host "[update] version written back to package.json -> $VersionName" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
# versionCode: explicit -VersionCode wins, otherwise derived from X.Y.Z
|
||||
if ($VersionCode) {
|
||||
$verCode = $VersionCode
|
||||
} else {
|
||||
$parts = @($verName -split '\.')
|
||||
if ($parts.Count -lt 3) {
|
||||
Write-Host "[error] version '$verName' must be three-part (X.Y.Z)" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
$numX = [int]$parts[0]
|
||||
$numY = [int]$parts[1]
|
||||
$numZ = [int]$parts[2]
|
||||
if ($numX -gt 999 -or $numY -gt 999 -or $numZ -gt 999) {
|
||||
Write-Host "[error] each part of version '$verName' must be 0-999 (e.g. 1.0.101 is ok, 1.0.1000 is not)" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
$verCode = [string]($numX * 1000000 + $numY * 1000 + $numZ)
|
||||
Write-Host ""
|
||||
Write-Host "[info] versionCode derived: $verName -> $verCode" -ForegroundColor DarkGray
|
||||
}
|
||||
|
||||
$cfg = Get-Content $configPath -Raw -Encoding UTF8 | ConvertFrom-Json
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "================== uni-app Android packaging ==================" -ForegroundColor Cyan
|
||||
Write-Host " project : $root"
|
||||
Write-Host " appid : $($cfg.appId)"
|
||||
Write-Host " version : $verName ($verCode)"
|
||||
Write-Host " build : release"
|
||||
Write-Host " JDK : $($env:JAVA_HOME)"
|
||||
Write-Host " AndroidSDK: $($env:ANDROID_HOME)"
|
||||
Write-Host "===============================================================" -ForegroundColor Cyan
|
||||
|
||||
# ============ step 1: inject (prepare.cjs) ============
|
||||
if (-not $NoInject) {
|
||||
Write-Host ""
|
||||
Write-Host "[step 1/3] inject config + www resources (prepare.cjs) ..." -ForegroundColor Yellow
|
||||
node (Join-Path $root 'prepare.cjs')
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "[error] prepare.cjs failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
} else {
|
||||
Write-Host ""
|
||||
Write-Host "[step 1/3] -NoInject specified, skip prepare.cjs" -ForegroundColor DarkGray
|
||||
}
|
||||
|
||||
# ============ step 2: gradle build ============
|
||||
$step = 2
|
||||
if ($Clean) {
|
||||
Write-Host ""
|
||||
Write-Host "[step 2/3] gradle clean ..." -ForegroundColor Yellow
|
||||
Push-Location $asDir
|
||||
& $gradlew clean --console=plain
|
||||
$cleanCode = $LASTEXITCODE
|
||||
Pop-Location
|
||||
if ($cleanCode -ne 0) { Write-Host "[error] clean failed" -ForegroundColor Red; exit 1 }
|
||||
$step = 3
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "[step $step/3] gradle assembleRelease ..." -ForegroundColor Yellow
|
||||
Push-Location $asDir
|
||||
& $gradlew assembleRelease --console=plain
|
||||
$buildCode = $LASTEXITCODE
|
||||
Pop-Location
|
||||
if ($buildCode -ne 0) {
|
||||
Write-Host "[error] packaging failed (gradle exit code $buildCode)" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# ============ step 3: copy artifact ============
|
||||
if (-not (Test-Path $apkSource)) {
|
||||
Write-Host "[error] APK not found: $apkSource" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
if (-not (Test-Path $distDir)) { New-Item -ItemType Directory -Path $distDir -Force | Out-Null }
|
||||
|
||||
$apkSuffix = ''
|
||||
if ($Dev) { $apkSuffix = '_dev' }
|
||||
|
||||
if ($Timestamp) {
|
||||
$stamp = Get-Date -Format 'yyyyMMdd_HHmmss'
|
||||
$apkName = "${appFile}_v${verName}_release${apkSuffix}_${stamp}.apk"
|
||||
} else {
|
||||
$apkName = "${appFile}_v${verName}_release${apkSuffix}.apk"
|
||||
}
|
||||
$apkDest = Join-Path $distDir $apkName
|
||||
Copy-Item -Path $apkSource -Destination $apkDest -Force
|
||||
|
||||
$apkSize = [math]::Round((Get-Item $apkDest).Length / 1MB, 2)
|
||||
Write-Host ""
|
||||
Write-Host "================== packaging done ==================" -ForegroundColor Green
|
||||
Write-Host " artifact : $apkDest"
|
||||
Write-Host " size : ${apkSize} MB"
|
||||
Write-Host " version : $verName ($verCode)"
|
||||
Write-Host "===================================================" -ForegroundColor Green
|
||||
|
||||
# ============ publish upload (scp + latest.json, same flow as sandan project) ============
|
||||
$deployCfgPath = Join-Path $projRoot 'config\deploy.json'
|
||||
if ($NoUpload -or $Dev) {
|
||||
Write-Host ""
|
||||
Write-Host "[hint] -NoUpload/-Dev specified, skip publish upload" -ForegroundColor DarkGray
|
||||
} elseif (-not (Test-Path $deployCfgPath)) {
|
||||
Write-Host ""
|
||||
Write-Host "[hint] config/deploy.json not found, skip publish upload (copy config/deploy.example.json and fill real values)" -ForegroundColor DarkGray
|
||||
} else {
|
||||
$dcfg = Get-Content $deployCfgPath -Raw -Encoding UTF8 | ConvertFrom-Json
|
||||
$dcfg = $dcfg.android
|
||||
if (-not $dcfg) {
|
||||
Write-Host "[error] config/deploy.json missing android section" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
$dHost = [string]$dcfg.host
|
||||
$dUser = [string]$dcfg.user
|
||||
$dKey = [string]$dcfg.keyPath
|
||||
$dRemDir = ([string]$dcfg.remoteDir).TrimEnd('/')
|
||||
$dUrlPre = [string]$dcfg.downloadUrlPrefix
|
||||
$dPort = 22
|
||||
if ($dcfg.port) { $dPort = [int]$dcfg.port }
|
||||
$dLatest = 'latest.json'
|
||||
if ($dcfg.latestJsonName) { $dLatest = [string]$dcfg.latestJsonName }
|
||||
if ($dUrlPre -and -not $dUrlPre.EndsWith('/')) { $dUrlPre = $dUrlPre + '/' }
|
||||
|
||||
$missing = @()
|
||||
if (-not $dHost) { $missing += 'host' }
|
||||
if (-not $dUser) { $missing += 'user' }
|
||||
if (-not $dRemDir) { $missing += 'remoteDir' }
|
||||
if (-not $dUrlPre) { $missing += 'downloadUrlPrefix' }
|
||||
if ($missing.Count -gt 0) {
|
||||
Write-Host "[error] config/deploy.json missing fields: $($missing -join ', ')" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
if ($dKey -and -not (Test-Path $dKey)) {
|
||||
Write-Host "[error] SSH key not found: $dKey" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# generate latest.json (same directory as the APK)
|
||||
$sha256 = (Get-FileHash -Path $apkDest -Algorithm SHA256).Hash
|
||||
$dlUrl = "$dUrlPre$apkName"
|
||||
$publishedAt = (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')
|
||||
$latest = [ordered]@{
|
||||
version = $verName
|
||||
file = $apkName
|
||||
url = $dlUrl
|
||||
sha256 = $sha256
|
||||
publishedAtUtc = $publishedAt
|
||||
}
|
||||
$latestPath = Join-Path $distDir $dLatest
|
||||
[System.IO.File]::WriteAllText($latestPath, ($latest | ConvertTo-Json), (New-Object System.Text.UTF8Encoding($false)))
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "[publish] upload to ${dUser}@${dHost}:${dRemDir}/ ..." -ForegroundColor Yellow
|
||||
$scpArgs = @('-i', $dKey, '-P', "$dPort", '-o', 'StrictHostKeyChecking=accept-new')
|
||||
& scp @scpArgs $apkDest "${dUser}@${dHost}:${dRemDir}/"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "[error] APK upload failed (scp exit code $LASTEXITCODE)" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
& scp @scpArgs $latestPath "${dUser}@${dHost}:${dRemDir}/"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "[error] $dLatest upload failed (scp exit code $LASTEXITCODE)" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "================== publish done ==================" -ForegroundColor Green
|
||||
Write-Host " download : $dlUrl"
|
||||
Write-Host " sha256 : $sha256"
|
||||
Write-Host " updated : ${dRemDir}/${dLatest}"
|
||||
Write-Host "=================================================" -ForegroundColor Green
|
||||
}
|
||||
|
||||
exit 0
|
||||
178
android-offline/prepare.cjs
Normal file
178
android-offline/prepare.cjs
Normal file
@ -0,0 +1,178 @@
|
||||
/**
|
||||
* Android 离线打包准备脚本
|
||||
* 职责:校验 config/android.json、拷贝 App 资源(www)、覆盖图标/启动图。
|
||||
* 包名/版本/签名/应用名/appid/appKey 等由 simpleDemo/build.gradle 在构建时动态读取
|
||||
* config/android.json 与 package.json,本脚本不再写入工程文件。
|
||||
*
|
||||
* 用法:
|
||||
* node android-offline/prepare.cjs
|
||||
* node android-offline/prepare.cjs <wwwSource> # 可选:覆盖 www 资源目录
|
||||
*/
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const ROOT = path.resolve(__dirname, '..')
|
||||
const OFFLINE_DIR = __dirname
|
||||
const CONFIG_PATH = path.join(ROOT, 'config', 'android.json')
|
||||
|
||||
const log = (...args) => console.log('[prepare]', ...args)
|
||||
const warn = (...args) => console.warn('[prepare][警告]', ...args)
|
||||
|
||||
// ---------- 1. 读取配置 ----------
|
||||
let config
|
||||
try {
|
||||
config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'))
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
console.error(`[prepare][错误] 未找到配置文件: ${CONFIG_PATH}`)
|
||||
console.error('请复制 config/android.example.json 为 config/android.json 并填写(appKey、signing 等),详见 config/README.md')
|
||||
} else {
|
||||
console.error(`[prepare][错误] 配置文件解析失败 ${CONFIG_PATH}: ${error.message}`)
|
||||
}
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const required = ['appId', 'appName', 'packageName']
|
||||
for (const key of required) {
|
||||
if (!config[key]) {
|
||||
console.error(`[prepare][错误] config.json 缺少必填项: ${key}`)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 1.5 版本一致性校验 ----------
|
||||
// 离线包的 versionName/versionCode 由 simpleDemo/build.gradle 从 package.json 推导
|
||||
// (versionCode = X*1000000 + Y*1000 + Z);而 src/manifest.json 的 versionName/versionCode
|
||||
// 是 HBuilderX 云打包使用的值。两者必须一致,否则同一版本会出现两个 APK 版本号,
|
||||
// 应用内更新提示、版本排查都会对不上号。
|
||||
// 注:编译产物 www 内不含版本字段(实测),APK 版本完全由原生工程决定,故此处只做一致性校验。
|
||||
try {
|
||||
const pkgVersion = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf-8')).version
|
||||
const [x, y, z] = String(pkgVersion).split('.').map((n) => parseInt(n, 10))
|
||||
const expectedCode = x * 1000000 + y * 1000 + z
|
||||
|
||||
const manifestText = fs.readFileSync(path.join(ROOT, 'src', 'manifest.json'), 'utf-8')
|
||||
const mVersion = (manifestText.match(/"versionName"\s*:\s*"([^"]*)"/) || [])[1]
|
||||
const mCode = Number((manifestText.match(/"versionCode"\s*:\s*(\d+)/) || [])[1])
|
||||
|
||||
log(`版本: package.json=${pkgVersion} (versionCode ${expectedCode}) | src/manifest.json=${mVersion} (versionCode ${mCode})`)
|
||||
|
||||
if (mVersion !== pkgVersion || mCode !== expectedCode) {
|
||||
warn('package.json 与 src/manifest.json 版本号不一致,请两处同步(否则云打包/离线包会出现不同版本号)')
|
||||
}
|
||||
} catch (error) {
|
||||
warn(`版本一致性校验已跳过: ${error.message}`)
|
||||
}
|
||||
|
||||
// ---------- 2. 定位 SDK 工程 ----------
|
||||
const AS_DIR = path.join(OFFLINE_DIR, 'HBuilder-Integrate-AS')
|
||||
const DEMO_DIR = path.join(AS_DIR, 'simpleDemo')
|
||||
|
||||
if (!fs.existsSync(AS_DIR)) {
|
||||
console.error('[prepare][错误] 未找到离线 SDK 工程: ' + AS_DIR)
|
||||
console.error('请先下载离线 SDK 并解压到 android-offline/ 目录,详见 README.md')
|
||||
process.exit(1)
|
||||
}
|
||||
if (!fs.existsSync(DEMO_DIR)) {
|
||||
console.error('[prepare][错误] 未找到 simpleDemo 工程: ' + DEMO_DIR)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
let failed = false
|
||||
|
||||
// ---------- 3. 签名配置预检(Gradle 构建时从 config 动态读取) ----------
|
||||
if (!config.signing || !config.signing.keystore) {
|
||||
warn('config/android.json 中 signing.keystore 为空,Gradle 构建时将因缺少签名配置而失败')
|
||||
} else if (!fs.existsSync(path.resolve(ROOT, config.signing.keystore))) {
|
||||
warn(`签名文件不存在: ${path.resolve(ROOT, config.signing.keystore)}`)
|
||||
}
|
||||
if (!config.appKey) {
|
||||
warn('config/android.json 中 appKey 为空,请到 https://dev.dcloud.net.cn 申请后填写')
|
||||
}
|
||||
|
||||
// ---------- 4. 拷贝 App 资源到 assets/apps/{appId}/www ----------
|
||||
const wwwTarget = path.join(DEMO_DIR, 'src', 'main', 'assets', 'apps', config.appId, 'www')
|
||||
|
||||
// 可选外部 www 源覆盖:node prepare.cjs <wwwSource>;其次用 config.android.json 的 wwwSource
|
||||
const wwwOverride = process.argv[2] ? path.resolve(ROOT, process.argv[2]) : ''
|
||||
|
||||
const candidates = [
|
||||
...(wwwOverride ? [wwwOverride] : []),
|
||||
...(config.wwwSource ? [path.resolve(ROOT, config.wwwSource)] : []),
|
||||
path.join(ROOT, 'unpackage', 'resources', config.appId, 'www'),
|
||||
path.join(ROOT, 'dist', 'build', 'app-plus'),
|
||||
]
|
||||
|
||||
const wwwSource = candidates.find((dir) => fs.existsSync(dir))
|
||||
if (!wwwSource) {
|
||||
failed = true
|
||||
console.error('[prepare][错误] 未找到 App 资源,请先执行 npm run build:app-plus(或 HBuilderX 生成本地打包资源)')
|
||||
} else {
|
||||
fs.rmSync(wwwTarget, { recursive: true, force: true })
|
||||
fs.cpSync(wwwSource, wwwTarget, { recursive: true })
|
||||
log(`✓ 拷贝 App 资源: ${path.relative(ROOT, wwwSource)} -> assets/apps/${config.appId}/www`)
|
||||
}
|
||||
|
||||
// ---------- 4.5 对齐编译器版本(隐藏"HTML5+ Runtime 版本不一致"提示) ----------
|
||||
// CLI 构建资源时写入的 compilerVersion(如 5.07)与离线 SDK Runtime 版本不一致时,
|
||||
// 启动会弹"本应用使用HBuilderX %s 编译,而手机端SDK版本是 %s"对话框。
|
||||
// 此处把 www 内 manifest.json / app-config-service.js 的 compilerVersion 对齐到
|
||||
// config/android.json 的 runtimeVersion(默认 5.24,与离线 SDK 一致),即可消除提示。
|
||||
const runtimeVersion = config.runtimeVersion || '5.24'
|
||||
function alignCompilerVersion (filePath) {
|
||||
try {
|
||||
if (!fs.existsSync(filePath)) return
|
||||
let text = fs.readFileSync(filePath, 'utf-8')
|
||||
const re = /"compilerVersion"\s*:\s*"[^"]*"/g
|
||||
text = text.replace(re, '"compilerVersion": "' + runtimeVersion + '"')
|
||||
fs.writeFileSync(filePath, text, 'utf-8')
|
||||
log(`✓ 对齐 compilerVersion -> ${runtimeVersion}: ${path.relative(ROOT, filePath)}`)
|
||||
} catch (e) {
|
||||
warn(`对齐 compilerVersion 失败 ${filePath}: ${e.message}`)
|
||||
}
|
||||
}
|
||||
alignCompilerVersion(path.join(wwwTarget, 'manifest.json'))
|
||||
alignCompilerVersion(path.join(wwwTarget, 'app-config-service.js'))
|
||||
|
||||
// ---------- 9. 覆盖图标与启动图 ----------
|
||||
function findResFiles(pattern) {
|
||||
const resDir = path.join(DEMO_DIR, 'src', 'main', 'res')
|
||||
const hits = []
|
||||
if (!fs.existsSync(resDir)) return hits
|
||||
const walk = (dir) => {
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const full = path.join(dir, entry.name)
|
||||
if (entry.isDirectory()) walk(full)
|
||||
else if (pattern.test(entry.name)) hits.push(full)
|
||||
}
|
||||
}
|
||||
walk(resDir)
|
||||
return hits
|
||||
}
|
||||
|
||||
function applyImage(cfgPath, patterns, desc) {
|
||||
if (!cfgPath) return
|
||||
const image = path.resolve(ROOT, cfgPath)
|
||||
if (!fs.existsSync(image)) {
|
||||
warn(`${desc}不存在,跳过: ${image}`)
|
||||
return
|
||||
}
|
||||
const targets = findResFiles(patterns)
|
||||
if (targets.length === 0) {
|
||||
warn(`${desc}: 未在 res 下找到目标文件(正则: ${patterns}),请手动替换`)
|
||||
return
|
||||
}
|
||||
for (const target of targets) {
|
||||
fs.copyFileSync(image, target)
|
||||
log(`✓ 覆盖${desc}: ${path.relative(ROOT, target)}`)
|
||||
}
|
||||
}
|
||||
|
||||
applyImage(config.icon, /^(icon\.png|ic_launcher(\.png)?)$/i, '应用图标')
|
||||
applyImage(config.splash, /^splash(\.png|_screen\.png)?$/i, '启动图')
|
||||
|
||||
// ---------- 5. 总结 ----------
|
||||
console.log('\n[prepare] 完成' + (failed ? '(部分失败,请查看上方错误)' : ''))
|
||||
console.log('后续:包名/版本/签名/应用名/appid/appKey 由 Gradle 构建时从 config/android.json 与 package.json 动态读取')
|
||||
if (!failed) process.exit(0)
|
||||
process.exit(1)
|
||||
2010
android-offline/readme/AndroidThirdPartyNotices
Normal file
2010
android-offline/readme/AndroidThirdPartyNotices
Normal file
File diff suppressed because it is too large
Load Diff
99
android-offline/readme/readme.md
Normal file
99
android-offline/readme/readme.md
Normal file
@ -0,0 +1,99 @@
|
||||
**项目集成需要添加msa_mdid_1.0.13.aar文件,以便获取移动智能设备标识公共服务平台提供的匿名设备标识符[OAID](https://www.html5plus.org/doc/zh_cn/device.html#plus.device.getOAID)、开发者匿名设备标识符VAID、及应用匿名设备标识符AAID,可用于解决Android10无法获取设备标识(如IMEI、IMSI、Wi-Fi MAC地址等)的问题**
|
||||
|
||||
## 2.8.1.80296_20200722
|
||||
1. 离线sdk不再支持wap2app应用,云打包不受影响。
|
||||
2. 离线sdk不再支持JS/NVUE文件原生混淆加密,云打包不受影响。
|
||||
3. 新增uniapp-v8-release.aar,调整 JS引擎默认从 jscore 改为 V8,提升运算性能 [详情](https://ask.dcloud.net.cn/article/37465) **注意:uniapp-v8-release.aar与uniapp-release.aar只能同时使用一个,重复会导致编译失败。**
|
||||
|
||||
## 2.7.11.80231_20200602
|
||||
1. 新增debug-server-release.aar,生成自定义基座时使用,生成正式包时需删除。
|
||||
2. 新增aps-igexin-fcm-release.aar,使用方式可参考[文档](https://nativesupport.dcloud.net.cn/AppDocs/usemodule/androidModuleConfig/push)
|
||||
|
||||
## 2.7.0.80159_20200506
|
||||
|
||||
1. 自定义组件编译模式下线,应用默认以v3编译模式运行。并在manifest去除相关概念。后续版本dcloud1.dat、dcloud2.dat也不在需要。
|
||||
|
||||
## 2.6.0.74021_20200224
|
||||
1. 新增腾讯X5内核,使用时只需添加webview-x5-release.aar和weex_webview-x5-release.aar即可。
|
||||
|
||||
## 2.5.4.72919_20200108
|
||||
1. 添加uniAd模块,具体配置可参考文件Feature-Android.xls或链接 https://ask.dcloud.net.cn/article/36814
|
||||
|
||||
## 2.4.6.71983_20191211
|
||||
1. 添加amap-gp-libs-release.aar,供上传google play使用,注意:amap-gp-libs-release.aar与amap-libs-release.aar互斥,二者使用时只能选其一。
|
||||
|
||||
## 2.4.2.71156_20191115
|
||||
1. 更新uni-app依赖,去掉bindingX相关依赖。新版依赖如下,可以参考项目实例。
|
||||
~~~
|
||||
/*uniapp所需库-----------------------开始*/
|
||||
implementation 'com.android.support:recyclerview-v7:26.1.0'
|
||||
implementation 'com.facebook.fresco:fresco:1.13.0'
|
||||
implementation "com.facebook.fresco:animated-gif:1.13.0"
|
||||
/*uniapp所需库-----------------------结束*/
|
||||
~~~
|
||||
|
||||
## 2.3.5.70306_20191018
|
||||
1. 新增aps-unipush-gp-release.aar和aps-igexin-gp-release.aar,解决个推或UniPush上传谷歌市场失败的问题,注意:谷歌版个推与原个推存在类冲突,若出现冲突,删掉一个即可。
|
||||
2. 更新uni-app依赖,去掉okhttp相关依赖。新版依赖如下,可以参考项目实例。
|
||||
~~~
|
||||
/*uniapp所需库-----------------------开始*/
|
||||
implementation 'com.android.support:recyclerview-v7:26.1.0'
|
||||
implementation 'com.alibaba.android:bindingx-core:1.0.3'
|
||||
implementation 'com.alibaba.android:bindingx_weex_plugin:1.0.3'
|
||||
implementation 'com.facebook.fresco:fresco:1.13.0'
|
||||
implementation "com.facebook.fresco:animated-gif:1.13.0"
|
||||
/*uniapp所需库-----------------------结束*/
|
||||
~~~
|
||||
3. 若出现以dc.okio或dc.suqareup.okhttp的类冲突,删除libs目录下dc-okhttp-2.7.5.jar、dc-okhttp-ws-2.7.5.jar、dc-okio-1.6.0.jar即可。
|
||||
4. 本版删掉sina-libs-release.aar,集成时只需集成openDefault-4.4.1.aar即可。
|
||||
5. google play版个推在原个推配置上需添加如下内容
|
||||
~~~
|
||||
<service
|
||||
android:name="io.dcloud.feature.apsGt.GTPushDevService"
|
||||
android:exported="true"
|
||||
android:label="PushService"
|
||||
android:process=":pushservice" />
|
||||
<activity
|
||||
android:name="com.igexin.sdk.PrivacyActivity"
|
||||
android:exported="false"/>
|
||||
~~~
|
||||
|
||||
## 1.9.9.69546_20190920
|
||||
1. 更新依赖,默认需添加fastjson依赖
|
||||
~~~
|
||||
implementation 'com.alibaba:fastjson:1.1.46.android'
|
||||
~~~
|
||||
## 1.9.9.67817_20190812
|
||||
1. 离线SDK已支持64位处理器,[Android平台配置支持的CPU类型(64位)](http://ask.dcloud.net.cn/article/36195)
|
||||
2. 添加map、live-pusher、video等component,具体集成方式参考Feature-Android.xls。
|
||||
3. 将gif库提取为专门的aar使用,您可以引入android-gif-drawable-release@1.2.17.aar或者引用远程仓库文件。
|
||||
4. 鉴于新浪和支付宝SDK升级缘故,对应所需库也发生了变化,详情见Feature-Android.xls。
|
||||
|
||||
## 1.9.9.67034_20190729
|
||||
1. barcode改进,相应配置发生变化
|
||||
~~~
|
||||
<feature name="Barcode" value="io.dcloud.feature.barcode2.BarcodeFeatureImpl"/>
|
||||
~~~
|
||||
2. gallery改进,图片预览更流畅,需集成gallery-dmcBig-release.aar文件(非必须添加),具体显示效果可参考HBuilderX中基座gallery模块。
|
||||
3. 录制mp3格式音频需集成audio-mp3aac-release.aar文件(非必须添加)。
|
||||
4. 基座添加glide依赖,集成SDK时必须添加。
|
||||
5. 集成uni-app时必须添加如下依赖。
|
||||
~~~
|
||||
implementation 'com.android.support:recyclerview-v7:26.1.0'
|
||||
implementation 'com.alibaba.android:bindingx-core:1.0.3'
|
||||
implementation 'com.alibaba.android:bindingx_weex_plugin:1.0.3'
|
||||
implementation 'com.squareup.okhttp:okhttp:2.3.0'
|
||||
implementation 'com.squareup.okhttp:okhttp-ws:2.3.0'
|
||||
implementation 'com.alibaba:fastjson:1.1.46.android'
|
||||
implementation 'com.facebook.fresco:fresco:1.13.0'
|
||||
implementation "com.facebook.fresco:animated-gif:1.13.0"
|
||||
~~~
|
||||
6. 新增sqlite模块,配置方式
|
||||
~~~
|
||||
<feature name="Sqlite" value="io.dcloud.feature.sqlite.DataBaseFeature"/>
|
||||
~~~
|
||||
|
||||
7. 自定义组件模式下和集成uni-app时必须添加uniapp-release.aar
|
||||
8. 新增混淆配置文件,可参考SDK目录下proguard.cfg文件进行配置。
|
||||
|
||||
本sdk的使用许可,详见HBuilder X使用许可协议
|
||||
BIN
android-offline/splash/splash.png
Normal file
BIN
android-offline/splash/splash.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
3
android-offline/splash/璇存槑.txt
Normal file
3
android-offline/splash/璇存槑.txt
Normal file
@ -0,0 +1,3 @@
|
||||
splash.png 已生成(1920x1080 横屏,深蓝渐变 + 包裹箱 + 底部进度条,无文字)。
|
||||
如需重新生成或调整设计,编辑 scripts/gen-android-assets.ps1 后运行:
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\gen-android-assets.ps1
|
||||
81
babel.config.js
Normal file
81
babel.config.js
Normal file
@ -0,0 +1,81 @@
|
||||
const webpack = require('webpack')
|
||||
const plugins = []
|
||||
|
||||
if (process.env.UNI_OPT_TREESHAKINGNG) {
|
||||
plugins.push(require('@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js'))
|
||||
}
|
||||
|
||||
if (
|
||||
(
|
||||
process.env.UNI_PLATFORM === 'app-plus' &&
|
||||
process.env.UNI_USING_V8
|
||||
) ||
|
||||
(
|
||||
process.env.UNI_PLATFORM === 'h5' &&
|
||||
process.env.UNI_H5_BROWSER === 'builtin'
|
||||
)
|
||||
) {
|
||||
const path = require('path')
|
||||
|
||||
const isWin = /^win/.test(process.platform)
|
||||
|
||||
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
|
||||
|
||||
const input = normalizePath(process.env.UNI_INPUT_DIR)
|
||||
try {
|
||||
plugins.push([
|
||||
require('@dcloudio/vue-cli-plugin-hbuilderx/packages/babel-plugin-console'),
|
||||
{
|
||||
file (file) {
|
||||
file = normalizePath(file)
|
||||
if (file.indexOf(input) === 0) {
|
||||
return path.relative(input, file)
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
])
|
||||
} catch (e) { }
|
||||
}
|
||||
|
||||
process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']
|
||||
process.UNI_LIBRARIES.forEach(libraryName => {
|
||||
plugins.push([
|
||||
'import',
|
||||
{
|
||||
'libraryName': libraryName,
|
||||
'customName': (name) => {
|
||||
return `${libraryName}/lib/${name}/${name}`
|
||||
}
|
||||
}
|
||||
])
|
||||
})
|
||||
|
||||
if (process.env.UNI_PLATFORM !== 'h5') {
|
||||
plugins.push('@babel/plugin-transform-runtime')
|
||||
}
|
||||
|
||||
const config = {
|
||||
presets: [
|
||||
[
|
||||
'@vue/app',
|
||||
{
|
||||
modules: webpack.version[0] > 4 ? 'auto' : 'commonjs',
|
||||
useBuiltIns: process.env.UNI_PLATFORM === 'h5' ? 'usage' : 'entry'
|
||||
}
|
||||
]
|
||||
],
|
||||
plugins
|
||||
}
|
||||
|
||||
const UNI_H5_TEST = '**/@dcloudio/uni-h5/dist/index.umd.min.js'
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
config.overrides = [{
|
||||
test: UNI_H5_TEST,
|
||||
compact: true,
|
||||
}]
|
||||
} else {
|
||||
config.ignore = [UNI_H5_TEST]
|
||||
}
|
||||
|
||||
module.exports = config
|
||||
57
config/README.md
Normal file
57
config/README.md
Normal file
@ -0,0 +1,57 @@
|
||||
# config 目录说明
|
||||
|
||||
本目录存放打包/发布相关配置。**含密码等敏感信息的一律不提交 git**,配套的 `*.example.json` 模板提交。
|
||||
|
||||
| 文件 | 说明 | 是否提交 |
|
||||
|---|---|---|
|
||||
| `android.json` | Android 离线打包本地配置(appKey、签名密码等) | ❌ |
|
||||
| `android.example.json` | 上述配置的模板,首次使用复制为 `android.json` | ✅ |
|
||||
|
||||
## android.json 字段
|
||||
|
||||
| 字段 | 说明 |
|
||||
|---|---|
|
||||
| `appId` | uni-app appid。**本项目为 `__UNI__0B3DAD3`,不要与工作台/散单的 `__UNI__900BDC1` 混用** |
|
||||
| `appKey` | DCloud 离线打包 Key,**按 `appId + packageName + 签名证书 SHA-256` 三者绑定** |
|
||||
| `appName` | 桌面显示的应用名(构建时写入 `resValue app_name`) |
|
||||
| `packageName` | Android 包名(`applicationId` 与 gradle `namespace` 都由它决定,发布后不可更改) |
|
||||
| `abis` | CPU 架构。此处与 `src/manifest.json` 的 `abiFilters` 保持一致(`armeabi-v7a`、`arm64-v8a`) |
|
||||
| `icon` / `splash` | 图标/启动图路径(相对项目根),`prepare.cjs` 会用它们覆盖 `res/` 下的同名资源 |
|
||||
| `wwwSource` | App 资源目录。留空则依次尝试 `unpackage/resources/<appId>/www`、`dist/build/app-plus` |
|
||||
| `runtimeVersion` | 离线 SDK 的 5+ Runtime 版本。`prepare.cjs` 会把 www 内 `manifest.json`/`app-config-service.js` 的 `compilerVersion` 对齐到该值,避免启动时弹「HBuilderX %s 编译 / 手机端 SDK %s」提示 |
|
||||
| `signing.keystore` | 签名文件路径(相对项目根),放在 `android-offline/keystore/`(该目录 git 不跟踪) |
|
||||
| `signing.storePassword` / `keyAlias` / `keyPassword` | 签名密码与别名,**自己填写,不要提交**。DCloud 下发的 keystore(PKCS12)别名固定为 `__uni__` + appid 小写,本项目即 `__uni__0b3dad3`;PKCS12 的 `storePassword` 与 `keyPassword` 必须相同 |
|
||||
|
||||
## appKey 务必与三者一致
|
||||
|
||||
`appKey` 失效的典型表现:APK 能装能开,但启动即白屏并提示「未配置appkey或配置错误」。此时按顺序核对:
|
||||
|
||||
1. `appId` 是否为 `__UNI__0B3DAD3`;
|
||||
2. `packageName` 是否与申请 Key 时填写的包名一致;
|
||||
3. 证书 SHA-256 是否与申请 Key 时使用的一致:
|
||||
```
|
||||
keytool -list -v -keystore android-offline\keystore\<你的证书> -alias <别名>
|
||||
```
|
||||
输出里的 `SHA256:` 即为指纹。
|
||||
|
||||
需要更换包名或证书时,要先去 https://dev.dcloud.net.cn → 应用详情 → Android → 离线打包 Key 管理 重新申请(需填包名与证书 SHA-256)。
|
||||
|
||||
### 当前已知指纹(用于快速判断是否需要重新申请 Key)
|
||||
|
||||
| 用途 | 证书 SHA-256 | appKey |
|
||||
|---|---|---|
|
||||
| 线上已发布 APK(DCloud 云打包签名) | `d9689a9ba66e55e3002508b6ea9bb3bc086a2ba541df9cb86cdde43d6c25d6ff` | `f523d8541674ad75105fa604f5a51a54` |
|
||||
| 本地离线打包(自有 keystore) | 用下面命令查,**与左栏不一致就必须重新申请** | 重新申请后填入本文件 |
|
||||
|
||||
```powershell
|
||||
& "$env:JAVA_HOME\bin\keytool.exe" -list -v -keystore "d:\WMS_PDA\android-offline\keystore\<证书文件>"
|
||||
# 输出里的 SHA256: 即上表右栏要用的指纹
|
||||
```
|
||||
|
||||
> 签名不同会导致**无法覆盖安装**已发布的云打包版本(需先卸载重装),这是切离线打包的必然代价。
|
||||
|
||||
## 首次使用
|
||||
|
||||
1. 确认 `config/android.json` 已存在(本仓库已预填非敏感项),填写 `appKey`、`keyAlias`、`storePassword`、`keyPassword`;
|
||||
2. 确认 `android-offline/keystore/` 下有对应 keystore;
|
||||
3. 执行 `npm run build:apk`(= 生产编译 + 产物地址校验 + 离线打包)。
|
||||
17
config/android.example.json
Normal file
17
config/android.example.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"appId": "__UNI__0B3DAD3",
|
||||
"appKey": "",
|
||||
"appName": "WMS_PDA",
|
||||
"packageName": "com.gztbyc.pda_wms",
|
||||
"abis": ["armeabi-v7a", "arm64-v8a"],
|
||||
"icon": "android-offline/icon/app-icon.png",
|
||||
"splash": "android-offline/splash/splash.png",
|
||||
"wwwSource": "",
|
||||
"runtimeVersion": "5.24",
|
||||
"signing": {
|
||||
"keystore": "android-offline/keystore/xxx.keystore",
|
||||
"storePassword": "",
|
||||
"keyAlias": "__uni__0b3dad3",
|
||||
"keyPassword": ""
|
||||
}
|
||||
}
|
||||
4
env.js
4
env.js
@ -1,4 +0,0 @@
|
||||
// export const BASE_URL = 'http://qimen.wms.gztbyc.com' //生产环境接口地址
|
||||
export const BASE_URL = 'http://192.168.11.56:6060' //开发环境接口地址
|
||||
export const API_URL = `${BASE_URL}/system` //后台接口域名
|
||||
export const IMG_URL = 'https://ye4s.file.gzxunren.com' //全局网络图片地址变量,css背景图片地址变量在uni.scss
|
||||
57
package.json
57
package.json
@ -1,17 +1,66 @@
|
||||
{
|
||||
"id": "uview-ui",
|
||||
"name": "wms-pda",
|
||||
"version": "1.0.122",
|
||||
"private": true,
|
||||
"description": "天豹云仓 WMS_PDA(uni-app Vue2 + @vue/cli 4.5)",
|
||||
"scripts": {
|
||||
"serve": "npm run dev:h5",
|
||||
"build": "npm run build:h5",
|
||||
"dev:h5": "cross-env NODE_ENV=development UNI_PLATFORM=h5 NODE_OPTIONS=\"--openssl-legacy-provider --require=./scripts/node-compat.cjs\" vue-cli-service uni-serve",
|
||||
"dev:app-plus": "cross-env NODE_ENV=development UNI_PLATFORM=app-plus NODE_OPTIONS=\"--openssl-legacy-provider --require=./scripts/node-compat.cjs\" vue-cli-service uni-build --watch",
|
||||
"build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 NODE_OPTIONS=\"--openssl-legacy-provider --require=./scripts/node-compat.cjs\" vue-cli-service uni-build && node scripts/check-build-env.cjs dist/build/h5",
|
||||
"build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus NODE_OPTIONS=\"--openssl-legacy-provider --require=./scripts/node-compat.cjs\" vue-cli-service uni-build && node scripts/check-build-env.cjs dist/build/app-plus",
|
||||
"build:apk": "node scripts/build-apk.cjs",
|
||||
"dev:adb": "node scripts/dev-adb.cjs",
|
||||
"build:app-plus:dev": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus NODE_OPTIONS=\"--openssl-legacy-provider --require=./scripts/node-compat.cjs\" vue-cli-service uni-build",
|
||||
"android:pack:raw": "powershell -NoProfile -ExecutionPolicy Bypass -File android-offline/pack.ps1",
|
||||
"check:env": "node scripts/check-build-env.cjs",
|
||||
"lint": "eslint . --fix",
|
||||
"test": "eslint . --fix"
|
||||
},
|
||||
"dependencies": {
|
||||
"@dcloudio/uni-app": "2.0.2-5020620260917001",
|
||||
"@dcloudio/uni-app-plus": "2.0.2-5020620260917001",
|
||||
"@dcloudio/uni-h5": "2.0.2-5020620260917001",
|
||||
"@dcloudio/uni-i18n": "2.0.2-5020620260917001",
|
||||
"@dcloudio/uni-mp-vue": "2.0.2-5020620260917001",
|
||||
"@dcloudio/uni-mp-weixin": "2.0.2-5020620260917001",
|
||||
"@dcloudio/uni-stat": "2.0.2-5020620260917001",
|
||||
"core-js": "^3.8.3",
|
||||
"html2canvas": "^1.4.1",
|
||||
"pinyin-pro": "^3.28.0",
|
||||
"qrcode": "^1.5.4",
|
||||
"regenerator-runtime": "^0.12.1",
|
||||
"uni-read-pages": "^1.0.5",
|
||||
"uqrcodejs": "^4.0.7"
|
||||
"uqrcodejs": "^4.0.7",
|
||||
"vue": ">= 2.6.14 < 2.7",
|
||||
"vuex": "^3.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@dcloudio/uni-cli-i18n": "2.0.2-5020620260917001",
|
||||
"@dcloudio/uni-cli-shared": "2.0.2-5020620260917001",
|
||||
"@dcloudio/uni-migration": "2.0.2-5020620260917001",
|
||||
"@dcloudio/uni-template-compiler": "2.0.2-5020620260917001",
|
||||
"@dcloudio/vue-cli-plugin-hbuilderx": "2.0.2-5020620260917001",
|
||||
"@dcloudio/vue-cli-plugin-uni": "2.0.2-5020620260917001",
|
||||
"@dcloudio/vue-cli-plugin-uni-optimize": "2.0.2-5020620260917001",
|
||||
"@dcloudio/webpack-uni-mp-loader": "2.0.2-5020620260917001",
|
||||
"@dcloudio/webpack-uni-pages-loader": "2.0.2-5020620260917001",
|
||||
"@vue/cli-plugin-babel": "~4.5.0",
|
||||
"@vue/cli-service": "~4.5.0",
|
||||
"babel-plugin-import": "^1.11.0",
|
||||
"copy-webpack-plugin": "^5.1.2",
|
||||
"cross-env": "^7.0.2",
|
||||
"eslint": "^8.2.0",
|
||||
"eslint-config-airbnb": "^19.0.0"
|
||||
}
|
||||
"eslint-config-airbnb": "^19.0.0",
|
||||
"postcss": "^7.0.39",
|
||||
"postcss-comment": "^2.0.0",
|
||||
"sass": "~1.49.8",
|
||||
"sass-loader": "^8.0.2",
|
||||
"vue-template-compiler": ">= 2.6.14 < 2.7"
|
||||
},
|
||||
"browserslist": [
|
||||
"Android >= 4.4",
|
||||
"iOS >= 9"
|
||||
]
|
||||
}
|
||||
|
||||
@ -1,732 +0,0 @@
|
||||
<template>
|
||||
<view class="inventory-count-page">
|
||||
<view class="normar_container">
|
||||
<page-nav title="库存盘点"></page-nav>
|
||||
|
||||
<!-- 搜索区 -->
|
||||
<view class="search-panel">
|
||||
<view class="search-input-wrap">
|
||||
<u-search
|
||||
v-model="keyword"
|
||||
placeholder="请输入/扫描盘点单号或标题"
|
||||
:bg-color="'#f5f5f5'"
|
||||
shape="round"
|
||||
:show-action="false"
|
||||
@search="handleSearch"
|
||||
@clear="handleClear"
|
||||
></u-search>
|
||||
<view class="search-actions">
|
||||
<view class="scan-btn" @click="handleCameraScan">
|
||||
<u-icon name="scan" size="38rpx" color="#2979ff"></u-icon>
|
||||
</view>
|
||||
<view class="search-divider"></view>
|
||||
<view class="search-btn" @click="handleSearch">
|
||||
<text class="search-btn__text">搜索</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view class="filter-scroll" scroll-x :show-scrollbar="false">
|
||||
<view class="filter-group">
|
||||
<view
|
||||
v-for="opt in statusOptions"
|
||||
:key="opt.value"
|
||||
class="filter-group__item"
|
||||
:class="{ 'filter-group__item--active': statusFilter === opt.value }"
|
||||
@click="handleStatusChange(opt.value)"
|
||||
>
|
||||
<text class="filter-group__item-text">{{ opt.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
|
||||
<!-- 列表区 -->
|
||||
<scroll-view class="detail-scroll" scroll-y>
|
||||
<view v-if="recordList.length === 0" class="empty-state">
|
||||
<u-icon name="list" size="86" color="#c0c4cc"></u-icon>
|
||||
<text class="empty-text">{{ loading ? '加载中...' : '暂无盘点任务' }}</text>
|
||||
<text class="empty-hint">{{ keyword ? '请检查关键字后重试' : '请在上方输入关键字查询' }}</text>
|
||||
</view>
|
||||
<view v-else class="record-list">
|
||||
<view
|
||||
v-for="(item, index) in recordList"
|
||||
:key="item.id || index"
|
||||
class="record-card"
|
||||
:class="{ 'record-card--stripe': index % 2 === 1 }"
|
||||
@click="handleRecordClick(item)"
|
||||
>
|
||||
<view class="record-card__row">
|
||||
<text class="record-card__label">盘点单号</text>
|
||||
<text class="record-card__value record-card__value--strong">{{ item.checkNo || '--' }}</text>
|
||||
</view>
|
||||
<view v-if="item.title" class="record-card__row">
|
||||
<text class="record-card__label">标题</text>
|
||||
<text class="record-card__value">{{ item.title }}</text>
|
||||
</view>
|
||||
<view class="record-card__row">
|
||||
<text class="record-card__label">盘点类型</text>
|
||||
<text class="record-card__value">{{ item.typeText || '--' }}</text>
|
||||
</view>
|
||||
<view class="record-card__row">
|
||||
<text class="record-card__label">状态</text>
|
||||
<text class="record-card__value" :class="item.statusClass">{{ item.statusText || '--' }}</text>
|
||||
</view>
|
||||
<view v-if="item.progressText" class="record-card__row">
|
||||
<text class="record-card__label">进度</text>
|
||||
<text class="record-card__value">{{ item.progressText }}</text>
|
||||
</view>
|
||||
<view class="record-card__row">
|
||||
<text class="record-card__label">创建人</text>
|
||||
<text class="record-card__value">{{ item.operator || '--' }}</text>
|
||||
</view>
|
||||
<view class="record-card__row record-card__row--last">
|
||||
<text class="record-card__label">创建时间</text>
|
||||
<text class="record-card__value">{{ item.timeText || '--' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="safe-area-bottom"></view>
|
||||
</scroll-view>
|
||||
|
||||
<!-- 分页 -->
|
||||
<view class="pagination-wrap">
|
||||
<pagination
|
||||
:pageNum.sync="currentPage"
|
||||
:pageSize="pageSize"
|
||||
:total="paginationTotal"
|
||||
:showTotal="true"
|
||||
:prevText="'上一页'"
|
||||
:nextText="'下一页'"
|
||||
:showFirstLast="true"
|
||||
:firstText="'首页'"
|
||||
:lastText="'末页'"
|
||||
@change="handlePageChange"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
keyword: '',
|
||||
statusFilter: '',
|
||||
statusOptions: [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '待盘点', value: 'approved' },
|
||||
{ label: '盘点中', value: 'checking' },
|
||||
{ label: '已完成', value: 'completed' },
|
||||
{ label: '已取消', value: 'cancelled' }
|
||||
],
|
||||
pageSize: 20,
|
||||
currentPage: 1,
|
||||
paginationTotal: 0,
|
||||
recordList: [],
|
||||
loading: false,
|
||||
_listLoaded: false
|
||||
}
|
||||
},
|
||||
onLoad(options = {}) {
|
||||
// 支持通过 ?keyword=xxx 预填关键字并自动查询
|
||||
const preset = String(options.keyword || '').trim();
|
||||
if (preset) {
|
||||
this.keyword = preset;
|
||||
this.$nextTick(() => this.loadRecordList(1));
|
||||
} else {
|
||||
this.loadRecordList(1);
|
||||
}
|
||||
this.safeDispatchBroadcast('setCallbacks', { onResult: this.handleBroadcastResult });
|
||||
this.safeDispatchBroadcast('start');
|
||||
},
|
||||
onShow() {
|
||||
this.safeDispatchBroadcast('setCallbacks', { onResult: this.handleBroadcastResult });
|
||||
this.safeDispatchBroadcast('resume');
|
||||
this.scheduleBroadcastSelfHeal();
|
||||
// 从详情页返回时刷新列表,保证状态与详情页操作一致
|
||||
if (this._listLoaded) {
|
||||
this.loadRecordList(this.currentPage);
|
||||
}
|
||||
this._listLoaded = true;
|
||||
},
|
||||
onHide() {
|
||||
this.safeDispatchBroadcast('pause');
|
||||
},
|
||||
onUnload() {
|
||||
if (this._broadcastHealTimer) {
|
||||
clearTimeout(this._broadcastHealTimer);
|
||||
this._broadcastHealTimer = null;
|
||||
}
|
||||
this.safeDispatchBroadcast('stop');
|
||||
},
|
||||
methods: {
|
||||
// ===== 广播/扫码基础设施 =====
|
||||
safeDispatchBroadcast(action, payload) {
|
||||
try {
|
||||
const task = this.$store.dispatch(`broadcast/${action}`, payload);
|
||||
if (task && typeof task.catch === 'function') {
|
||||
task.catch(error => console.warn(`[inventoryCount] broadcast/${action} 调用失败:`, error));
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`[inventoryCount] broadcast/${action} 调用异常:`, error);
|
||||
}
|
||||
},
|
||||
scheduleBroadcastSelfHeal() {
|
||||
if (this._broadcastHealTimer) {
|
||||
clearTimeout(this._broadcastHealTimer);
|
||||
}
|
||||
this._broadcastHealTimer = setTimeout(() => {
|
||||
// 兼容跳转时序竞态:旧页 onHide 的 pause(=stop) 可能晚于本页 onShow 执行,导致广播被误停
|
||||
this.safeDispatchBroadcast('setCallbacks', { onResult: this.handleBroadcastResult });
|
||||
this.safeDispatchBroadcast('start');
|
||||
}, 1200);
|
||||
},
|
||||
normalizeScanResult(scanResult) {
|
||||
if (!scanResult) return '';
|
||||
if (typeof scanResult === 'string') return scanResult.trim();
|
||||
if (typeof scanResult.result === 'string') return scanResult.result.trim();
|
||||
if (Array.isArray(scanResult.result)) {
|
||||
const first = scanResult.result.find(item => item);
|
||||
if (typeof first === 'string') return first.trim();
|
||||
if (first && typeof first.data === 'string') return first.data.trim();
|
||||
}
|
||||
if (typeof scanResult.data === 'string') return scanResult.data.trim();
|
||||
return '';
|
||||
},
|
||||
handleBroadcastResult(result) {
|
||||
const code = this.normalizeScanResult(result);
|
||||
if (!code) return;
|
||||
this.keyword = code;
|
||||
this.loadRecordList(1);
|
||||
},
|
||||
handleCameraScan() {
|
||||
uni.scanCode({
|
||||
onlyFromCamera: true,
|
||||
scanType: ['qrCode', 'barCode', 'datamatrix', 'pdf417'],
|
||||
success: (res) => {
|
||||
const code = this.normalizeScanResult(res);
|
||||
if (!code) return;
|
||||
this.keyword = code;
|
||||
this.loadRecordList(1);
|
||||
},
|
||||
fail: () => {}
|
||||
});
|
||||
},
|
||||
// ===== 查询 =====
|
||||
handleSearch() {
|
||||
this.loadRecordList(1);
|
||||
},
|
||||
handleClear() {
|
||||
this.keyword = '';
|
||||
this.loadRecordList(1);
|
||||
},
|
||||
handleStatusChange(value) {
|
||||
if (this.statusFilter === value) return;
|
||||
this.statusFilter = value;
|
||||
this.recordList = [];
|
||||
this.paginationTotal = 0;
|
||||
this.loadRecordList(1);
|
||||
},
|
||||
handlePageChange(page) {
|
||||
const targetPage = Math.max(1, Number(page || 1));
|
||||
if (targetPage === this.currentPage) return;
|
||||
this.currentPage = targetPage;
|
||||
this.loadRecordList(targetPage);
|
||||
},
|
||||
handleRecordClick(item) {
|
||||
if (!item || !item.id) return;
|
||||
this.$tools.routerTo(`/pages/warehouse/inventoryCountDetail?id=${encodeURIComponent(item.id)}`);
|
||||
},
|
||||
buildRecordParams(page = this.currentPage) {
|
||||
const targetPage = Math.max(1, Number(page || 1));
|
||||
const pageSize = Math.max(1, Number(this.pageSize || 20));
|
||||
const params = {
|
||||
pagination: {
|
||||
page: targetPage,
|
||||
pageSize
|
||||
}
|
||||
};
|
||||
const where = {};
|
||||
const keyword = String(this.keyword || '').trim();
|
||||
if (keyword) {
|
||||
where.keyword = keyword;
|
||||
}
|
||||
if (this.statusFilter) {
|
||||
where.status = this.statusFilter;
|
||||
} else {
|
||||
// 列表仅展示以下四种状态,过滤掉 created/submitted/rejected
|
||||
where.status = ['approved', 'checking', 'completed', 'cancelled'];
|
||||
}
|
||||
if (Object.keys(where).length) {
|
||||
params.where = where;
|
||||
}
|
||||
return params;
|
||||
},
|
||||
extractRecordPayload(response) {
|
||||
const candidates = [
|
||||
response?.data?.data,
|
||||
response?.data,
|
||||
response?.result,
|
||||
response
|
||||
];
|
||||
for (let i = 0; i < candidates.length; i += 1) {
|
||||
const current = candidates[i];
|
||||
if (current && typeof current === 'object' && !Array.isArray(current)) {
|
||||
return current;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
},
|
||||
extractRecordList(payload, response) {
|
||||
const candidates = [
|
||||
payload?.list,
|
||||
payload?.rows,
|
||||
payload?.items,
|
||||
payload?.records,
|
||||
payload?.data?.list,
|
||||
response?.data?.list,
|
||||
response?.data?.data?.list,
|
||||
response?.list
|
||||
];
|
||||
for (let i = 0; i < candidates.length; i += 1) {
|
||||
if (Array.isArray(candidates[i])) return candidates[i];
|
||||
}
|
||||
return [];
|
||||
},
|
||||
resolveRecordTotal(payload, response, list) {
|
||||
const pagination = (payload && typeof payload === 'object') ? (payload.pagination || {}) : {};
|
||||
const candidates = [
|
||||
pagination?.total,
|
||||
pagination?.count,
|
||||
payload?.pagination?.total,
|
||||
payload?.total,
|
||||
payload?.count,
|
||||
payload?.totalCount,
|
||||
response?.data?.pagination?.total,
|
||||
response?.data?.total,
|
||||
response?.total,
|
||||
Array.isArray(list) ? list.length : 0
|
||||
];
|
||||
for (let i = 0; i < candidates.length; i += 1) {
|
||||
const value = Number(candidates[i]);
|
||||
if (Number.isFinite(value) && value >= 0) return value;
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
firstValue(source, keys) {
|
||||
for (let i = 0; i < keys.length; i += 1) {
|
||||
const value = source[keys[i]];
|
||||
if (value !== null && value !== undefined && String(value).trim() !== '') {
|
||||
return String(value).trim();
|
||||
}
|
||||
}
|
||||
return '';
|
||||
},
|
||||
formatDateTime(value) {
|
||||
if (value === null || value === undefined || value === '') return '';
|
||||
const date = new Date(String(value).trim());
|
||||
if (Number.isNaN(date.getTime())) return String(value).trim();
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const hour = String(date.getHours()).padStart(2, '0');
|
||||
const minute = String(date.getMinutes()).padStart(2, '0');
|
||||
const second = String(date.getSeconds()).padStart(2, '0');
|
||||
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
||||
},
|
||||
statusText(status) {
|
||||
const map = {
|
||||
created: '待提交',
|
||||
submitted: '待审核',
|
||||
rejected: '已驳回',
|
||||
approved: '待盘点',
|
||||
checking: '盘点中',
|
||||
completed: '已完成',
|
||||
cancelled: '已取消'
|
||||
};
|
||||
const key = String(status || '').trim().toLowerCase();
|
||||
return map[key] || (status ? String(status) : '--');
|
||||
},
|
||||
statusClass(status) {
|
||||
const key = String(status || '').trim().toLowerCase();
|
||||
if (key === 'completed') {
|
||||
return 'record-card__value--success';
|
||||
}
|
||||
if (key === 'checking') {
|
||||
return 'record-card__value--warning';
|
||||
}
|
||||
if (key === 'rejected') {
|
||||
return 'record-card__value--danger';
|
||||
}
|
||||
if (key === 'cancelled') {
|
||||
return 'record-card__value--muted';
|
||||
}
|
||||
if (key === 'approved') {
|
||||
return 'record-card__value--strong';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
typeText(type) {
|
||||
const map = {
|
||||
all: '全盘',
|
||||
full: '全盘',
|
||||
open: '明盘',
|
||||
store: '按货主',
|
||||
part: '抽盘',
|
||||
partial: '抽盘',
|
||||
dynamic: '动销盘',
|
||||
cycle: '循环盘'
|
||||
};
|
||||
const key = String(type || '').trim().toLowerCase();
|
||||
return map[key] || (type ? String(type) : '--');
|
||||
},
|
||||
modeText(mode) {
|
||||
const map = {
|
||||
all: '全盘',
|
||||
full: '全盘',
|
||||
open: '明盘',
|
||||
store: '按货主',
|
||||
by_store: '按货主',
|
||||
owner: '按货主',
|
||||
by_owner: '按货主',
|
||||
space: '按库位',
|
||||
by_space: '按库位',
|
||||
location: '按库位',
|
||||
item: '按商品',
|
||||
by_item: '按商品',
|
||||
product: '按商品'
|
||||
};
|
||||
const key = String(mode || '').trim().toLowerCase();
|
||||
return map[key] || (mode ? String(mode) : '');
|
||||
},
|
||||
composeType(type, mode) {
|
||||
const t = this.typeText(type);
|
||||
const m = this.modeText(mode);
|
||||
if (t === '--') return m || '--';
|
||||
return m ? `${t},${m}` : t;
|
||||
},
|
||||
normalizeRecordList(list) {
|
||||
if (!Array.isArray(list)) return [];
|
||||
return list
|
||||
.map((item, index) => {
|
||||
const source = item && typeof item === 'object' ? item : {};
|
||||
const checkNo = this.firstValue(source, [
|
||||
'check_no', 'checkNo', 'bill_no', 'billNo', 'code', 'no'
|
||||
]);
|
||||
const title = this.firstValue(source, ['title', 'name']);
|
||||
const typeValue = this.firstValue(source, ['check_type', 'checkType', 'type']);
|
||||
const modeValue = this.firstValue(source, ['mode', 'check_mode', 'checkMode']);
|
||||
const operator = this.firstValue(source, [
|
||||
'creator_name', 'creatorName', 'operator_name', 'operatorName',
|
||||
'create_user', 'createUser', 'creator', 'created_by', 'createdBy'
|
||||
]);
|
||||
const timeValue = this.firstValue(source, [
|
||||
'created_at', 'createdAt', 'create_time', 'createTime'
|
||||
]);
|
||||
const status = this.firstValue(source, ['status', 'check_status', 'checkStatus', 'state']);
|
||||
const totalItems = this.firstValue(source, ['total_items', 'totalItems']);
|
||||
const checkedItems = this.firstValue(source, ['checked_items', 'checkedItems']);
|
||||
let progressText = '';
|
||||
if (totalItems !== '') {
|
||||
progressText = checkedItems !== '' ? `${checkedItems}/${totalItems}` : `0/${totalItems}`;
|
||||
}
|
||||
const id = this.firstValue(source, ['id', 'check_id', 'checkId', 'task_id', 'taskId'])
|
||||
|| `${this.currentPage}-${index + 1}`;
|
||||
return {
|
||||
id,
|
||||
checkNo,
|
||||
title,
|
||||
typeText: this.composeType(typeValue, modeValue),
|
||||
operator,
|
||||
progressText,
|
||||
status,
|
||||
statusText: this.statusText(status),
|
||||
statusClass: this.statusClass(status),
|
||||
timeText: this.formatDateTime(timeValue)
|
||||
};
|
||||
})
|
||||
.filter(item => !!(item.checkNo || item.title || item.operator));
|
||||
},
|
||||
async loadRecordList(page = this.currentPage) {
|
||||
const targetPage = Math.max(1, Number(page || 1));
|
||||
this.loading = true;
|
||||
try {
|
||||
const response = await this.$http('check.list', this.buildRecordParams(targetPage));
|
||||
const payload = this.extractRecordPayload(response);
|
||||
const list = this.extractRecordList(payload, response);
|
||||
this.recordList = this.normalizeRecordList(list);
|
||||
this.paginationTotal = this.resolveRecordTotal(payload, response, list);
|
||||
const pageInfo = (payload && typeof payload === 'object') ? (payload.pagination || {}) : {};
|
||||
const pageNo = Number(pageInfo?.page ?? payload?.page ?? targetPage);
|
||||
this.currentPage = Number.isFinite(pageNo) && pageNo > 0 ? pageNo : targetPage;
|
||||
const pageSize = Number(pageInfo?.pageSize ?? pageInfo?.page_size ?? this.pageSize);
|
||||
this.pageSize = Number.isFinite(pageSize) && pageSize > 0 ? pageSize : this.pageSize;
|
||||
} catch (error) {
|
||||
console.error('[inventoryCount] 盘点任务加载失败:', error);
|
||||
this.recordList = [];
|
||||
this.paginationTotal = 0;
|
||||
uni.showToast({ title: '盘点任务加载失败', icon: 'none' });
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.inventory-count-page {
|
||||
height: 100vh;
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.normar_container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 搜索区 */
|
||||
.search-panel {
|
||||
background: #ffffff;
|
||||
border-bottom: 1rpx solid #f2f2f2;
|
||||
padding: 16rpx;
|
||||
box-sizing: border-box;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.search-input-wrap {
|
||||
position: relative;
|
||||
|
||||
::v-deep .u-search {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
::v-deep .u-search__content {
|
||||
padding-right: 200rpx;
|
||||
}
|
||||
|
||||
::v-deep .u-search__content__close {
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.search-actions {
|
||||
position: absolute;
|
||||
right: 24rpx;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
height: 68rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.scan-btn {
|
||||
height: 68rpx;
|
||||
padding: 0 8rpx 0 4rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&:active {
|
||||
opacity: 0.88;
|
||||
}
|
||||
}
|
||||
|
||||
.search-divider {
|
||||
width: 1rpx;
|
||||
height: 28rpx;
|
||||
background: #dcdfe6;
|
||||
margin: 0 16rpx 0 10rpx;
|
||||
}
|
||||
|
||||
.search-btn {
|
||||
height: 68rpx;
|
||||
padding: 0 8rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
|
||||
&__text {
|
||||
font-size: 34rpx;
|
||||
font-weight: 500;
|
||||
color: #2979ff;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
&:active {
|
||||
opacity: 0.88;
|
||||
}
|
||||
}
|
||||
|
||||
/* 状态筛选行(横向滚动) */
|
||||
.filter-row {
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.filter-scroll {
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.filter-group {
|
||||
display: inline-flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.filter-group__item {
|
||||
flex: none;
|
||||
height: 56rpx;
|
||||
padding: 0 24rpx;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #f5f7fa;
|
||||
border: 1rpx solid #ebeef5;
|
||||
border-radius: 28rpx;
|
||||
}
|
||||
|
||||
.filter-group__item + .filter-group__item {
|
||||
margin-left: 16rpx;
|
||||
}
|
||||
|
||||
.filter-group__item--active {
|
||||
background: #2979ff;
|
||||
border-color: #2979ff;
|
||||
box-shadow: 0 4rpx 12rpx rgba(41, 121, 255, 0.28);
|
||||
}
|
||||
|
||||
.filter-group__item-text {
|
||||
font-size: 30rpx;
|
||||
color: #303133;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.filter-group__item--active .filter-group__item-text {
|
||||
color: #ffffff;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* 列表区 */
|
||||
.detail-scroll {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
height: auto;
|
||||
padding: 20rpx 0 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 160rpx 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
margin-top: 24rpx;
|
||||
font-size: 36rpx;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.empty-hint {
|
||||
margin-top: 12rpx;
|
||||
font-size: 30rpx;
|
||||
color: #c0c4cc;
|
||||
}
|
||||
|
||||
.record-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 0 12rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.record-card {
|
||||
background: #ffffff;
|
||||
border: 2rpx solid #ebedf2;
|
||||
border-radius: 20rpx;
|
||||
padding: 4rpx 28rpx;
|
||||
margin-bottom: 20rpx;
|
||||
box-shadow: 0 6rpx 20rpx rgba(31, 45, 61, 0.06);
|
||||
}
|
||||
|
||||
.record-card--stripe {
|
||||
background: #dde9fb;
|
||||
border-color: #dfe7f5;
|
||||
}
|
||||
|
||||
.record-card--stripe .record-card__label {
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.record-card__row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1rpx solid #f0f2f5;
|
||||
}
|
||||
|
||||
.record-card__row--last {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.record-card__label {
|
||||
flex-shrink: 0;
|
||||
width: 160rpx;
|
||||
font-size: 36rpx;
|
||||
color: #8a9099;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.record-card__value {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 40rpx;
|
||||
color: #303133;
|
||||
line-height: 1.5;
|
||||
word-break: break-all;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.record-card__value--strong {
|
||||
font-weight: 600;
|
||||
color: #2979ff;
|
||||
}
|
||||
|
||||
.record-card__value--success {
|
||||
font-weight: 600;
|
||||
color: #18a058;
|
||||
}
|
||||
|
||||
.record-card__value--warning {
|
||||
font-weight: 600;
|
||||
color: #ff9800;
|
||||
}
|
||||
|
||||
.record-card__value--danger {
|
||||
font-weight: 600;
|
||||
color: #e64340;
|
||||
}
|
||||
|
||||
.record-card__value--muted {
|
||||
color: #c0c4cc;
|
||||
}
|
||||
|
||||
.safe-area-bottom {
|
||||
height: calc(20rpx + env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
/* 分页 */
|
||||
.pagination-wrap {
|
||||
flex-shrink: 0;
|
||||
padding: 12rpx 12rpx 0;
|
||||
background: #ffffff;
|
||||
border-top: 1rpx solid #f2f2f2;
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large
Load Diff
27
postcss.config.js
Normal file
27
postcss.config.js
Normal file
@ -0,0 +1,27 @@
|
||||
const path = require('path')
|
||||
const webpack = require('webpack')
|
||||
const config = {
|
||||
parser: require('postcss-comment'),
|
||||
plugins: [
|
||||
require('postcss-import')({
|
||||
resolve (id, basedir, importOptions) {
|
||||
if (id.startsWith('~@/')) {
|
||||
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3))
|
||||
} else if (id.startsWith('@/')) {
|
||||
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2))
|
||||
} else if (id.startsWith('/') && !id.startsWith('//')) {
|
||||
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1))
|
||||
}
|
||||
return id
|
||||
}
|
||||
}),
|
||||
require('autoprefixer')({
|
||||
remove: process.env.UNI_PLATFORM !== 'h5'
|
||||
}),
|
||||
require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
|
||||
]
|
||||
}
|
||||
if (webpack.version[0] > 4) {
|
||||
delete config.parser
|
||||
}
|
||||
module.exports = config
|
||||
@ -28,9 +28,6 @@
|
||||
<link rel="stylesheet" href="<%= BASE_URL %>static/index.css" />
|
||||
</head>
|
||||
<body>
|
||||
<!-- 该文件为 H5 平台的模板 HTML,并非应用入口。 -->
|
||||
<!-- 请勿在此文件编写页面代码或直接运行此文件。 -->
|
||||
<!-- 详见文档:https://uniapp.dcloud.io/collocation/manifest?id=h5-template -->
|
||||
<noscript>
|
||||
<strong>本站点必须要开启JavaScript才能运行</strong>
|
||||
</noscript>
|
||||
63
scripts/build-apk.cjs
Normal file
63
scripts/build-apk.cjs
Normal file
@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Android APK 一键打包(强制生产编译 + 产物地址校验)。
|
||||
*
|
||||
* 步骤:
|
||||
* 1. `npm run build:app-plus` —— 生产编译。该命令内部已包含 `scripts/check-build-env.cjs`
|
||||
* 的产物校验(含内网地址或缺少生产域名会直接失败),因此不会把开发地址打进 APK;
|
||||
* 2. `android-offline/pack.ps1` —— 注入 App 资源/图标/启动图 + `gradlew assembleRelease`,
|
||||
* 产物输出到 `release/android/wms-pda_v{版本}_release.apk`。
|
||||
*
|
||||
* 用法:
|
||||
* npm run build:apk # 前端编译 + 打包
|
||||
* npm run build:apk -- -Clean # gradle 全量重编
|
||||
* npm run build:apk -- -NoInject # 跳过资源注入(已注入过时用)
|
||||
* npm run build:apk -- -Timestamp # 产物名带时间戳
|
||||
* npm run android:pack:raw # 跳过前端编译,直接用现有 dist/build/app-plus 打包
|
||||
*
|
||||
* 说明:
|
||||
* - 发布上传(scp + latest.json)在 pack.ps1 内,且只有存在 `config/deploy.json` 时才会执行;
|
||||
* 本仓库不提供该文件,故默认不会上传。
|
||||
* - 版本号唯一来源是根 `package.json` 的 `version`(X.Y.Z),`versionCode` 自动推导为
|
||||
* X*1000000 + Y*1000 + Z。
|
||||
*/
|
||||
const { spawnSync } = require('child_process')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const ROOT = path.resolve(__dirname, '..')
|
||||
const APP_BUILD_DIR = path.join(ROOT, 'dist', 'build', 'app-plus')
|
||||
|
||||
const log = (...args) => console.log('[build-apk]', ...args)
|
||||
|
||||
function run(cmd, args) {
|
||||
log(`$ ${cmd} ${args.join(' ')}`)
|
||||
const res = spawnSync(cmd, args, {
|
||||
cwd: ROOT,
|
||||
stdio: 'inherit',
|
||||
env: process.env,
|
||||
shell: process.platform === 'win32',
|
||||
})
|
||||
return res.status === 0
|
||||
}
|
||||
|
||||
// ---------- step 1: 生产编译(内部含产物地址校验) ----------
|
||||
log('step 1/2: build:app-plus(生产编译 + 产物地址校验)...')
|
||||
if (!run('npm', ['run', 'build:app-plus'])) {
|
||||
console.error('[build-apk] ✗ build:app-plus 失败,终止')
|
||||
process.exit(1)
|
||||
}
|
||||
if (!fs.existsSync(APP_BUILD_DIR)) {
|
||||
console.error(`[build-apk] ✗ 未找到 App 构建产物: ${APP_BUILD_DIR}`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// ---------- step 2: 离线打包(参数透传) ----------
|
||||
const extraArgs = process.argv.slice(2)
|
||||
const packArgs = ['run', 'android:pack:raw']
|
||||
if (extraArgs.length) packArgs.push('--', ...extraArgs)
|
||||
log(`step 2/2: android:pack:raw${extraArgs.length ? ' ' + extraArgs.join(' ') : ''} ...`)
|
||||
if (!run('npm', packArgs)) {
|
||||
console.error('[build-apk] ✗ android:pack:raw 失败')
|
||||
process.exit(1)
|
||||
}
|
||||
log('✓ 打包完成,APK 见 release/android/')
|
||||
105
scripts/check-build-env.cjs
Normal file
105
scripts/check-build-env.cjs
Normal file
@ -0,0 +1,105 @@
|
||||
/**
|
||||
* 构建产物「接口地址」校验(防呆)
|
||||
*
|
||||
* 背景:本项目原 HBuilderX 工程里 src/env.js 的开发地址长期处于生效状态,
|
||||
* 打正式包时会连内网测试库(曾在姊妹项目 wms_worker_station 造成过生产事故)。
|
||||
* 本脚本在构建结束后扫描产物,做两道校验:
|
||||
* 1. 产物中不得出现内网地址(192.168.x.x / 127.0.0.1)——否则说明开发地址进了包;
|
||||
* 2. 产物中必须出现生产域名 PROD_HOST——否则说明生产地址根本没被编译进去
|
||||
* (例如误用了 override、或 env.js 被改坏)。
|
||||
* 任一条不满足即 exit 1,让 CI / 本地打包在「产物不可信」时就停下来。
|
||||
*
|
||||
* 用法:
|
||||
* node scripts/check-build-env.cjs # 自动扫描已存在的产物目录
|
||||
* node scripts/check-build-env.cjs dist/build/h5 # 只校验指定目录
|
||||
* node scripts/check-build-env.cjs --allow-missing-prod # 跳过第 2 条(特殊域名场景)
|
||||
*/
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const ROOT = path.resolve(__dirname, '..')
|
||||
const DEFAULT_TARGETS = [path.join(ROOT, 'dist', 'build', 'h5'), path.join(ROOT, 'dist', 'build', 'app-plus')]
|
||||
const SCAN_EXTENSIONS = ['.js', '.html', '.json', '.css']
|
||||
|
||||
// 生产接口域名:必须与 src/env.js 的 PROD_API_BASE 保持一致
|
||||
const PROD_HOST = 'qimen.wms.gztbyc.com'
|
||||
// 内网地址特征(开发环境地址一旦出现在产物里就是事故)
|
||||
const DEV_PATTERNS = [/192\.168\.\d{1,3}\.\d{1,3}/g, /127\.0\.0\.1/g]
|
||||
|
||||
const args = process.argv.slice(2)
|
||||
const allowMissingProd = args.includes('--allow-missing-prod')
|
||||
const explicitTargets = args.filter((arg) => !arg.startsWith('--'))
|
||||
|
||||
const log = (...rest) => console.log('[check-build-env]', ...rest)
|
||||
|
||||
function collectFiles(dir, out = []) {
|
||||
if (!fs.existsSync(dir)) return out
|
||||
for (const name of fs.readdirSync(dir)) {
|
||||
const full = path.join(dir, name)
|
||||
const stat = fs.statSync(full)
|
||||
if (stat.isDirectory()) {
|
||||
collectFiles(full, out)
|
||||
} else if (SCAN_EXTENSIONS.includes(path.extname(name).toLowerCase())) {
|
||||
out.push(full)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
const targets = (explicitTargets.length ? explicitTargets : DEFAULT_TARGETS)
|
||||
.map((target) => path.resolve(ROOT, target))
|
||||
.filter((dir) => fs.existsSync(dir))
|
||||
|
||||
if (!targets.length) {
|
||||
console.error('[check-build-env] ✗ 未找到任何构建产物目录,请先执行构建(npm run build:h5 / build:app-plus)')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
let failed = false
|
||||
|
||||
for (const dir of targets) {
|
||||
const files = collectFiles(dir)
|
||||
const rel = path.relative(ROOT, dir).replace(/\\/g, '/')
|
||||
if (!files.length) {
|
||||
log(`✗ ${rel} 为空目录,跳过`)
|
||||
continue
|
||||
}
|
||||
|
||||
const devHits = []
|
||||
let hasProdHost = false
|
||||
|
||||
for (const file of files) {
|
||||
const content = fs.readFileSync(file, 'utf-8')
|
||||
if (content.includes(PROD_HOST)) hasProdHost = true
|
||||
for (const pattern of DEV_PATTERNS) {
|
||||
const matches = content.match(pattern)
|
||||
if (matches) {
|
||||
devHits.push({ file: path.relative(dir, file).replace(/\\/g, '/'), hits: Array.from(new Set(matches)) })
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (devHits.length) {
|
||||
failed = true
|
||||
console.error(`[check-build-env] ✗ ${rel} 中发现内网地址,产物不可用于发布:`)
|
||||
devHits.forEach(({ file, hits }) => console.error(` - ${file}(${hits.join(', ')})`))
|
||||
console.error(' 排查:src/env.js 是否被改回开发地址 / 是否误用 VUE_APP_API_BASE_OVERRIDE')
|
||||
}
|
||||
|
||||
if (!hasProdHost && !allowMissingProd) {
|
||||
failed = true
|
||||
console.error(`[check-build-env] ✗ ${rel} 中未发现生产域名 ${PROD_HOST},产物不可用于发布`)
|
||||
console.error(' 排查:src/env.js 的 PROD_API_BASE 是否被改动;如属特殊场景请加 --allow-missing-prod')
|
||||
}
|
||||
|
||||
if (!devHits.length && (hasProdHost || allowMissingProd)) {
|
||||
log(`✓ ${rel} 校验通过(${files.length} 个文件,无内网地址${hasProdHost ? `,含生产域名 ${PROD_HOST}` : ''})`)
|
||||
}
|
||||
}
|
||||
|
||||
if (failed) {
|
||||
console.error('[check-build-env] ✗ 校验未通过,已中止')
|
||||
process.exit(1)
|
||||
}
|
||||
log('全部产物校验通过')
|
||||
426
scripts/dev-adb.cjs
Normal file
426
scripts/dev-adb.cjs
Normal file
@ -0,0 +1,426 @@
|
||||
/**
|
||||
* 真机调试(测试模式):注入接口地址 → 编译 → 打包 → 装机 → 启动 → 跟随日志 → 监听改动自动重来。
|
||||
*
|
||||
* 与 `npm run build:apk` 的区别:
|
||||
* - build:apk → 发行包。接口地址固定为 src/env.js 的 PROD_API_BASE,构建后强制校验产物不含内网地址。
|
||||
* - dev:adb → 测试包。接口地址在编译期由本脚本注入(默认取 .env.development.local 的
|
||||
* VUE_APP_API_BASE_URL),产物进 release/android/dev/*_dev.apk,绝不覆盖发行包。
|
||||
*
|
||||
* 注入方式(与工作台 wms_worker_station 一致):命令行环境变量 VUE_APP_API_BASE_OVERRIDE,
|
||||
* 不写入任何 .env 文件、不落盘;在 src/env.js 中优先级高于生产常量,详见该文件顶部说明。
|
||||
*
|
||||
* 用法:
|
||||
* npm run dev:adb # 默认:构建→装机→启动→跟随真机日志→监听改动自动重来
|
||||
* npm run dev:adb -- --once # 只跑一遍(CI/脚本调用用,不监听)
|
||||
* npm run dev:adb -- --prod-api # 不注入,产出与发行包一致的包(排查线上问题时用)
|
||||
* npm run dev:adb -- --api=http://192.168.1.10:6060
|
||||
* npm run dev:adb -- --no-install # 只编译 + 打包
|
||||
* npm run dev:adb -- --no-launch # 装机后不自动启动
|
||||
* npm run dev:adb -- --no-logcat # 不跟随真机日志
|
||||
* npm run dev:adb -- --serial=4235737 # 多设备时指定目标设备
|
||||
*
|
||||
* 真机日志:release 包里 JS 的 console 走 UniConsole(逻辑层) / UniViewConsole(视图层) 两个 tag,
|
||||
* 本脚本默认跟随这两个 tag 实时打印到控制台(出错行标红)。
|
||||
*/
|
||||
const { spawn, spawnSync } = require('child_process')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const readline = require('readline')
|
||||
|
||||
const ROOT = path.resolve(__dirname, '..')
|
||||
const APP_BUILD_DIR = path.join(ROOT, 'dist', 'build', 'app-plus')
|
||||
const DEV_APK_DIR = path.join(ROOT, 'release', 'android', 'dev')
|
||||
const PACKAGE_NAME = 'com.gztbyc.pda_wms'
|
||||
|
||||
const argv = process.argv.slice(2)
|
||||
const hasFlag = (name) => argv.includes(name)
|
||||
const argValue = (name) => {
|
||||
const hit = argv.find((a) => a.startsWith(`${name}=`))
|
||||
return hit ? hit.slice(name.length + 1) : ''
|
||||
}
|
||||
|
||||
const ONCE = hasFlag('--once') || hasFlag('--no-watch')
|
||||
const NO_INSTALL = hasFlag('--no-install')
|
||||
const NO_LAUNCH = hasFlag('--no-launch')
|
||||
const NO_LOGCAT = hasFlag('--no-logcat')
|
||||
|
||||
const log = (msg) => console.log(`[dev:adb] ${msg}`)
|
||||
|
||||
// ---------- adb 探测 ----------
|
||||
function detectAdb() {
|
||||
const candidates = []
|
||||
const home = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT || ''
|
||||
if (home) candidates.push(path.join(home, 'platform-tools', process.platform === 'win32' ? 'adb.exe' : 'adb'))
|
||||
if (process.env.LOCALAPPDATA) candidates.push(path.join(process.env.LOCALAPPDATA, 'Android', 'Sdk', 'platform-tools', 'adb.exe'))
|
||||
candidates.push(process.platform === 'win32' ? 'adb.exe' : 'adb')
|
||||
for (const c of candidates) {
|
||||
const res = spawnSync(c, ['version'], { encoding: 'utf-8' })
|
||||
if (res.status === 0 && /Android Debug Bridge/.test(res.stdout || '')) return c
|
||||
}
|
||||
return 'adb'
|
||||
}
|
||||
const ADB = detectAdb()
|
||||
|
||||
// ---------- 接口地址解析 ----------
|
||||
function readEnvValue(file, key) {
|
||||
try {
|
||||
const text = fs.readFileSync(path.join(ROOT, file), 'utf-8')
|
||||
for (const line of text.split(/\r?\n/)) {
|
||||
const m = line.match(/^\s*([A-Za-z0-9_]+)\s*=\s*(.*)$/)
|
||||
if (m && m[1] === key) return m[2].trim().replace(/^["']|["']$/g, '')
|
||||
}
|
||||
} catch (e) {
|
||||
// 文件不存在视为未配置
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function resolveApiTarget() {
|
||||
if (hasFlag('--prod-api')) return { base: '', note: '--prod-api 指定,与发行包一致(生产地址)' }
|
||||
const argApi = argValue('--api')
|
||||
if (argApi) return { base: argApi, note: '命令行 --api 指定' }
|
||||
const fromEnv = readEnvValue('.env.development.local', 'VUE_APP_API_BASE_URL') || readEnvValue('.env.local', 'VUE_APP_API_BASE_URL')
|
||||
if (fromEnv) return { base: fromEnv, note: '.env.development.local 的 VUE_APP_API_BASE_URL' }
|
||||
return { base: '', note: '未配置开发地址,沿用构建默认(生产地址)' }
|
||||
}
|
||||
|
||||
const API_TARGET = resolveApiTarget()
|
||||
const BUILD_ENV = {
|
||||
...(API_TARGET.base ? { VUE_APP_API_BASE_OVERRIDE: API_TARGET.base } : {}),
|
||||
// 测试包始终开启 JS→logcat 转发(发行包不注入该变量,见 src/core/utils/dev-log.js)
|
||||
VUE_APP_JS_LOG_TO_LOGCAT: '1',
|
||||
}
|
||||
|
||||
// ---------- 工具 ----------
|
||||
function run(cmd, args, env) {
|
||||
const res = spawnSync(cmd, args, {
|
||||
cwd: ROOT,
|
||||
stdio: 'inherit',
|
||||
env: { ...process.env, ...(env || {}) },
|
||||
shell: process.platform === 'win32',
|
||||
})
|
||||
if (res.error) {
|
||||
console.error(`[dev:adb] 执行失败 ${cmd}: ${res.error.message}`)
|
||||
return false
|
||||
}
|
||||
return res.status === 0
|
||||
}
|
||||
|
||||
function collectFiles(dir, out = []) {
|
||||
if (!fs.existsSync(dir)) return out
|
||||
for (const name of fs.readdirSync(dir)) {
|
||||
const full = path.join(dir, name)
|
||||
if (fs.statSync(full).isDirectory()) collectFiles(full, out)
|
||||
else if (/\.(js|html|json)$/i.test(name)) out.push(full)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
function findDevApk() {
|
||||
if (!fs.existsSync(DEV_APK_DIR)) return null
|
||||
const apks = fs.readdirSync(DEV_APK_DIR)
|
||||
.filter((f) => f.endsWith('.apk'))
|
||||
.map((f) => ({ name: f, mtime: fs.statSync(path.join(DEV_APK_DIR, f)).mtimeMs }))
|
||||
if (!apks.length) return null
|
||||
apks.sort((a, b) => b.mtime - a.mtime)
|
||||
return path.join(DEV_APK_DIR, apks[0].name)
|
||||
}
|
||||
|
||||
// ---------- 设备 ----------
|
||||
// 上次选择的设备记在本文件里(不提交 git):多设备时自动选回它,避免每次都要选
|
||||
const STATE_FILE = path.join(ROOT, '.dev-adb.local.json')
|
||||
|
||||
function readSavedSerial() {
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(STATE_FILE, 'utf-8')).serial || ''
|
||||
} catch (e) {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
function saveSerial(serial) {
|
||||
try {
|
||||
fs.writeFileSync(STATE_FILE, `${JSON.stringify({ serial }, null, 2)}\n`)
|
||||
} catch (e) {
|
||||
// 写入失败不影响流程
|
||||
}
|
||||
}
|
||||
|
||||
function listDevices() {
|
||||
const res = spawnSync(ADB, ['devices', '-l'], { encoding: 'utf-8' })
|
||||
const devices = []
|
||||
for (const line of (res.stdout || '').split(/\r?\n/)) {
|
||||
const m = line.trim().match(/^(\S+)\s+device\b(.*)$/)
|
||||
if (m) devices.push({ serial: m[1], desc: m[2].trim() })
|
||||
}
|
||||
return devices
|
||||
}
|
||||
|
||||
function ask(question) {
|
||||
const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
|
||||
return new Promise((resolve) => {
|
||||
rl.question(question, (answer) => {
|
||||
rl.close()
|
||||
resolve(String(answer || '').trim())
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function printDevices(devices) {
|
||||
devices.forEach((d, i) => console.error(` [${i + 1}] ${d.serial} ${d.desc}`))
|
||||
}
|
||||
|
||||
async function pickDevice() {
|
||||
const devices = listDevices()
|
||||
if (!devices.length) {
|
||||
console.error('[dev:adb] 未检测到已连接设备(USB 未插好、未授权,或无线调试未 adb connect)')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// 1. 命令行指定优先
|
||||
const wanted = argValue('--serial')
|
||||
if (wanted) {
|
||||
const hit = devices.find((d) => d.serial === wanted)
|
||||
if (!hit) {
|
||||
console.error(`[dev:adb] 未找到设备 ${wanted},当前:${devices.map((d) => d.serial).join(', ')}`)
|
||||
process.exit(1)
|
||||
}
|
||||
saveSerial(hit.serial)
|
||||
return hit
|
||||
}
|
||||
|
||||
// 2. 上次用过的设备仍然在线 → 直接用
|
||||
const saved = readSavedSerial()
|
||||
if (saved) {
|
||||
const hit = devices.find((d) => d.serial === saved)
|
||||
if (hit) {
|
||||
log(`使用上次选择的设备: ${hit.serial} ${hit.desc}(可用 --serial= 更换)`)
|
||||
return hit
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 只有一台 → 自动选中
|
||||
if (devices.length === 1) {
|
||||
saveSerial(devices[0].serial)
|
||||
return devices[0]
|
||||
}
|
||||
|
||||
// 4. 多台 → 交互选择(与工作台 dev:adb 一致)
|
||||
console.error('[dev:adb] 检测到多台设备:')
|
||||
printDevices(devices)
|
||||
if (!process.stdin.isTTY) {
|
||||
console.error('[dev:adb] 当前终端不能交互,请用 --serial=<序列号> 指定,例如:')
|
||||
console.error(` npm run dev:adb -- --serial=${devices[0].serial}`)
|
||||
process.exit(1)
|
||||
}
|
||||
const answer = await ask(`请选择设备序号 [1-${devices.length}],默认 1: `)
|
||||
const idx = answer ? Number(answer) - 1 : 0
|
||||
if (!Number.isInteger(idx) || idx < 0 || idx >= devices.length) {
|
||||
console.error(`[dev:adb] 无效序号: ${answer}`)
|
||||
process.exit(1)
|
||||
}
|
||||
saveSerial(devices[idx].serial)
|
||||
return devices[idx]
|
||||
}
|
||||
|
||||
// ---------- 真机日志跟随 ----------
|
||||
let logcatProc = null
|
||||
let shuttingDown = false
|
||||
|
||||
function clearLogcat(serial) {
|
||||
spawnSync(ADB, ['-s', serial, 'logcat', '-c'], { stdio: 'ignore' })
|
||||
}
|
||||
|
||||
function startLogcat(serial) {
|
||||
if (NO_LOGCAT || logcatProc || shuttingDown) return
|
||||
clearLogcat(serial)
|
||||
logcatProc = spawn(ADB, ['-s', serial, 'logcat', '-v', 'time', 'jsLog:V', 'UniConsole:V', 'UniViewConsole:V', '*:S'], {
|
||||
stdio: ['ignore', 'pipe', 'inherit'],
|
||||
})
|
||||
let buf = ''
|
||||
logcatProc.stdout.setEncoding('utf-8')
|
||||
logcatProc.stdout.on('data', (chunk) => {
|
||||
buf += chunk
|
||||
let idx
|
||||
while ((idx = buf.indexOf('\n')) >= 0) {
|
||||
const line = buf.slice(0, idx).trim()
|
||||
buf = buf.slice(idx + 1)
|
||||
if (!line) continue
|
||||
const isErr = / W\/| E\//.test(line)
|
||||
console.log(isErr ? `\x1b[31m[真机] ${line}\x1b[0m` : `\x1b[36m[真机] ${line}\x1b[0m`)
|
||||
}
|
||||
})
|
||||
logcatProc.on('exit', () => {
|
||||
logcatProc = null
|
||||
if (!shuttingDown) {
|
||||
// adb 重连/设备重启后自动恢复跟随
|
||||
setTimeout(() => startLogcat(serial), 3000)
|
||||
}
|
||||
})
|
||||
log('真机 console 实时打印已开启(jsLog / UniConsole / UniViewConsole)')
|
||||
}
|
||||
|
||||
process.on('SIGINT', () => {
|
||||
shuttingDown = true
|
||||
if (logcatProc) {
|
||||
logcatProc.kill()
|
||||
logcatProc = null
|
||||
}
|
||||
log('已退出监听的日志跟随')
|
||||
process.exit(0)
|
||||
})
|
||||
|
||||
// ---------- 构建 → 安装 → 启动 ----------
|
||||
async function buildAndInstall(device, trigger) {
|
||||
const serial = device.serial
|
||||
const t0 = Date.now()
|
||||
log(`开始构建(触发: ${trigger})`)
|
||||
log(`接口地址 = ${API_TARGET.base || 'src/env.js 的 PROD_API_BASE(生产)'} 〔${API_TARGET.note}〕`)
|
||||
|
||||
// 1. 编译 App 资源(生产模式编译,但注入 override 指向测试环境)
|
||||
if (!run('npm', ['run', 'build:app-plus:dev'], BUILD_ENV)) {
|
||||
log('✗ 编译失败,跳过安装')
|
||||
return false
|
||||
}
|
||||
|
||||
// 2. 校验注入结果(正向:期望地址必须出现在产物里)
|
||||
const files = collectFiles(APP_BUILD_DIR)
|
||||
if (!files.length) {
|
||||
log(`✗ 未找到构建产物: ${path.relative(ROOT, APP_BUILD_DIR)}`)
|
||||
return false
|
||||
}
|
||||
if (API_TARGET.base) {
|
||||
const host = API_TARGET.base.replace(/^https?:\/\//, '').replace(/\/.*$/, '')
|
||||
const hit = files.find((f) => fs.readFileSync(f, 'utf-8').includes(host))
|
||||
if (!hit) {
|
||||
log(`✗ 产物中未找到注入的地址 ${API_TARGET.base},注入可能未生效,已中止`)
|
||||
return false
|
||||
}
|
||||
log(`✓ 已确认产物使用 ${API_TARGET.base}`)
|
||||
} else if (!run('node', ['scripts/check-build-env.cjs', 'dist/build/app-plus'])) {
|
||||
log('✗ 产物地址校验未通过')
|
||||
return false
|
||||
}
|
||||
|
||||
// 3. 离线打包(-Dev:产物进 release/android/dev 且带 _dev 后缀,不触发发布上传)
|
||||
if (!run('npm', ['run', 'android:pack:raw', '--', '-Dev', '-NoUpload'])) {
|
||||
log('✗ 打包失败,跳过安装')
|
||||
return false
|
||||
}
|
||||
const apk = findDevApk()
|
||||
if (!apk) {
|
||||
log(`✗ 未找到 APK: ${path.relative(ROOT, DEV_APK_DIR)}`)
|
||||
return false
|
||||
}
|
||||
log(`APK: ${path.relative(ROOT, apk)}`)
|
||||
|
||||
if (NO_INSTALL) {
|
||||
log(`✓ 编译 + 打包完成,耗时 ${((Date.now() - t0) / 1000).toFixed(1)}s(--no-install 未安装)`)
|
||||
return true
|
||||
}
|
||||
|
||||
// 4. 安装(设备忙时常见失败,重试 3 次)
|
||||
for (let i = 0; i < 3; i++) {
|
||||
if (spawnSync(ADB, ['-s', serial, 'install', '-r', apk], { stdio: 'inherit' }).status === 0) break
|
||||
if (i === 2) {
|
||||
log('✗ adb install 失败(已重试 3 次)')
|
||||
return false
|
||||
}
|
||||
log(`安装失败,2 秒后重试 (${i + 1}/2)`)
|
||||
await new Promise((r) => setTimeout(r, 2000))
|
||||
}
|
||||
|
||||
// 5. 启动(先停进程,再用 monkey 拉起 launcher 入口最稳)
|
||||
if (!NO_LAUNCH) {
|
||||
if (!NO_LOGCAT) startLogcat(serial)
|
||||
else clearLogcat(serial)
|
||||
spawnSync(ADB, ['-s', serial, 'shell', 'am', 'force-stop', PACKAGE_NAME], { stdio: 'ignore' })
|
||||
spawnSync(ADB, ['-s', serial, 'shell', 'monkey', '-p', PACKAGE_NAME, '-c', 'android.intent.category.LAUNCHER', '1'], { stdio: 'ignore' })
|
||||
log('已启动应用')
|
||||
}
|
||||
|
||||
log(`✓ 完成,耗时 ${((Date.now() - t0) / 1000).toFixed(1)}s`)
|
||||
return true
|
||||
}
|
||||
|
||||
let building = false
|
||||
let pending = false
|
||||
|
||||
async function triggerBuild(device, trigger) {
|
||||
if (building) {
|
||||
pending = true
|
||||
return
|
||||
}
|
||||
building = true
|
||||
try {
|
||||
await buildAndInstall(device, trigger)
|
||||
} finally {
|
||||
building = false
|
||||
if (pending) {
|
||||
pending = false
|
||||
log('构建期间有新变更,继续构建...')
|
||||
triggerBuild(device, 'pending')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 目录监听 ----------
|
||||
// 监听范围:src/(uni-app 前端)、原生 java、以及 src/main 直接子文件(AndroidManifest.xml)。
|
||||
// 注意:不监听 src/main/assets(prepare 注入产物)与 res(图标/启动图覆盖产物),否则构建会自触发死循环。
|
||||
const WATCH_ROOTS = [
|
||||
{ dir: path.join(ROOT, 'src'), recursive: true },
|
||||
{ dir: path.join(ROOT, 'android-offline', 'HBuilder-Integrate-AS', 'simpleDemo', 'src', 'main', 'java'), recursive: true },
|
||||
{ dir: path.join(ROOT, 'android-offline', 'HBuilder-Integrate-AS', 'simpleDemo', 'src', 'main'), recursive: false },
|
||||
]
|
||||
const WATCH_EXTS = new Set(['.vue', '.js', '.ts', '.json', '.scss', '.css', '.cjs', '.ps1', '.xml', '.java', '.png', '.jpg', '.jpeg'])
|
||||
|
||||
const IGNORE_SEGMENTS = [`${path.sep}assets${path.sep}`, `${path.sep}unpackage${path.sep}`, `${path.sep}dist${path.sep}`, `${path.sep}node_modules${path.sep}`]
|
||||
|
||||
function startWatch(device) {
|
||||
let timer = null
|
||||
for (const root of WATCH_ROOTS) {
|
||||
if (!fs.existsSync(root.dir)) {
|
||||
log(`警告: 监听目录不存在: ${path.relative(ROOT, root.dir)}`)
|
||||
continue
|
||||
}
|
||||
try {
|
||||
fs.watch(root.dir, { recursive: root.recursive }, (event, filename) => {
|
||||
const rel = filename ? path.join(root.dir, filename) : root.dir
|
||||
if (IGNORE_SEGMENTS.some((seg) => rel.includes(seg))) return
|
||||
if (filename && !WATCH_EXTS.has(path.extname(filename).toLowerCase())) return
|
||||
if (timer) clearTimeout(timer)
|
||||
timer = setTimeout(() => {
|
||||
timer = null
|
||||
triggerBuild(device, path.relative(ROOT, rel))
|
||||
}, 800)
|
||||
})
|
||||
log(`监听中: ${path.relative(ROOT, root.dir)}${root.recursive ? '' : '(不递归)'}`)
|
||||
} catch (e) {
|
||||
log(`警告: 无法监听 ${root.dir}: ${e.message}`)
|
||||
}
|
||||
}
|
||||
log('改动文件即自动重编重装(Ctrl+C 退出)')
|
||||
}
|
||||
|
||||
// ---------- 主流程 ----------
|
||||
async function main() {
|
||||
const device = await pickDevice()
|
||||
log(`目标设备: ${device.serial} ${device.desc}`)
|
||||
|
||||
await triggerBuild(device, '首次')
|
||||
|
||||
log(`单独查看真机日志:adb -s ${device.serial} logcat jsLog:V UniConsole:V UniViewConsole:V *:S`)
|
||||
|
||||
if (ONCE) {
|
||||
if (NO_LOGCAT || NO_LAUNCH) {
|
||||
log('--once 指定,不进入监听,结束')
|
||||
} else {
|
||||
log('--once 指定:不监听文件改动,但继续跟随真机日志(Ctrl+C 退出)')
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
startWatch(device)
|
||||
}
|
||||
|
||||
main()
|
||||
52
scripts/node-compat.cjs
Normal file
52
scripts/node-compat.cjs
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Node 兼容 shim(uni-app Vue2 工具链专用)
|
||||
*
|
||||
* 背景:Node 23+ 移除了历史遗留的 `util.isArray` / `util.isRegExp` 等 API,
|
||||
* 而 uni-app Vue2 编译链依赖的 postcss-urlrewrite 等老包仍在调用它们,
|
||||
* 在 Node 22+ 上执行 app-plus 构建会抛 `util.isRegExp is not a function`。
|
||||
*
|
||||
* 用法:通过 NODE_OPTIONS=--require=./scripts/node-compat.cjs 注入(见 package.json scripts)。
|
||||
* 在 Node 16/18 下运行时所有 API 均存在,本文件自动变成空操作,无副作用。
|
||||
*/
|
||||
'use strict'
|
||||
|
||||
const util = require('util')
|
||||
|
||||
const toString = Object.prototype.toString
|
||||
|
||||
const shims = {
|
||||
isArray: Array.isArray,
|
||||
isBoolean: (v) => typeof v === 'boolean',
|
||||
isBuffer: (v) => Buffer.isBuffer(v),
|
||||
isDate: (v) => v instanceof Date,
|
||||
isError: (v) => v instanceof Error || toString.call(v) === '[object Error]',
|
||||
isFunction: (v) => typeof v === 'function',
|
||||
isNull: (v) => v === null,
|
||||
isNullOrUndefined: (v) => v === null || v === undefined,
|
||||
isNumber: (v) => typeof v === 'number',
|
||||
isObject: (v) => v !== null && typeof v === 'object',
|
||||
isPrimitive: (v) => v === null || (typeof v !== 'object' && typeof v !== 'function'),
|
||||
isRegExp: (v) => v instanceof RegExp,
|
||||
isString: (v) => typeof v === 'string',
|
||||
isSymbol: (v) => typeof v === 'symbol',
|
||||
isUndefined: (v) => v === undefined
|
||||
}
|
||||
|
||||
Object.keys(shims).forEach((name) => {
|
||||
if (typeof util[name] !== 'function') {
|
||||
util[name] = shims[name]
|
||||
}
|
||||
})
|
||||
|
||||
if (typeof util._extend !== 'function') {
|
||||
util._extend = function _extend (target, source) {
|
||||
if (source) {
|
||||
for (const key in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
target[key] = source[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
}
|
||||
@ -443,6 +443,34 @@ export default {
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 盘点明细结果(按范围行聚合作业记录):返回 { check, rows, total },
|
||||
// rows 含已盘/差异聚合 + 作业记录/库位/未知商品;无状态限制(已完成任务也能拉)
|
||||
result: {
|
||||
path: "stock.check.result",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 盘点作业数据:入参 id + is_goods + keyword + pagination;视图由任务范围与 is_goods 驱动
|
||||
// (库位任务一律 location 视图;商品任务默认 space 聚合库位视图,is_goods=true 为 goods 商品视图)
|
||||
// keyword 仅 location 视图生效(按 location_code/location_name 模糊匹配后分页)
|
||||
// 仅任务状态 approved/checking 可拉取,其他状态返回 400
|
||||
workData: {
|
||||
path: "stock.check.workData",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 单条盘点明细的作业数据(workData 单行版,仅库位任务明细):
|
||||
// 入参仅 detail_id(兼容 detailId),warehouse_id 由服务端注入;
|
||||
// 返回 data 为单行 location 结构(detail_id/location_id/location_code/location_name/
|
||||
// status/has_unknown/is_empty/checked_at/checkers/goods),仅 approved/checking 可拉取
|
||||
workDataDetail: {
|
||||
path: "stock.check.workDataDetail",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 盘点作业上报:单条明细实盘数量(quantity>=0 整数)
|
||||
report: {
|
||||
path: "stock.check.report",
|
||||
@ -450,6 +478,14 @@ export default {
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 删除盘点作业记录(批量:record_ids 数组,单次≤200,兼容单值 recordId/record_id)
|
||||
// 仅 approved/checking 允许;查不到的 ID 计入 skipped_ids 不报错;删除后重算进度、主表状态不回退
|
||||
recordDelete: {
|
||||
path: "stock.check.recordDelete",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 完成盘点作业:主表置 completed
|
||||
finish: {
|
||||
path: "stock.check.finish",
|
||||
@ -470,6 +506,22 @@ export default {
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 添加盘点明细(按任务盘点类型决定维度):商品任务传 stock_ids;
|
||||
// 库位任务传 locations/location_ids(location_ids 优先),type=all 两者都不传则自动拉全仓启用库位
|
||||
// 仅 created/rejected 允许;已存在的盘点项自动跳过(幂等);完成后重算主表 total_items
|
||||
addDetail: {
|
||||
path: "stock.check.addDetail",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
},
|
||||
// 批量添加库位明细(兼容入口,转调 addDetail 的库位ID直查路径)
|
||||
addLocationDetail: {
|
||||
path: "stock.check.addLocationDetail",
|
||||
auth: true,
|
||||
method: "POST",
|
||||
isSystemApi: true
|
||||
}
|
||||
},
|
||||
pick: {
|
||||
79
src/core/utils/dev-log.js
Normal file
79
src/core/utils/dev-log.js
Normal file
@ -0,0 +1,79 @@
|
||||
/**
|
||||
* 测试包专用:把 JS 的 console 输出转发到 Android logcat(tag: jsLog),
|
||||
* 这样 `npm run dev:adb` 就能把真机 console 实时打到控制台(见 scripts/dev-adb.cjs)。
|
||||
*
|
||||
* 背景:uni-app 的 release / 离线打包产物默认**不会**把 JS console 输出到 logcat
|
||||
* (HBuilderX「运行到手机」用的是 debug 基座才有这个能力,其运行时类
|
||||
* io.dcloud.weex.ConsoleLogUtils 也是用 jsLog 这个 tag 转发 __LOG/__WARN 等前缀)。
|
||||
* 因此测试包自己用 plus.android 调 android.util.Log 落日志。
|
||||
*
|
||||
* 生效条件:构建时注入 VUE_APP_JS_LOG_TO_LOGCAT=1(仅 dev-adb 注入)。
|
||||
* 发行包里该判断是常量,整个分支会被 webpack 折叠掉,不产生运行时开销,也不会打日志。
|
||||
*/
|
||||
export function setupDevLogToLogcat () {
|
||||
// #ifdef APP-PLUS
|
||||
if (process.env.VUE_APP_JS_LOG_TO_LOGCAT !== '1') {
|
||||
return
|
||||
}
|
||||
|
||||
const LOG_TAG = 'jsLog'
|
||||
|
||||
const stringify = (args) => {
|
||||
const parts = []
|
||||
for (const arg of args) {
|
||||
if (typeof arg === 'string') {
|
||||
parts.push(arg)
|
||||
} else {
|
||||
try {
|
||||
parts.push(JSON.stringify(arg))
|
||||
} catch (e) {
|
||||
parts.push(String(arg))
|
||||
}
|
||||
}
|
||||
}
|
||||
return parts.join(' ')
|
||||
}
|
||||
|
||||
const install = () => {
|
||||
const androidLog = plus.android.importClass('android.util.Log')
|
||||
const wrapped = [['log', 'd'], ['info', 'i'], ['warn', 'w'], ['error', 'e']]
|
||||
for (const [name, level] of wrapped) {
|
||||
const origin = console[name] ? console[name].bind(console) : () => {}
|
||||
console[name] = (...args) => {
|
||||
origin(...args)
|
||||
try {
|
||||
androidLog[level](LOG_TAG, stringify(args))
|
||||
} catch (e) {
|
||||
// 单条日志失败不影响业务
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log('[dev-log] JS 日志已转发到 logcat(tag=jsLog),仅测试包生效')
|
||||
}
|
||||
|
||||
if (typeof plus !== 'undefined' && plus.android) {
|
||||
try {
|
||||
install()
|
||||
} catch (e) {
|
||||
console.warn('[dev-log] 初始化失败:', e && e.message)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// plus 尚未就绪时兜底重试(正常不会走到)
|
||||
let attempts = 0
|
||||
const timer = setInterval(() => {
|
||||
attempts += 1
|
||||
if (typeof plus !== 'undefined' && plus.android) {
|
||||
clearInterval(timer)
|
||||
try {
|
||||
install()
|
||||
} catch (e) {
|
||||
console.warn('[dev-log] 初始化失败:', e && e.message)
|
||||
}
|
||||
} else if (attempts >= 25) {
|
||||
clearInterval(timer)
|
||||
}
|
||||
}, 200)
|
||||
// #endif
|
||||
}
|
||||
25
src/env.js
Normal file
25
src/env.js
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 前端环境配置
|
||||
*
|
||||
* ⚠️ 防呆约定(曾有「开发地址被打进正式包」的隐患,勿随意改动):
|
||||
* 1. 生产构建(NODE_ENV=production)固定走 PROD_API_BASE,不采用任何 .env 文件里的地址,
|
||||
* 所以构建机上残留的开发地址不会进正式包;
|
||||
* 2. 开发地址只允许来自 `.env.development.local`(VUE_APP_API_BASE_URL,该文件 git 不跟踪),
|
||||
* 或命令行显式注入 `VUE_APP_API_BASE_OVERRIDE`(不写入任何 .env 文件,真机调试用);
|
||||
* 注意:不能写在 `.env.local`——那个文件在 production 模式同样会被加载并注入到客户端代码里;
|
||||
* 源码中也不保留内网地址字面量,否则不管走哪个分支都会被打进产物。
|
||||
* 3. 构建后由 `scripts/check-build-env.cjs` 扫描产物:含内网地址或缺少生产域名即中止构建。
|
||||
*/
|
||||
const PROD_API_BASE = 'http://qimen.wms.gztbyc.com' //生产环境接口地址
|
||||
|
||||
const isProd = process.env.NODE_ENV === 'production'
|
||||
// 命令行显式注入优先(不落盘,用于真机调试指向指定后端)
|
||||
const overrideApiBase = process.env.VUE_APP_API_BASE_OVERRIDE || ''
|
||||
// .env.development.local 注入的开发地址(仅 VUE_APP_ 前缀会被构建工具注入到代码里)
|
||||
const envFileApiBase = process.env.VUE_APP_API_BASE_URL || ''
|
||||
|
||||
export const BASE_URL = overrideApiBase || (isProd ? PROD_API_BASE : envFileApiBase) //接口根地址
|
||||
export const API_URL = `${BASE_URL}/system` //后台接口域名
|
||||
export const IMG_URL = process.env.VUE_APP_IMG_URL || 'https://ye4s.file.gzxunren.com' //全局网络图片地址变量,css背景图片地址变量在uni.scss
|
||||
export const IS_PROD_BUILD = isProd //是否生产构建(排查现场问题时便于页面展示)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user