From 7b11fc60c849c64c4e25e8febedb0a409de36e36 Mon Sep 17 00:00:00 2001 From: xuan <1359774872@qq.com> Date: Sat, 31 Oct 2026 19:01:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=8A=E4=BC=A0=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=89=8B=E6=9C=BA=E5=8F=B7=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/upload-apk.js | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/scripts/upload-apk.js b/scripts/upload-apk.js index 1d973a4..b5afc47 100644 --- a/scripts/upload-apk.js +++ b/scripts/upload-apk.js @@ -39,7 +39,7 @@ function parseArgs(argv) { for (let i = 0; i < argv.length; i += 1) { const key = argv[i]; const value = argv[i + 1]; - if (key === '--file' || key === '--target' || key === '--mode' || key === '--version') { + if (key === '--file' || key === '--target' || key === '--mode' || key === '--version' || key === '--phone' || key === '--password' || key === '--tenant') { args[key.slice(2)] = value; i += 1; } @@ -126,9 +126,9 @@ async function apiJson(apiBase, urlPath, { method = 'GET', token, body } = {}) { return data.data || {}; } -async function login(apiBase) { - const phone = await ask('手机号: '); - const password = await askPassword('密码: '); +async function login(apiBase, { phone: phoneArg, password: passwordArg, tenant: tenantArg } = {}) { + const phone = phoneArg || await ask('手机号: '); + const password = passwordArg || await askPassword('密码: '); if (!phone || !password) { throw new Error('请输入手机号和密码'); } @@ -148,14 +148,20 @@ async function login(apiBase) { let tenant = tenants[0]; if (tenants.length > 1) { - console.log('请选择账套:'); - tenants.forEach((item, index) => { - const name = item.company_name || item.database_name || item.tenant_contacts || item.tenant_management_id; - console.log(` ${index + 1}. ${name}`); - }); - const picked = Number(await ask('序号: ')); - tenant = tenants[picked - 1]; - if (!tenant) throw new Error('账套序号无效'); + if (tenantArg) { + const picked = Number(tenantArg); + tenant = tenants[picked - 1]; + if (!tenant) throw new Error('账套序号无效'); + } else { + console.log('请选择账套:'); + tenants.forEach((item, index) => { + const name = item.company_name || item.database_name || item.tenant_contacts || item.tenant_management_id; + console.log(` ${index + 1}. ${name}`); + }); + const picked = Number(await ask('序号: ')); + tenant = tenants[picked - 1]; + if (!tenant) throw new Error('账套序号无效'); + } } const second = await apiJson(apiBase, '/admin/v1/login', { @@ -248,7 +254,11 @@ async function main() { const fileName = `${version}.apk`; const saveKey = `/version/${upgradeName}/${fileName}`; const apiBase = API_BASE; - const token = await login(apiBase); + const token = await login(apiBase, { + phone: args.phone, + password: args.password, + tenant: args.tenant, + }); console.log(`版本号: ${version}`); console.log(`场景路径: ${saveKey}`);