AndroidStation(原中控改造为纯设备端) - 只做三件事:UDP 48899 被桌面端发现、TCP 8087 推送 USB 扫码结果、离线语音播报 - 扫码不再经过 UI:去掉逐键重绘,50ms 自动提交,同一码重复扫码也一律上报 - 离线语音种子(数字/字母/“开始打包”/欢迎语)随包安装,MediaPlayer 播放,启动把音量拉满 - 启动播报「欢迎使用溯源系统,初始化已经完成,扫码即可开始打包」 - 移除 Device Owner / 设备管理员 / lock task / 网络与 IP 设置等非普通应用能力(仅保留开机自启) - 正式签名 keystore + release 签名配置,versionName/versionCode 可由打包脚本覆盖 发布脚手架 - backend/android_client:Android 正式包构建(build.ps1 + package.config.json) - backend/scripts/deploy/publish-android.cjs + npm run android:build / android:publish - 桌面端安装包改为 download/desktop,Android 为 download/android_client; version.json 仍走 /download/version.json(老客户端写死),新增 /download/android_client/version.json - 谷歌插件随桌面端 MSI 安装到 <安装目录>\extension,工具菜单新增「复制谷歌插件地址」 - git-safety-check 增加仓库级禁区(keystore.properties / *.jks / local.properties) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
123 lines
3.1 KiB
JavaScript
123 lines
3.1 KiB
JavaScript
'use strict';
|
|
|
|
const path = require('node:path');
|
|
const {
|
|
ensureCommandAvailable,
|
|
loadDeployConfig,
|
|
quoteForBash,
|
|
runSsh,
|
|
} = require('./deploy-lib.cjs');
|
|
|
|
function parseArgs(argv) {
|
|
const options = { history: 0 };
|
|
for (const item of argv) {
|
|
if (!item) continue;
|
|
if (item.startsWith('--history=')) {
|
|
const value = Number(item.slice('--history='.length));
|
|
if (Number.isFinite(value) && value > 0) {
|
|
options.history = Math.floor(value);
|
|
}
|
|
}
|
|
}
|
|
return options;
|
|
}
|
|
|
|
function queryActiveInstance(config) {
|
|
const currentMdFile = path.posix.join(config.deployRoot, 'current.md');
|
|
const remoteScript = [
|
|
'set -euo pipefail',
|
|
`FILE=${quoteForBash(currentMdFile)}`,
|
|
'if [ -f "$FILE" ]; then',
|
|
' cat "$FILE"',
|
|
'else',
|
|
' echo CURRENT_MD_NOT_FOUND',
|
|
'fi',
|
|
].join('\n');
|
|
|
|
const raw = runSsh(config, remoteScript, { stdio: 'pipe' }).trim();
|
|
if (!raw || raw === 'CURRENT_MD_NOT_FOUND') {
|
|
return null;
|
|
}
|
|
|
|
const version = raw.replace(/[\r\n\s]/g, '');
|
|
if (version !== 'v1' && version !== 'v2') {
|
|
return null;
|
|
}
|
|
|
|
return { version, port: config.ports[version], currentMd: raw.split('\n')[0].trim() };
|
|
}
|
|
|
|
function queryCurrentRelease(config) {
|
|
const releaseFile = path.posix.join(config.stateDir, 'current-release.json');
|
|
const remoteScript = [
|
|
'set -euo pipefail',
|
|
`FILE=${quoteForBash(releaseFile)}`,
|
|
'if [ -f "$FILE" ]; then',
|
|
' cat "$FILE"',
|
|
'else',
|
|
' echo ONLINE_VERSION_NOT_FOUND',
|
|
'fi',
|
|
].join('\n');
|
|
|
|
const output = runSsh(config, remoteScript, { stdio: 'pipe' }).trim();
|
|
if (!output || output === 'ONLINE_VERSION_NOT_FOUND') {
|
|
return null;
|
|
}
|
|
|
|
try {
|
|
return JSON.parse(output);
|
|
} catch (error) {
|
|
return output;
|
|
}
|
|
}
|
|
|
|
function queryReleaseHistory(config, limit) {
|
|
const historyFile = path.posix.join(config.stateDir, 'release-history.jsonl');
|
|
const remoteScript = [
|
|
'set -euo pipefail',
|
|
`FILE=${quoteForBash(historyFile)}`,
|
|
`LIMIT=${Number(limit)}`,
|
|
'if [ -f "$FILE" ]; then',
|
|
' tail -n "$LIMIT" "$FILE"',
|
|
'else',
|
|
' echo ONLINE_VERSION_HISTORY_EMPTY',
|
|
'fi',
|
|
].join('\n');
|
|
|
|
const output = runSsh(config, remoteScript, { stdio: 'pipe' }).trim();
|
|
if (!output || output === 'ONLINE_VERSION_HISTORY_EMPTY') {
|
|
return null;
|
|
}
|
|
|
|
return output.split(/\r?\n/).map(item => item.trim()).filter(Boolean).map(line => {
|
|
try {
|
|
return JSON.parse(line);
|
|
} catch (error) {
|
|
return { raw: line };
|
|
}
|
|
});
|
|
}
|
|
|
|
function main() {
|
|
const envName = process.argv[2] || 'production';
|
|
const options = parseArgs(process.argv.slice(3));
|
|
|
|
ensureCommandAvailable('ssh', '请先安装 OpenSSH Client 并确保 ssh 在 PATH 中。');
|
|
const config = loadDeployConfig(envName);
|
|
const active = queryActiveInstance(config);
|
|
|
|
if (options.history > 0) {
|
|
console.log(JSON.stringify({ active, history: queryReleaseHistory(config, options.history) }, null, 2));
|
|
return;
|
|
}
|
|
|
|
console.log(JSON.stringify({ active, release: queryCurrentRelease(config) }, null, 2));
|
|
}
|
|
|
|
try {
|
|
main();
|
|
} catch (err) {
|
|
console.error(`[ERROR] ${err && err.message ? err.message : err}`);
|
|
process.exit(1);
|
|
}
|