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>
55 lines
1.8 KiB
JavaScript
55 lines
1.8 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 执行 sql/schema.sql 建表(本机没装 mysql 客户端时用它)
|
||
*
|
||
* 用法:
|
||
* npm run db:init # 执行 sql/schema.sql
|
||
* node scripts/init-db.js sql/xxx.sql # 执行指定 SQL 文件
|
||
*
|
||
* 连接信息来源:环境变量 > config/config.prod.js(EGG_SERVER_ENV=prod)> config/config.local.js > 内置默认值
|
||
*/
|
||
|
||
const fs = require('fs');
|
||
const path = require('path');
|
||
const mysql = require('mysql2/promise');
|
||
|
||
// 数据库连接信息统一在 scripts/db-config.js 里解析
|
||
// (环境变量 > config/config.prod.js(EGG_SERVER_ENV=prod)> config/config.local.js > 默认值)
|
||
const resolveDbConfig = require('./db-config');
|
||
|
||
/** 去掉 -- 行注释,再按分号切分成可逐条执行的语句 */
|
||
function splitStatements(sql) {
|
||
return sql
|
||
.split(/\r?\n/)
|
||
.filter((line) => !line.trim().startsWith('--'))
|
||
.join('\n')
|
||
.split(';')
|
||
.map((stmt) => stmt.trim())
|
||
.filter(Boolean);
|
||
}
|
||
|
||
async function main() {
|
||
const file = process.argv[2] || path.join(__dirname, '..', 'sql', 'schema.sql');
|
||
const config = resolveDbConfig();
|
||
const statements = splitStatements(fs.readFileSync(file, 'utf8'));
|
||
|
||
console.log(`[db:init] 连接 ${config.host}:${config.port}/${config.database} as ${config.user}`);
|
||
const conn = await mysql.createConnection(config);
|
||
try {
|
||
for (const stmt of statements) {
|
||
console.log(`[db:init] 执行: ${stmt.split('\n')[0].slice(0, 70)} ...`);
|
||
await conn.query(stmt);
|
||
}
|
||
const [tables] = await conn.query('SHOW TABLES');
|
||
console.log('[db:init] 完成,当前表: %s', tables.map((t) => Object.values(t)[0]).join(', ') || '(空)');
|
||
} finally {
|
||
await conn.end();
|
||
}
|
||
}
|
||
|
||
main().catch((err) => {
|
||
console.error(`[db:init] 失败: ${err.code || ''} ${err.message}`);
|
||
process.exit(1);
|
||
});
|