From 95effeeff210b6d6d5ed3562df4200e5e6b72a1f Mon Sep 17 00:00:00 2001 From: lixiaolong <702156524@qq.com> Date: Thu, 29 Oct 2026 17:27:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(app):=20=E4=BC=98=E5=8C=96=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=E5=BA=94=E7=94=A8=E9=85=8D=E7=BD=AE=E5=92=8C?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加生产环境服务器地址配置支持内外网切换 - 实现采购列表只看我创建的功能开关 - 更新构建脚本中的默认生产环境API地址 - 优化采购单表格单元格编辑体验改用自动补全组件 - 调整应用更新检查逻辑增强生产环境兼容性 - 修复开发服务器切换时的一些验证问题 - 增强应用启动时的服务地址配置灵活性 --- mobile-app/app.config.js | 4 +- mobile-app/config/environment.cjs | 9 ++- mobile-app/plugins/with-internal-network.cjs | 2 +- mobile-app/scripts/Build-Production.ps1 | 2 +- mobile-app/scripts/Stage-ProductionUpdate.ps1 | 3 +- .../scripts/check-installable-config.cjs | 2 +- mobile-app/scripts/publish-update.mjs | 2 +- mobile-app/scripts/verify-production-ota.mjs | 4 +- mobile-app/src/App.tsx | 25 ++++--- mobile-app/src/PackageUpdates.tsx | 14 ++-- mobile-app/src/core/network.ts | 9 ++- mobile-app/src/core/package-update.ts | 10 +++ mobile-app/src/core/server-address.ts | 6 +- mobile-app/src/screens/ArrivalListParts.tsx | 13 +++- mobile-app/src/screens/BusinessList.tsx | 18 +++-- mobile-app/src/screens/LoginView.tsx | 5 +- mobile-app/tests/package-update.test.mjs | 10 ++- .../tests/production-connection.test.mjs | 16 ++++ .../production-network-security.test.mjs | 29 ++++++++ mobile-app/tests/purchase-only-mine.test.mjs | 22 ++++++ mobile-app/tests/server-address.test.mjs | 4 +- .../warehouse/PurchaseRequestController.java | 12 ++- .../warehouse/SupplierInquiryExport.java | 56 ++++++++++---- .../PurchaseOnlyMineMapperTest.java | 74 +++++++++++++++++++ .../PurchaseOnlyMineControllerTest.java | 45 +++++++++++ .../SupplierInquiryRoundTripTest.java | 45 ++++++++++- .../ruoyi/warehouse/domain/PurchaseBatch.java | 3 + .../warehouse/domain/PurchaseRequest.java | 5 ++ .../mapper/warehouse/PurchaseBatchMapper.xml | 9 ++- .../warehouse/PurchaseRequestMapper.xml | 1 + .../src/components/PurchaseSheet/Cell.vue | 46 ++++++++++-- .../src/components/PurchaseSheet/Lookup.vue | 6 +- .../PurchaseSheet/SupplierQuotation.vue | 31 ++++++-- .../src/components/PurchaseSheet/index.vue | 36 ++++++--- .../src/utils/purchase-link-label.js | 15 ++++ .../src/utils/purchase-paste-continuation.js | 16 ++++ ruoyi-ui-vue3/src/utils/purchase-sheet.js | 2 +- .../src/views/warehouse/purchase/index.vue | 6 +- .../tests/runtime/arrival-only-mine.spec.js | 14 ++++ .../runtime/purchase-amount-order.spec.js | 5 +- .../runtime/purchase-catalog-search.spec.js | 45 +++++++++++ .../tests/runtime/purchase-excel-edit.spec.js | 2 - .../tests/runtime/purchase-only-mine.spec.js | 30 ++++++++ .../tests/unit/purchase-link-label.test.mjs | 20 +++++ .../unit/purchase-paste-continuation.test.mjs | 23 ++++++ 45 files changed, 652 insertions(+), 104 deletions(-) create mode 100644 mobile-app/tests/production-connection.test.mjs create mode 100644 mobile-app/tests/production-network-security.test.mjs create mode 100644 mobile-app/tests/purchase-only-mine.test.mjs create mode 100644 ruoyi-admin/src/test/java/com/ruoyi/projectdev/PurchaseOnlyMineMapperTest.java create mode 100644 ruoyi-admin/src/test/java/com/ruoyi/web/controller/warehouse/PurchaseOnlyMineControllerTest.java create mode 100644 ruoyi-ui-vue3/src/utils/purchase-link-label.js create mode 100644 ruoyi-ui-vue3/src/utils/purchase-paste-continuation.js create mode 100644 ruoyi-ui-vue3/tests/runtime/arrival-only-mine.spec.js create mode 100644 ruoyi-ui-vue3/tests/runtime/purchase-catalog-search.spec.js create mode 100644 ruoyi-ui-vue3/tests/runtime/purchase-only-mine.spec.js create mode 100644 ruoyi-ui-vue3/tests/unit/purchase-link-label.test.mjs create mode 100644 ruoyi-ui-vue3/tests/unit/purchase-paste-continuation.test.mjs diff --git a/mobile-app/app.config.js b/mobile-app/app.config.js index a3e12e9..0dddd13 100644 --- a/mobile-app/app.config.js +++ b/mobile-app/app.config.js @@ -1,13 +1,13 @@ const { environment } = require('./config/environment.cjs'); module.exports = () => { const env = environment(); - const cleartextHosts = [...new Set([env.apiUrl, env.updateOrigin].filter(url => url.startsWith('http:')).map(url => new URL(url).hostname))]; + const cleartextHosts = [...new Set([...([env.apiUrl, env.updateOrigin].filter(url => url.startsWith('http:')).map(url => new URL(url).hostname)), ...(env.variant === 'prod' ? ['192.168.28.10'] : [])])]; return { name: env.variant === 'prod' ? '设备科综合管理系统' : '设备科综合管理系统·开发', icon: `./assets/brand/app-icon-blue-${env.variant}.png`, 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: env.variant === 'dev' ? 5 : 3, + android: { package: env.variant === 'prod' ? 'cn.cmvr.wms' : 'cn.cmvr.wms.dev', versionCode: env.variant === 'dev' ? 7 : 5, adaptiveIcon: { foregroundImage: `./assets/brand/app-icon-blue-${env.variant}-adaptive.png`, backgroundColor: '#ffffff' }, permissions: ['android.permission.REQUEST_INSTALL_PACKAGES'], blockedPermissions: ['android.permission.RECORD_AUDIO'] }, plugins: ['./plugins/with-apk-installer.cjs', 'expo-sharing', '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 }], diff --git a/mobile-app/config/environment.cjs b/mobile-app/config/environment.cjs index e40e471..e4c6bff 100644 --- a/mobile-app/config/environment.cjs +++ b/mobile-app/config/environment.cjs @@ -1,12 +1,13 @@ const fs = require('node:fs'); const path = require('node:path'); const development = require('./development.json'); -function internal(value, dev) { +function internal(value, dev, production = false) { const url = new URL(value); const p = url.hostname.split('.').map(Number); const ipv4 = p.length === 4 && p.every(v => Number.isInteger(v) && v >= 0 && v <= 255); + const publicProduction = production && url.origin === 'https://wms.svc.cmvr-iot.icu'; if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.search || url.hash - || !(ipv4 && (p[0] === 10 || p[0] === 192 && p[1] === 168 || p[0] === 172 && p[1] >= 16 && p[1] <= 31) + || !(publicProduction || ipv4 && (p[0] === 10 || p[0] === 192 && p[1] === 168 || p[0] === 172 && p[1] >= 16 && p[1] <= 31) || dev && ['localhost', '127.0.0.1'].includes(url.hostname))) throw Error('App 地址必须是内网 IPv4 地址;开发环境也可用 localhost。'); return url.toString().replace(/\/$/, ''); } @@ -14,10 +15,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 ? development.apiUrl : ''), dev); + const apiUrl = internal(env.APP_API_URL || (dev ? development.apiUrl : 'https://wms.svc.cmvr-iot.icu/prod-api'), dev, !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); + const updateOrigin = internal(env.APP_UPDATE_ORIGIN || (dev ? development.updateOrigin : 'https://wms.svc.cmvr-iot.icu'), dev, !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/plugins/with-internal-network.cjs b/mobile-app/plugins/with-internal-network.cjs index d2029b7..ffdc5cf 100644 --- a/mobile-app/plugins/with-internal-network.cjs +++ b/mobile-app/plugins/with-internal-network.cjs @@ -7,7 +7,7 @@ const { environment } = require('../config/environment.cjs'); module.exports = (config, options) => { const env = environment(); const hosts = [...new Set(options?.hosts || [])]; - const expected = [...new Set([env.apiUrl, env.updateOrigin].filter(s => s.startsWith('http:')).map(s => new URL(s).hostname))]; + const expected = [...new Set([...([env.apiUrl, env.updateOrigin].filter(s => s.startsWith('http:')).map(s => new URL(s).hostname)), ...(env.variant === 'prod' ? ['192.168.28.10'] : [])])]; if (JSON.stringify(hosts) !== JSON.stringify(expected)) throw Error('Native network hosts must match the environment config'); config = withAndroidManifest(config, cfg => { const app = cfg.modResults.manifest.application[0]; diff --git a/mobile-app/scripts/Build-Production.ps1 b/mobile-app/scripts/Build-Production.ps1 index 5eabf87..c24d2b5 100644 --- a/mobile-app/scripts/Build-Production.ps1 +++ b/mobile-app/scripts/Build-Production.ps1 @@ -1,4 +1,4 @@ -param([string]$ApiUrl = 'http://192.168.28.10/prod-api', [string]$UpdateOrigin = 'http://192.168.28.10') +param([string]$ApiUrl = 'https://wms.svc.cmvr-iot.icu/prod-api', [string]$UpdateOrigin = 'https://wms.svc.cmvr-iot.icu') $ErrorActionPreference = 'Stop' $taskApp = Split-Path $PSScriptRoot -Parent $taskRepo = Split-Path $taskApp -Parent diff --git a/mobile-app/scripts/Stage-ProductionUpdate.ps1 b/mobile-app/scripts/Stage-ProductionUpdate.ps1 index 3940413..20be312 100644 --- a/mobile-app/scripts/Stage-ProductionUpdate.ps1 +++ b/mobile-app/scripts/Stage-ProductionUpdate.ps1 @@ -4,13 +4,14 @@ $taskApp = Split-Path $PSScriptRoot -Parent $taskRepo = Split-Path $taskApp -Parent $taskSigning = Join-Path $taskApp 'keys/production' if (!$OutputDirectory) { $OutputDirectory = Join-Path $taskRepo '.codex-tmp/expo-prod-ota-staged' } +Add-Type -AssemblyName System.Security $taskProtected = [IO.File]::ReadAllBytes((Join-Path $taskSigning 'credentials.machine.dpapi')) $taskUnprotected = [System.Security.Cryptography.ProtectedData]::Unprotect($taskProtected, $null, [System.Security.Cryptography.DataProtectionScope]::LocalMachine) try { $taskCredentials = [Text.Encoding]::UTF8.GetString($taskUnprotected) | ConvertFrom-Json } finally { [Array]::Clear($taskUnprotected, 0, $taskUnprotected.Length) } try { $env:APP_ENV = 'prod' - $env:APP_UPDATE_ORIGIN = 'http://192.168.28.10' + $env:APP_UPDATE_ORIGIN = 'https://wms.svc.cmvr-iot.icu' $env:OTA_PRIVATE_KEY = Join-Path $taskSigning 'ota-private-key.pem' $env:OTA_KEY_PASSPHRASE = $taskCredentials.otaPassword $env:OTA_CERTIFICATE = Join-Path $taskApp 'certs/prod.pem' diff --git a/mobile-app/scripts/check-installable-config.cjs b/mobile-app/scripts/check-installable-config.cjs index ca3de47..c74dc13 100644 --- a/mobile-app/scripts/check-installable-config.cjs +++ b/mobile-app/scripts/check-installable-config.cjs @@ -6,7 +6,7 @@ function assertInstallableConfig(config) { 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); + internal(url.origin, false, variant === 'prod'); 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'); diff --git a/mobile-app/scripts/publish-update.mjs b/mobile-app/scripts/publish-update.mjs index 97626ef..4c89fca 100644 --- a/mobile-app/scripts/publish-update.mjs +++ b/mobile-app/scripts/publish-update.mjs @@ -10,7 +10,7 @@ const types = { png: 'image/png', jpg: 'image/jpeg', jpeg: 'image/jpeg', webp: ' export async function publishUpdate({ exportDir, root, origin, environment, runtimeVersion, keyFile, keyPassphrase, certificateFile, expoConfig }) { if (!['dev', 'prod'].includes(environment) || !/^[\w.-]{1,200}$/.test(runtimeVersion || '')) throw Error('Explicit environment/runtime required'); - origin = internal(origin, environment === 'dev'); + origin = internal(origin, environment === 'dev', environment === 'prod'); if (new URL(origin).pathname !== '/') throw Error('OTA origin must not have a path'); exportDir = await realpath(exportDir); root = path.resolve(root); const metadata = JSON.parse(await readFile(path.join(exportDir, 'metadata.json'), 'utf8')); diff --git a/mobile-app/scripts/verify-production-ota.mjs b/mobile-app/scripts/verify-production-ota.mjs index 91e87dd..52e406a 100644 --- a/mobile-app/scripts/verify-production-ota.mjs +++ b/mobile-app/scripts/verify-production-ota.mjs @@ -1,8 +1,8 @@ import assert from 'node:assert/strict'; import { readFile, writeFile } from 'node:fs/promises'; import { createHash, verify, X509Certificate } from 'node:crypto'; -const origin = 'http://192.168.28.10'; -const runtime = 'ac523f4137469f9f4b0faaca30982e68445686df'; +const origin = 'https://wms.svc.cmvr-iot.icu'; +const runtime = (await readFile(new URL('../android/app/build/generated/assets/createReleaseUpdatesResources/fingerprint', import.meta.url), 'utf8')).trim(); const headers = { 'expo-platform': 'android', 'expo-runtime-version': runtime, 'expo-protocol-version': '1', 'expo-expect-signature': 'sig, keyid="prod", alg="rsa-v1_5-sha256"', accept: 'application/expo+json, application/json, multipart/mixed' }; diff --git a/mobile-app/src/App.tsx b/mobile-app/src/App.tsx index 002ee14..922fd0e 100644 --- a/mobile-app/src/App.tsx +++ b/mobile-app/src/App.tsx @@ -13,7 +13,7 @@ import Constants from 'expo-constants'; import * as SecureStore from 'expo-secure-store'; import * as Crypto from 'expo-crypto'; import { StatusBar } from 'expo-status-bar'; -import { ApiClient, allows, internalUrl } from './core/network'; +import { ApiClient, allows, internalUrl, productionServer, PRODUCTION_PUBLIC_URL, PRODUCTION_INTERNAL_URL } from './core/network'; import { AppUpdateDialog, useAppUpdates, type AppUpdateControls } from './AppUpdates'; import { modules, display, recordDisplay, routeComponents, validDate, type Module, type Row, localDate } from './core/modules'; import { AppearanceContext, Button, Card, Choice, Field, Heading, Icon, Note, s, useTheme, type Appearance, type IconName } from './ui'; @@ -33,7 +33,7 @@ import {developmentServerKey,developmentServer,serverTokenKey,connectionClient,c const config=Constants.expoConfig?.extra || {}; const variant=String(config.environment || 'dev'); -const nativeBase=internalUrl(String(config.apiUrl || 'http://127.0.0.1:8080'),variant==='dev'); +const nativeBase=variant==='prod'?productionServer(String(config.apiUrl || PRODUCTION_PUBLIC_URL)):internalUrl(String(config.apiUrl || 'http://127.0.0.1:8080'),true); const base=Platform.OS==='web'?`${globalThis.location.origin}/native-api`:nativeBase; type User={user:Row; roles?:string[]; permissions:string[]; pages?:string[];pwdChrtype?:string}; const preferences={get:async(key:string)=>Platform.OS==='web'?localStorage.getItem(key):SecureStore.getItemAsync(key), @@ -44,9 +44,9 @@ export default function App(){ const [reading,setReading]=useState('compact'); useEffect(()=>{void preferences.get('cmvr.reading-size').then(value=>{if(['compact','standard','large'].includes(value||''))setReading(value as ReadingSize);}).catch(()=>{});},[]); const changeReading=useCallback((value:ReadingSize)=>{setReading(value);void preferences.put('cmvr.reading-size',value).catch(()=>{});},[]); - const [server,setServer]=useState(variant==='dev'?null:nativeBase); - useEffect(()=>{if(variant!=='dev')return;let alive=true;void preferences.get(developmentServerKey).then(value=>{if(alive)setServer(value?developmentServer(value):nativeBase);}).catch(()=>{if(alive)setServer(nativeBase);});return()=>{alive=false;};},[]); - const saveServer=useCallback(async(value:string)=>{await preferences.put(developmentServerKey,value);setServer(value);},[]); + const [server,setServer]=useState(null); + useEffect(()=>{let alive=true;const key=variant==='dev'?developmentServerKey:'cmvr.prod.connection';void preferences.get(key).then(value=>{if(!alive)return;try{setServer(value?(variant==='dev'?developmentServer(value):productionServer(value)):nativeBase);}catch{setServer(nativeBase);}}).catch(()=>{if(alive)setServer(nativeBase);});return()=>{alive=false;};},[]); + const saveServer=useCallback(async(value:string)=>{await preferences.put(variant==='dev'?developmentServerKey:'cmvr.prod.connection',value);setServer(value);},[]); useEffect(()=>{void (Platform.OS==='web'?Promise.resolve(localStorage.getItem('cmvr.appearance')):SecureStore.getItemAsync('cmvr.appearance')).then(value=>{if(['system','light','dark'].includes(value||''))setMode(value as Appearance);}).catch(()=>{});},[]); const change=useCallback((value:Appearance)=>{setMode(value);if(Platform.OS==='web')try{localStorage.setItem('cmvr.appearance',value);}catch{}else void SecureStore.setItemAsync('cmvr.appearance',value).catch(()=>{});},[]); return {server?:正在读取开发服务设置…}; @@ -61,7 +61,7 @@ function Root({server,saveServer,updates}:{server:string;saveServer:(value:strin const epoch=useRef(0),leave=useRef(null); const bindLeave=useCallback((guard:LeaveGuard|null)=>{leave.current=guard;},[]); const reset=useCallback(()=>{epoch.current++;messageSerial.current++;setUnreadMessages({count:0,exact:true});setUser(null);setTab('home');setStack([]);setAiVisited(false);leave.current=null;void storage.clear();},[storage]); - const api=useMemo(()=>variant==='dev'?connectionClient(server,reset,Platform.OS==='web'?globalThis.location.origin:undefined):new ApiClient(base,reset),[reset,server]); + const api=useMemo(()=>variant==='dev'?connectionClient(server,reset,Platform.OS==='web'?globalThis.location.origin:undefined):new ApiClient(Platform.OS==='web'?base:server,reset),[reset,server]); const packageUpdates=usePackageUpdates(api,scope,!!user); const refreshMessages=useCallback(()=>{ const current=epoch.current,id=++messageSerial.current;if(!user){setUnreadMessages({count:0,exact:true});return;} @@ -72,15 +72,15 @@ function Root({server,saveServer,updates}:{server:string;saveServer:(value:strin useEffect(()=>{refreshMessages();const timer=setInterval(()=>{if(AppState.currentState==='active')refreshMessages();},60000),listener=AppState.addEventListener('change',state=>{if(state==='active')refreshMessages();});return()=>{clearInterval(timer);listener.remove();messageSerial.current++;};},[refreshMessages]); useEffect(()=>()=>{epoch.current++;api.clear();},[api]); async function changeServer(value:string){ - const checked=await checkDevelopmentServer(value,Platform.OS==='web'?globalThis.location.origin:undefined); + const checked=variant==='dev'?await checkDevelopmentServer(value,Platform.OS==='web'?globalThis.location.origin:undefined):productionServer(value); if(checked===server)return; - if(user){const confirmed=await new Promise(resolve=>Alert.alert('更换开发服务','切换后需要重新登录,未提交的表单和对话不会迁移。是否继续?',[{text:'取消',style:'cancel',onPress:()=>resolve(false)},{text:'更换并退出登录',onPress:()=>resolve(true)}]));if(!confirmed)throw new Error('已取消切换,当前服务保持不变。');} + if(user){const confirmed=await new Promise(resolve=>Alert.alert(variant==='dev'?'更换开发服务':'切换连接方式','切换后需要重新登录,未提交的表单和对话不会迁移。是否继续?',[{text:'取消',style:'cancel',onPress:()=>resolve(false)},{text:'更换并退出登录',onPress:()=>resolve(true)}]));if(!confirmed)throw new Error('已取消切换,当前服务保持不变。');} await storage.clear(); if(Platform.OS!=='web')await SecureStore.deleteItemAsync(serverTokenKey(variant,checked)); await saveServer(checked); epoch.current++;api.clear(); } - const connection=variant==='dev'?:undefined; + const connection=variant==='dev'?:; const identity=useCallback(async()=>{const [info,routes]=await Promise.all([api.request('/getInfo'),api.request('/getRouters')]);return {...info,pages:routeComponents(routes.data||[])};},[api]); useEffect(()=>{let alive=true;const current=epoch.current; void storage.get().then(async token=>{if(!alive||!token)return;api.authenticate(token);try{const data=await identity();if(alive&&epoch.current===current)setUser(data);}catch{api.clear();await storage.clear();}}) @@ -106,7 +106,7 @@ function Root({server,saveServer,updates}:{server:string;saveServer:(value:strin {selected?.title||titles[page||tab]} {!!selected?.guide&&Alert.alert(selected.title+' · 操作指引',selected.guide)} style={{padding:10}}>} {page!=='messages'&&open('messages')} style={{padding:10,position:'relative'}}>{!!messageBadge(unreadMessages.count,unreadMessages.exact)&&{messageBadge(unreadMessages.count,unreadMessages.exact)}}} - {!page&&{variant==='prod'?'内网工作空间':'开发环境'}} + {!page&&{variant==='prod'?'正式环境':'开发环境'}} {!page&&tab==='home'&&} @@ -124,6 +124,11 @@ function Root({server,saveServer,updates}:{server:string;saveServer:(value:strin {!packageUpdates.visible&&} ; } +function ProductionConnection({address,onSave}:{address:string;onSave:(value:string)=>Promise}){ + const [busy,setBusy]=useState(false),[error,setError]=useState(''); + async function select(value:string){if(busy||value===address)return;setBusy(true);setError('');try{await onSave(value);}catch(e){setError((e as Error).message);}finally{setBusy(false);}} + return 连接方式切换后需重新登录,未提交内容不会迁移。