Files
wrong-notebook/scripts/package/android-version.mjs
margrop 384ba74a26 feat: 新增安卓手机版、平板版客户端,发布时随 Release 提供 APK
- packaging/android:原生 WebView 客户端,首次启动填写服务器地址并通过 /api/health 校验
- 手机版锁定竖屏、平板版横竖屏自动旋转,两个 flavor 共用一套代码
- 补齐拍照上传、blob 文件另存为、系统打印、外部链接、自签名证书确认等能力
- 网页「设置 → 关于」在客户端内显示当前服务器和「更换服务器」按钮
- build.mjs 新增 android 命令,versionCode 由日期版本号换算并保证递增
- packages.yml 新增 Android 构建,标签发布时要求固定签名密钥并上传 APK
- 同步 README、安装包文档与 Wiki

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 09:01:51 +08:00

17 lines
923 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 安卓 versionCode 必须随版本单调递增,由日期版本号换算:
* 预览版 2026.10.22-3 → 2026102203(当天序号 1–98)
* 正式版 2026.10.22 → 2026102299(排在当天所有预览版之后)
* git describe 形式(2026.10.22-3-gabc1234)按其所在的预览版计算。
*/
export function androidVersionCode(version) {
const match = /^v?(\d{4})\.(\d{1,2})\.(\d{1,2})(?:-(\d+))?/.exec(String(version));
if (!match) throw new Error(`无法从版本号 ${version} 计算安卓 versionCode,需形如 2026.10.22 或 2026.10.22-1`);
const [, year, month, day, seq] = match;
if (seq !== undefined && (Number(seq) < 1 || Number(seq) > 98)) {
throw new Error(`预览版序号需在 1–98 之间:${version}`);
}
const n = seq === undefined ? 99 : Number(seq);
return Number(year) * 1_000_000 + Number(month) * 10_000 + Number(day) * 100 + n;
}