From 5cee6482f80307fd599371814794d8d814dcc362 Mon Sep 17 00:00:00 2001 From: lixiaolong <702156524@qq.com> Date: Tue, 20 Oct 2026 15:35:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(assistant):=20=E4=BC=98=E5=8C=96=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E5=8A=A9=E6=89=8B=E5=8A=9F=E8=83=BD=E5=92=8C=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E5=BA=94=E7=94=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 实现业务确认单条目的移出和恢复功能 - 添加报价匹配明细中的跳过处理选项 - 重构移动应用的环境配置使用默认开发配置 - 更新移动应用Android版本号策略 - 替换到货操作组件为独立的操作组件 - 添加安装配置检查脚本 - 增强测试覆盖包括条目移出恢复和报价跳过场景 --- mobile-app/.env.example | 7 +- mobile-app/app.config.js | 2 +- mobile-app/config/development.json | 4 + mobile-app/config/environment.cjs | 7 +- mobile-app/deploy/DEVELOPMENT.html | 20 +++++ mobile-app/scripts/Build-Android.ps1 | 3 + mobile-app/scripts/Build-Development.ps1 | 10 +++ .../scripts/Stage-DevelopmentUpdate.ps1 | 24 +++++ .../scripts/Start-DevelopmentUpdates.ps1 | 36 ++++++++ .../scripts/check-installable-config.cjs | 19 ++++ mobile-app/scripts/ota-server.mjs | 12 ++- mobile-app/scripts/serve-development.mjs | 17 ++++ mobile-app/scripts/verify-development-ota.mjs | 53 +++++++++++ mobile-app/src/App.tsx | 9 +- mobile-app/src/core/arrival-actions.ts | 32 +++++++ mobile-app/src/core/modules.ts | 2 +- mobile-app/src/screens/ArrivalActions.tsx | 16 ++++ mobile-app/tests/arrival-actions.test.mjs | 88 +++++++++++++++++++ mobile-app/tests/installable-config.test.mjs | 36 ++++++++ mobile-app/tests/ota.test.mjs | 28 ++++++ mobile-app/tests/ui-contract.test.mjs | 2 +- .../AssistantConversationSafetyTest.java | 22 +++++ .../assistant/BusinessActionRegistryTest.java | 24 +++++ .../AssistantConversationCard.vue | 6 +- .../BusinessAssistant/AssistantDraft.vue | 26 ++++-- .../AssistantQuotePreview.vue | 17 +++- .../components/BusinessAssistant/index.vue | 20 ++++- .../src/utils/assistant-draft-exclusions.js | 27 ++++++ .../src/utils/assistant-quotation-review.js | 25 ++++++ .../assistant-quotation-review.spec.js | 67 ++++++++++++++ .../tests/ui/assistant-draft-review.html | 26 ++++++ .../unit/assistant-draft-exclusions.test.mjs | 37 ++++++++ .../unit/assistant-quotation-review.test.mjs | 37 ++++++++ 33 files changed, 731 insertions(+), 30 deletions(-) create mode 100644 mobile-app/config/development.json create mode 100644 mobile-app/deploy/DEVELOPMENT.html create mode 100644 mobile-app/scripts/Build-Development.ps1 create mode 100644 mobile-app/scripts/Stage-DevelopmentUpdate.ps1 create mode 100644 mobile-app/scripts/Start-DevelopmentUpdates.ps1 create mode 100644 mobile-app/scripts/check-installable-config.cjs create mode 100644 mobile-app/scripts/serve-development.mjs create mode 100644 mobile-app/scripts/verify-development-ota.mjs create mode 100644 mobile-app/src/core/arrival-actions.ts create mode 100644 mobile-app/src/screens/ArrivalActions.tsx create mode 100644 mobile-app/tests/arrival-actions.test.mjs create mode 100644 mobile-app/tests/installable-config.test.mjs create mode 100644 ruoyi-ui-vue3/src/utils/assistant-draft-exclusions.js create mode 100644 ruoyi-ui-vue3/src/utils/assistant-quotation-review.js create mode 100644 ruoyi-ui-vue3/tests/runtime/assistant-quotation-review.spec.js create mode 100644 ruoyi-ui-vue3/tests/ui/assistant-draft-review.html create mode 100644 ruoyi-ui-vue3/tests/unit/assistant-draft-exclusions.test.mjs create mode 100644 ruoyi-ui-vue3/tests/unit/assistant-quotation-review.test.mjs diff --git a/mobile-app/.env.example b/mobile-app/.env.example index 975d4a7..25a5316 100644 --- a/mobile-app/.env.example +++ b/mobile-app/.env.example @@ -1,8 +1,9 @@ # Build-time settings; never put credentials in APP_* or EXPO_PUBLIC_*. APP_ENV=dev -# For a phone, replace this with the development PC's LAN IP (not the phone's localhost). -APP_API_URL=http://127.0.0.1:8080 -APP_UPDATE_ORIGIN=http://127.0.0.1:8090 +# Defaults are in config/development.json. These optional overrides must match +# the installed APK when exporting updates. Never point a phone at loopback. +APP_API_URL=http://192.168.0.222:8080 +APP_UPDATE_ORIGIN=http://192.168.0.222:8090 EXPO_NO_TELEMETRY=1 # OTA server: defaults to loopback behind an internal reverse proxy. OTA_HOST=127.0.0.1 diff --git a/mobile-app/app.config.js b/mobile-app/app.config.js index d0ec83d..836b98e 100644 --- a/mobile-app/app.config.js +++ b/mobile-app/app.config.js @@ -6,7 +6,7 @@ module.exports = () => { name: env.variant === 'prod' ? 'CMVR 物资管理' : 'CMVR 物资管理·开发', slug: 'cmvr-wms', version: '1.0.0', orientation: 'portrait', userInterfaceStyle: 'automatic', platforms: ['android', 'web'], - android: { package: env.variant === 'prod' ? 'cn.cmvr.wms' : 'cn.cmvr.wms.dev', versionCode: 1, + android: { package: env.variant === 'prod' ? 'cn.cmvr.wms' : 'cn.cmvr.wms.dev', versionCode: env.variant === 'dev' ? 2 : 1, permissions: [], blockedPermissions: ['android.permission.RECORD_AUDIO'] }, plugins: ['expo-secure-store', 'expo-status-bar', './plugins/with-short-cmake-paths.cjs', './plugins/with-private-build-inputs.cjs', ['./plugins/with-internal-network.cjs', { hosts: cleartextHosts }], ...(env.variant === 'prod' ? ['./plugins/with-release-signing.cjs'] : [])], diff --git a/mobile-app/config/development.json b/mobile-app/config/development.json new file mode 100644 index 0000000..7b1a106 --- /dev/null +++ b/mobile-app/config/development.json @@ -0,0 +1,4 @@ +{ + "apiUrl": "http://192.168.0.222:8080", + "updateOrigin": "http://192.168.0.222:8090" +} diff --git a/mobile-app/config/environment.cjs b/mobile-app/config/environment.cjs index e7664f3..e40e471 100644 --- a/mobile-app/config/environment.cjs +++ b/mobile-app/config/environment.cjs @@ -1,5 +1,6 @@ const fs = require('node:fs'); const path = require('node:path'); +const development = require('./development.json'); function internal(value, dev) { const url = new URL(value); const p = url.hostname.split('.').map(Number); @@ -13,8 +14,10 @@ function environment(env = process.env) { const variant = env.APP_ENV || 'dev'; if (!['dev', 'prod'].includes(variant)) throw Error('APP_ENV 只能是 dev 或 prod'); const dev = variant === 'dev'; - const apiUrl = internal(env.APP_API_URL || (dev ? 'http://127.0.0.1:8080' : ''), dev); - const updateOrigin = internal(env.APP_UPDATE_ORIGIN || (dev ? 'http://127.0.0.1:8090' : ''), dev); + const apiUrl = internal(env.APP_API_URL || (dev ? development.apiUrl : ''), dev); + // Installed development apps reach the development PC, not the phone or production server. + // API selection remains independent and editable from the development app. + const updateOrigin = internal(env.APP_UPDATE_ORIGIN || (dev ? development.updateOrigin : ''), dev); if (new URL(updateOrigin).pathname !== '/') throw Error('APP_UPDATE_ORIGIN 只能包含协议、内网地址和端口。'); const certificate = path.resolve(__dirname, '../certs', `${variant}.pem`); if (!dev && !fs.existsSync(certificate)) throw Error('正式构建必须先配置 certs/prod.pem 更新签名证书。'); diff --git a/mobile-app/deploy/DEVELOPMENT.html b/mobile-app/deploy/DEVELOPMENT.html new file mode 100644 index 0000000..6135176 --- /dev/null +++ b/mobile-app/deploy/DEVELOPMENT.html @@ -0,0 +1,20 @@ + +开发 App 与内网热更新 +

开发 App 与内网热更新

2026-10-20。开发业务和更新均放开发电脑,不登录或修改正式环境 192.168.28.10。

+

地址统一保存在 mobile-app/config/development.json:业务 http://192.168.0.222:8080,更新 http://192.168.0.222:8090/updates/dev。开发 App 的业务地址仍可在登录页、设置中修改;更新地址独立固定,不跟随业务地址跳转。

+

首次安装与后续更新

旧开发包内置更新地址为手机自己的 127.0.0.1,需覆盖安装本次新包一次,保留同一包名和 Android 开发签名。之后页面和业务 JS 修复使用签名热更新;不需要 Expo Go 或重新安装。新增原生模块、修改 SDK、证书、原生网络设置等改变兼容指纹时仍需新包。

+

手机须能访问开发电脑,电脑及开发更新服务须保持运行。App 启动后后台检查并下载;在“我的→设置”看到更新已备妥后,完全退出并重新打开生效,不强制中断编辑。断网继续使用内置或已下载版本。

+

开发电脑启动服务

powershell -File mobile-app/scripts/Start-DevelopmentUpdates.ps1
+

服务只绑定配置中的本机内网 IP,允许 dev 通道,不服务 prod 通道。更新与安装包公开资源在 .codex-tmp/app-dev-ota,签名私钥不放在服务目录,不通过 HTTP 提供。当前进程信息、日志保存在该目录;重启电脑后重新运行启动脚本。不会停止其他未知进程。

+

下次发布页面更新

cd mobile-app
+# 保持与安装包相同的开发配置,不设置为 prod。
+$env:APP_ENV='dev'
+npm run typecheck
+npm test
+npm run ota:export
+powershell -File scripts/Stage-DevelopmentUpdate.ps1
+node scripts/verify-development-ota.mjs
+

暂存脚本会核对导出与最近 APK 的原生指纹,使用 dev 私钥签名,并把新版本及不可变资源写到开发服务目录;服务不必重启。发布前必须先通过测试。若要完整打包,使用 scripts/Build-Development.ps1;所有 APK 构建都会拒绝 loopback 更新地址或未签名配置。

+

正式环境、正式签名、正式更新通道均保持不变。开发电脑 IP 最好固定或做 DHCP 地址保留;如果 IP 改变,现有包的固定更新地址也会失效。不要关闭防火墙来排障,只按组织网络策略允许手机访问开发服务。

+

本机开发更新签名私钥长期保存在被 Git 忽略且限制访问的 mobile-app/keys/development/ota-private-key.pem,服务只挂公开资源,不提供私钥。保留并备份同一私钥和 certs/dev.pem;不要重新生成来替换,否则已安装客户端不会接受新签名。旧临时副本仅作保留备份,后续发布不依赖临时目录中的密钥。

+

服务端签名、资源哈希和协议验证不等于真机已完成下载与重启生效验收,须在手机上另行核对。

diff --git a/mobile-app/scripts/Build-Android.ps1 b/mobile-app/scripts/Build-Android.ps1 index 416e1b1..f1dcd2e 100644 --- a/mobile-app/scripts/Build-Android.ps1 +++ b/mobile-app/scripts/Build-Android.ps1 @@ -21,6 +21,9 @@ New-Item -ItemType Directory -Path $taskTmp -Force | Out-Null $env:JAVA_TOOL_OPTIONS = "$env:JAVA_TOOL_OPTIONS -Dfile.encoding=UTF-8 -Djava.io.tmpdir=$taskTmp -Djdk.net.unixdomain.tmpdir=$taskTmp" Push-Location $taskApp try { + # Run for every installable APK, not only the development convenience wrapper. + & node.exe (Join-Path $PSScriptRoot 'check-installable-config.cjs') + if ($LASTEXITCODE) { throw 'Installable App update configuration is invalid' } & npm.cmd run typecheck if ($LASTEXITCODE) { throw 'Type checking failed' } & npm.cmd test diff --git a/mobile-app/scripts/Build-Development.ps1 b/mobile-app/scripts/Build-Development.ps1 new file mode 100644 index 0000000..37516da --- /dev/null +++ b/mobile-app/scripts/Build-Development.ps1 @@ -0,0 +1,10 @@ +param([string]$ApiUrl = '', [string]$UpdateOrigin = '') +$ErrorActionPreference = 'Stop' +$taskApp = Split-Path $PSScriptRoot -Parent +$taskRepo = Split-Path $taskApp -Parent +$taskDevelopment = Get-Content -LiteralPath (Join-Path $taskApp 'config/development.json') -Raw | ConvertFrom-Json +if (!$ApiUrl) { $ApiUrl = $taskDevelopment.apiUrl } +if (!$UpdateOrigin) { $UpdateOrigin = $taskDevelopment.updateOrigin } +$env:APP_API_URL = $ApiUrl +$env:APP_UPDATE_ORIGIN = $UpdateOrigin +& (Join-Path $PSScriptRoot 'Build-Android.ps1') -Environment dev -GradlePath (Join-Path $taskRepo '.codex-tmp/expo-tools/gradle-9.4.1/bin/gradle.bat') diff --git a/mobile-app/scripts/Stage-DevelopmentUpdate.ps1 b/mobile-app/scripts/Stage-DevelopmentUpdate.ps1 new file mode 100644 index 0000000..5058af4 --- /dev/null +++ b/mobile-app/scripts/Stage-DevelopmentUpdate.ps1 @@ -0,0 +1,24 @@ +param([string]$OutputDirectory = '', [string]$UpdateOrigin = '') +$ErrorActionPreference = 'Stop' +$taskApp = Split-Path $PSScriptRoot -Parent +$taskRepo = Split-Path $taskApp -Parent +if (!$OutputDirectory) { $OutputDirectory = Join-Path $taskRepo '.codex-tmp/app-dev-ota/data' } +if (!$UpdateOrigin) { $UpdateOrigin = (Get-Content -LiteralPath (Join-Path $taskApp 'config/development.json') -Encoding UTF8 -Raw | ConvertFrom-Json).updateOrigin } +try { + $env:APP_ENV = 'dev' + $env:APP_UPDATE_ORIGIN = $UpdateOrigin + $env:OTA_PRIVATE_KEY = Join-Path $taskApp 'keys/development/ota-private-key.pem' + $env:OTA_CERTIFICATE = Join-Path $taskApp 'certs/dev.pem' + $env:OTA_DATA_DIR = $OutputDirectory + $taskRuntime = (Get-Content -LiteralPath (Join-Path $taskApp 'dist/runtime-version.txt') -Raw).Trim() + $taskApkRuntime = (Get-Content -LiteralPath (Join-Path $taskApp 'android/app/build/generated/assets/createReleaseUpdatesResources/fingerprint') -Raw).Trim() + if ($taskRuntime -ne $taskApkRuntime) { throw 'Export fingerprint differs from built APK; rebuild before staging' } + $taskExportConfig = Get-Content -LiteralPath (Join-Path $taskApp 'dist/resolved-config.json') -Encoding UTF8 -Raw | ConvertFrom-Json + if ($taskExportConfig.extra.environment -ne 'dev' -or $taskExportConfig.updates.url -ne ($UpdateOrigin.TrimEnd('/') + '/updates/dev')) { + throw 'Exported App update URL differs from the development feed; export with matching development config first' + } + & node.exe (Join-Path $PSScriptRoot 'publish-update.mjs') (Join-Path $taskApp 'dist') (Join-Path $taskApp 'dist/resolved-config.json') $taskRuntime + if ($LASTEXITCODE) { throw 'Local signed development update staging failed' } +} finally { + foreach ($taskName in @('OTA_PRIVATE_KEY','OTA_CERTIFICATE')) { Remove-Item -LiteralPath "Env:$taskName" -ErrorAction SilentlyContinue } +} diff --git a/mobile-app/scripts/Start-DevelopmentUpdates.ps1 b/mobile-app/scripts/Start-DevelopmentUpdates.ps1 new file mode 100644 index 0000000..26e39a4 --- /dev/null +++ b/mobile-app/scripts/Start-DevelopmentUpdates.ps1 @@ -0,0 +1,36 @@ +$ErrorActionPreference = 'Stop' +$taskApp = Split-Path $PSScriptRoot -Parent +$taskRepo = Split-Path $taskApp -Parent +$taskDir = Join-Path $taskRepo '.codex-tmp/app-dev-ota' +$taskServer = Join-Path $PSScriptRoot 'serve-development.mjs' +$taskConfig = Get-Content -LiteralPath (Join-Path $taskApp 'config/development.json') -Raw | ConvertFrom-Json +$taskOrigin = $taskConfig.updateOrigin +New-Item -ItemType Directory -Path $taskDir -Force | Out-Null +$taskRecord = Join-Path $taskDir 'server.json' +if (Test-Path -LiteralPath $taskRecord) { + $taskPrevious = Get-Content -LiteralPath $taskRecord -Raw | ConvertFrom-Json + $taskExisting = Get-CimInstance Win32_Process -Filter "ProcessId=$($taskPrevious.pid)" + if ($taskExisting -and $taskExisting.Name -eq 'node.exe' -and $taskExisting.CommandLine.Contains($taskServer) -and $taskPrevious.origin -eq $taskOrigin) { + if ((Invoke-WebRequest -Uri ($taskOrigin + '/health') -TimeoutSec 5 -UseBasicParsing).Content.Trim() -eq 'ok') { + Write-Output ('Development updates already running: ' + $taskOrigin) + exit 0 + } + } + if ($taskExisting) { throw 'Recorded process does not match a healthy development update server; no process stopped.' } +} +$taskNode = (Get-Command node.exe).Source +$taskProcess = Start-Process -FilePath $taskNode -ArgumentList ('"' + $taskServer + '"') -WorkingDirectory $taskApp -WindowStyle Hidden -PassThru ` + -RedirectStandardOutput (Join-Path $taskDir 'server.out.log') -RedirectStandardError (Join-Path $taskDir 'server.err.log') +for ($taskAttempt = 0; $taskAttempt -lt 20; $taskAttempt++) { + Start-Sleep -Milliseconds 250 + $taskProcess.Refresh() + if ($taskProcess.HasExited) { throw (Get-Content -LiteralPath (Join-Path $taskDir 'server.err.log') -Raw) } + try { + if ((Invoke-WebRequest -Uri ($taskOrigin + '/health') -TimeoutSec 2 -UseBasicParsing).Content.Trim() -eq 'ok') { + [IO.File]::WriteAllText($taskRecord, (@{pid=$taskProcess.Id;origin=$taskOrigin;script=$taskServer} | ConvertTo-Json)) + Write-Output ('Development updates running: ' + $taskOrigin) + exit 0 + } + } catch { } +} +throw 'Development update service did not become ready; inspect .codex-tmp/app-dev-ota/server.err.log' diff --git a/mobile-app/scripts/check-installable-config.cjs b/mobile-app/scripts/check-installable-config.cjs new file mode 100644 index 0000000..ca3de47 --- /dev/null +++ b/mobile-app/scripts/check-installable-config.cjs @@ -0,0 +1,19 @@ +const { internal } = require('../config/environment.cjs'); + +function assertInstallableConfig(config) { + const variant = config.extra?.environment; + if (!['dev', 'prod'].includes(variant)) throw Error('Explicit App environment required'); + if (!config.updates?.enabled || !config.updates.codeSigningCertificate) throw Error('Installable App requires signed updates'); + const url = new URL(config.updates.url); + // Loopback is valid for local preview, never for an APK delivered to phones. + internal(url.origin, false); + if (url.pathname !== `/updates/${variant}` || url.search || url.hash) throw Error('Update channel must match App environment'); + if (config.updates.codeSigningMetadata?.keyid !== variant) throw Error('Update signing key must match App environment'); + if (config.android?.package !== (variant === 'dev' ? 'cn.cmvr.wms.dev' : 'cn.cmvr.wms')) throw Error('App package/environment mismatch'); + return url.toString(); +} +module.exports = { assertInstallableConfig }; +if (require.main === module) { + const config = require('../app.config.js')(); + console.log(`Installable ${config.extra.environment} App: ${assertInstallableConfig(config)}`); +} diff --git a/mobile-app/scripts/ota-server.mjs b/mobile-app/scripts/ota-server.mjs index 750c498..398bbea 100644 --- a/mobile-app/scripts/ota-server.mjs +++ b/mobile-app/scripts/ota-server.mjs @@ -3,8 +3,10 @@ import { readFile, realpath } from 'node:fs/promises'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; -export function createOtaServer({ root, environments = ['dev', 'prod'] }) { +export function createOtaServer({ root, environments = ['dev', 'prod'], downloadDirectory }) { if (!environments.length || environments.some(value => !['dev', 'prod'].includes(value))) throw Error('Invalid OTA environment allowlist'); + if (downloadDirectory && (environments.length !== 1 || environments[0] !== 'dev')) throw Error('APK downloads are development-only'); + if (downloadDirectory) downloadDirectory = path.resolve(downloadDirectory); root = path.resolve(root); const server = http.createServer(async (req, res) => { const common = { 'expo-protocol-version': '1', 'expo-sfv-version': '0', @@ -13,6 +15,14 @@ export function createOtaServer({ root, environments = ['dev', 'prod'] }) { if (!['GET', 'HEAD'].includes(req.method)) return send(405, 'Method not allowed'); try { const url = new URL(req.url, 'http://localhost'); + const download = /^\/downloads\/(cmvr-wms-dev-[a-zA-Z0-9-]+\.apk)$/.exec(url.pathname); + if (download && downloadDirectory) { + const dir = await realpath(downloadDirectory); + const file = await realpath(path.join(dir, download[1])); + if (path.dirname(file) !== dir) throw Error('Invalid download path'); + return send(200, await readFile(file), { 'content-type': 'application/vnd.android.package-archive', + 'content-disposition': `attachment; filename="${download[1]}"` }); + } const update = /^\/updates\/(dev|prod)$/.exec(url.pathname); if (update) { if (!environments.includes(update[1])) return send(404, 'Not found'); diff --git a/mobile-app/scripts/serve-development.mjs b/mobile-app/scripts/serve-development.mjs new file mode 100644 index 0000000..b16e2d5 --- /dev/null +++ b/mobile-app/scripts/serve-development.mjs @@ -0,0 +1,17 @@ +import path from 'node:path'; +import os from 'node:os'; +import {fileURLToPath} from 'node:url'; +import {createRequire} from 'node:module'; +import {createOtaServer} from './ota-server.mjs'; +const require=createRequire(import.meta.url); +const {internal}=require('../config/environment.cjs'); +const development=require('../config/development.json'); +const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'../..'); +const origin=new URL(internal(development.updateOrigin,false)); +if(origin.protocol!=='http:'||origin.pathname!=='/')throw Error('Development listener requires a direct local HTTP origin'); +const addresses=Object.values(os.networkInterfaces()).flat().filter(Boolean).map(item=>item.address); +if(!addresses.includes(origin.hostname))throw Error('Development update IP is not assigned to this computer; check config/development.json'); +const server=createOtaServer({root:path.join(root,'.codex-tmp/app-dev-ota/data'),environments:['dev'], + downloadDirectory:path.join(root,'.codex-tmp/app-dev-ota/downloads')}); +server.listen(Number(origin.port||80),origin.hostname,()=>console.log(`Development-only updates ready: ${origin.origin}/updates/dev`)); +server.on('error',error=>{console.error(error.message);process.exitCode=1;}); diff --git a/mobile-app/scripts/verify-development-ota.mjs b/mobile-app/scripts/verify-development-ota.mjs new file mode 100644 index 0000000..fa43332 --- /dev/null +++ b/mobile-app/scripts/verify-development-ota.mjs @@ -0,0 +1,53 @@ +import assert from 'node:assert/strict'; +import {readFile,writeFile} from 'node:fs/promises'; +import {createHash,verify,X509Certificate} from 'node:crypto'; +import {createRequire} from 'node:module'; +const require=createRequire(import.meta.url),config=require('../config/development.json'); +const runtime=(await readFile(new URL('../dist/runtime-version.txt',import.meta.url),'utf8')).trim(); +const origin=config.updateOrigin,headers={'expo-platform':'android','expo-runtime-version':runtime,'expo-protocol-version':'1', + 'expo-expect-signature':'sig, keyid="dev", alg="rsa-v1_5-sha256"'}; +const request=route=>fetch(origin+route,{headers,redirect:'error',signal:AbortSignal.timeout(15000)}); +const response=await request('/updates/dev');assert.equal(response.status,200); +assert.match(response.headers.get('content-type'),/application\/expo\+json/); +const bytes=Buffer.from(await response.arrayBuffer()),manifest=JSON.parse(bytes); +const signatureHeader=response.headers.get('expo-signature');assert.match(signatureHeader,/keyid="dev"/); +const signature=Buffer.from(/sig="([^"]+)"/.exec(signatureHeader)[1],'base64'); +const cert=new X509Certificate(await readFile(new URL('../certs/dev.pem',import.meta.url))); +assert.equal(verify('RSA-SHA256',bytes,cert.publicKey,signature),true); +assert.equal(verify('RSA-SHA256',Buffer.concat([bytes,Buffer.from('tampered')]),cert.publicKey,signature),false); +const prod=new X509Certificate(await readFile(new URL('../certs/prod.pem',import.meta.url))); +assert.equal(verify('RSA-SHA256',bytes,prod.publicKey,signature),false); +assert.equal(manifest.runtimeVersion,runtime);assert.equal(manifest.metadata.environment,'dev'); +assert.equal(manifest.extra.expoClient.extra.apiUrl,config.apiUrl); +assert.equal(manifest.extra.expoClient.updates.url,origin+'/updates/dev'); +const assets=[]; +for(const asset of [manifest.launchAsset,...manifest.assets]){ + const url=new URL(asset.url);assert.equal(url.origin,origin);assert.match(url.pathname,/^\/assets\/[a-f0-9]{64}$/); + const result=await request(url.pathname);assert.equal(result.status,200);assert.match(result.headers.get('cache-control'),/immutable/); + const content=Buffer.from(await result.arrayBuffer()); + assert.equal(createHash('sha256').update(content).digest('base64url'),asset.hash); + assets.push({hash:asset.hash,bytes:content.length}); +} +assert.equal((await request('/updates/prod')).status,404); +const incompatible=await fetch(origin+'/updates/dev',{headers:{...headers,'expo-runtime-version':'wrong-native-runtime'}}); +assert.equal(incompatible.status,200);assert.match(incompatible.headers.get('content-type'),/multipart\/mixed/); +assert.equal((await request('/keys/private-key.pem')).status,404); +assert.equal((await request('/downloads/private-key.pem')).status,404); +const api=await fetch(config.apiUrl+'/captchaImage',{signal:AbortSignal.timeout(10000)}); +assert.equal(api.status,200);assert.equal((await api.json()).code,200); +let downloadedApk; +try { + const info=JSON.parse(await readFile(new URL('../../.codex-tmp/app-dev-ota/apk-verification.json',import.meta.url),'utf8')); + assert.equal(info.runtime,runtime);assert.equal(new URL(info.url).origin,origin); + const response=await request(new URL(info.url).pathname);assert.equal(response.status,200); + assert.match(response.headers.get('content-type'),/android.package-archive/); + const apk=Buffer.from(await response.arrayBuffer());assert.equal(apk.length,info.bytes); + assert.equal(createHash('sha256').update(apk).digest('hex'),info.sha256); + downloadedApk={url:info.url,bytes:apk.length,sha256:info.sha256,downloadHashMatched:true}; +} catch(error) {if(error.code!=='ENOENT')throw error;} +const result={checkedAt:new Date().toISOString(),environment:'dev',updateUrl:origin+'/updates/dev',apiUrl:config.apiUrl, + runtime,updateId:manifest.id,signatureVerified:true,tamperedManifestRejected:true,productionKeyRejected:true, + productionChannelBlocked:true,incompatibleRuntimeIsolated:true,privatePathsBlocked:true,assets, + developmentApiReachable:true,downloadedApk,productionEnvironmentModified:false,physicalDeviceAcceptance:'pending'}; +if(process.argv[2])await writeFile(process.argv[2],JSON.stringify(result,null,2)); +console.log(JSON.stringify(result,null,2)); diff --git a/mobile-app/src/App.tsx b/mobile-app/src/App.tsx index ed73b14..d607622 100644 --- a/mobile-app/src/App.tsx +++ b/mobile-app/src/App.tsx @@ -13,6 +13,7 @@ import { modules, display, recordDisplay, routeComponents, validDate, type Modul import { AppearanceContext, Button, Card, Choice, Field, Heading, Icon, Note, s, useTheme, type Appearance, type IconName } from './ui'; import { Assistant } from './screens/Assistant'; import { ArrivalOperation } from './screens/ArrivalOperation'; +import { ArrivalActions } from './screens/ArrivalActions'; import { Workspace, BusinessHub, Me, Settings } from './screens/Workspace'; import { Account, type LeaveGuard } from './screens/Account'; import { Feedback } from './screens/Feedback'; @@ -149,15 +150,13 @@ function BusinessList({api,module,permissions}:{api:ApiClient;module:Module;perm
- +
业务已处理,可刷新当前页面查看最新数据。刷新当前页面
@@ -23,8 +23,8 @@ import { assistantDraftCounts, assistantDraftStatus, assistantSkippedResults } f import AssistantDraft from './AssistantDraft.vue' import AssistantResults from './AssistantResults.vue' -const props = defineProps({ draft: { type: Object, required: true }, action: Object, rows: { type: Array, default: () => [] }, active: Boolean, busy: Boolean, wide: Boolean }) -defineEmits(['change', 'refresh-page', 'expand']) +const props = defineProps({ draft: { type: Object, required: true }, action: Object, rows: { type: Array, default: () => [] }, excludedRows: { type: Array, default: () => [] }, active: Boolean, busy: Boolean, wide: Boolean }) +defineEmits(['change', 'refresh-page', 'expand', 'remove', 'restore']) const expanded = ref(false) const status = computed(() => assistantDraftStatus(props.draft)) const counts = computed(() => assistantDraftCounts(props.draft)) diff --git a/ruoyi-ui-vue3/src/components/BusinessAssistant/AssistantDraft.vue b/ruoyi-ui-vue3/src/components/BusinessAssistant/AssistantDraft.vue index 9f9cb3c..9ddedac 100644 --- a/ruoyi-ui-vue3/src/components/BusinessAssistant/AssistantDraft.vue +++ b/ruoyi-ui-vue3/src/components/BusinessAssistant/AssistantDraft.vue @@ -1,11 +1,11 @@