diff --git a/mobile-app/app.config.js b/mobile-app/app.config.js index 76b1195..a3e12e9 100644 --- a/mobile-app/app.config.js +++ b/mobile-app/app.config.js @@ -3,7 +3,7 @@ module.exports = () => { const env = environment(); const cleartextHosts = [...new Set([env.apiUrl, env.updateOrigin].filter(url => url.startsWith('http:')).map(url => new URL(url).hostname))]; return { - name: env.variant === 'prod' ? '车研物资' : '车研物资·开发', + 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'], diff --git a/mobile-app/assets/brand/README.md b/mobile-app/assets/brand/README.md new file mode 100644 index 0000000..5836b05 --- /dev/null +++ b/mobile-app/assets/brand/README.md @@ -0,0 +1,31 @@ +# 素材与生成提示词 + +使用内置 imagegen 生成原创素材。安装包图标的安全区域适配是对生成结果的尺寸和透明通道处理;未使用或伪造官方商标。 + +## 正式版图标 + +Use case: logo-brand. Asset type: production Android application launcher icon, single square image, 1024x1024, full bleed opaque background without rounded outside corners. Create a premium original app emblem for 招商车研 (automotive testing research), 研发中心, 设备仪器科, an internal equipment/materials management app. A bold simple geometric monogram-like emblem combining a precision measurement frame / caliper with the silhouette of an automotive test-track curve and a subtle central data pulse. One coherent strong symbol, not a collage of small objects. Deep midnight navy background, rich cobalt blue and emerald-teal luminous metallic linework, exceptionally restrained highlights, precise symmetry and excellent readability at 48 pixels. Center the entire emblem inside the central 58% square safe zone so Android adaptive masks do not crop it; outside is generous clean dark blue background. Modern Chinese state-owned research institute visual identity, trustworthy engineering, minimal premium three-dimensional finish, crisp edges. Do not copy or invent the official China Merchants logo; this is an original departmental application mark. No Chinese or English text, no letters, no labels, no watermark, no photo, no phone mockup, no border. + +## 开发版图标 + +Use case: logo-brand. Asset type: fixed DEVELOPMENT Android launcher icon, square 1024x1024 full bleed opaque. EDIT the supplied production icon as the reference and edit target. Preserve exactly the recognizable geometric precision instrument frame, central measurement probe, data pulse and curving automotive test-track emblem and the premium engineering style. Change palette to strong amber-orange and warm pale gold on a deep ink-blue background so development is instantly distinguishable from blue/teal production. Simplify excessive tiny shine, retain clean edges. Add one small but highly legible rectangular badge integrated in the LOWER RIGHT OF THE CENTRAL SAFE ZONE bearing exact uppercase text "DEV", dark navy lettering on amber-gold. Keep whole emblem and DEV badge within center 60% of canvas with generous plain dark margins, so round/squircle Android masks cannot crop it. No extra text, no Chinese characters, no official company logo, no watermark or phone mockup. This is an original internal departmental app icon for 招商车研 研发中心 设备仪器科. + +## 登录背景 + +Use case: stylized-concept. Asset type: portrait mobile app login background 1024x1536. EDIT the reference automotive test laboratory image to reflect the full business of 招商车研 研发中心 设备仪器科, while preserving its refined photoreal cinematic industrial style, midnight navy/cobalt/teal palette, and clean empty lower portion. Replace the car-only scene with ONE coherent advanced multi-disciplinary testing research laboratory in the UPPER 38%: a clearly recognizable elegant full-body humanoid research robot at center-left, a compact mobile manipulation robot with wheeled AGV base and a single industrial arm in foreground left, an intelligent vehicle cockpit testing rig on right with steering wheel and wide dashboard display, and a restrained automotive durability / dynamometer test vehicle further back at far right. Precision measurement instruments and subtle thin sensor/data trajectories connect these research areas. Physically plausible equipment, no humanoid faces like humans, no weapons, no people. Premium trustworthy corporate research atmosphere; NOT a collage, no separate panels, no poster, no text, logos or watermarks. Keep bottom 62% mostly smooth midnight navy negative space for a login form. Reduce visual clutter and loud neon. A refined cinematic photo/3D blend, sharp engineering details, upper scene with enough breathing room for a company masthead overlaid at very top. No UI controls drawn. + +项目使用文件:app-icon-prod.png、app-icon-dev.png、app-icon-prod-adaptive.png、app-icon-dev-adaptive.png、login-tech-background.jpg。 + +## 蓝色复用版(当前使用) + +使用内置 imagegen,以用户提供的图片为参考进行重新绘制。正式版提示词:保持原图几何形状和比例,将金色改为统一蓝色 #176AB2、白色背景,不添加其他文字或装饰;图形置于 Android 图标安全区域。 + +开发版提示词:保持同一蓝色图形,在图案正下方居中添加蓝色大写 DEV,不增加徽章或其他装饰;保留足够白边以适配圆形桌面图标。 + +当前文件:app-icon-blue-prod.png、app-icon-blue-dev.png 及对应的 -adaptive.png。原图像为低分辨率截图,蓝色图案由图像工具重绘,并非逐像素的颜色替换。 + +### 本次使用的原始提示词 + +正式版:Edit the attached icon, using it as the exact design reference. Preserve the SAME geometry, positions, proportions, circular gap, angles and shape of the interior angular emblem. It must be directly recognizable as the supplied original, not a redesign. Change all gold/beige strokes to a single flat medium blue (#176AB2), preserve the white background, crisp clean vector-like edges. Upscale/re-render accurately in a high-resolution square suitable for an Android launcher icon, center original mark within central 58% of canvas with white space around it so Android adaptive icons don't clip it. No extra decoration, no gradients, shadows, gloss, 3D, words or typography. Preserve original visual geometry. + +开发版:Edit the attached icon as an exact visual reference. Preserve the SAME geometry, positions, proportions, circular gap, angles, and interior angular emblem; do not redesign the mark. Recolor gold/beige strokes to a single flat medium blue (#176AB2) on pure white. Directly below the circular emblem, centered, add a small clean, readable blue uppercase label "DEV" in bold sans-serif. No badge box, no other text. Original symbol plus DEV label fully contained in the central 58% square safe area of the overall white square, ample white margin for Android adaptive masking. Crisp vector-like, no decoration, no gradients, shadows, gloss or 3D. diff --git a/mobile-app/assets/brand/app-icon-blue-dev-adaptive.png b/mobile-app/assets/brand/app-icon-blue-dev-adaptive.png new file mode 100644 index 0000000..024eb6d Binary files /dev/null and b/mobile-app/assets/brand/app-icon-blue-dev-adaptive.png differ diff --git a/mobile-app/assets/brand/app-icon-blue-dev.png b/mobile-app/assets/brand/app-icon-blue-dev.png new file mode 100644 index 0000000..6e7ed2e Binary files /dev/null and b/mobile-app/assets/brand/app-icon-blue-dev.png differ diff --git a/mobile-app/assets/brand/app-icon-blue-prod-adaptive.png b/mobile-app/assets/brand/app-icon-blue-prod-adaptive.png new file mode 100644 index 0000000..3d3ad43 Binary files /dev/null and b/mobile-app/assets/brand/app-icon-blue-prod-adaptive.png differ diff --git a/mobile-app/assets/brand/app-icon-blue-prod.png b/mobile-app/assets/brand/app-icon-blue-prod.png new file mode 100644 index 0000000..5646f47 Binary files /dev/null and b/mobile-app/assets/brand/app-icon-blue-prod.png differ diff --git a/mobile-app/assets/brand/app-icon-dev-adaptive.png b/mobile-app/assets/brand/app-icon-dev-adaptive.png new file mode 100644 index 0000000..3aa5686 Binary files /dev/null and b/mobile-app/assets/brand/app-icon-dev-adaptive.png differ diff --git a/mobile-app/assets/brand/app-icon-dev.png b/mobile-app/assets/brand/app-icon-dev.png new file mode 100644 index 0000000..7e2cfd2 Binary files /dev/null and b/mobile-app/assets/brand/app-icon-dev.png differ diff --git a/mobile-app/assets/brand/app-icon-prod-adaptive.png b/mobile-app/assets/brand/app-icon-prod-adaptive.png new file mode 100644 index 0000000..d3ec50e Binary files /dev/null and b/mobile-app/assets/brand/app-icon-prod-adaptive.png differ diff --git a/mobile-app/assets/brand/app-icon-prod.png b/mobile-app/assets/brand/app-icon-prod.png new file mode 100644 index 0000000..3a9ec25 Binary files /dev/null and b/mobile-app/assets/brand/app-icon-prod.png differ diff --git a/mobile-app/assets/brand/login-tech-background.jpg b/mobile-app/assets/brand/login-tech-background.jpg new file mode 100644 index 0000000..d6362c4 Binary files /dev/null and b/mobile-app/assets/brand/login-tech-background.jpg differ diff --git a/mobile-app/plugins/with-apk-installer.cjs b/mobile-app/plugins/with-apk-installer.cjs new file mode 100644 index 0000000..ecbb7d0 --- /dev/null +++ b/mobile-app/plugins/with-apk-installer.cjs @@ -0,0 +1,62 @@ +const {withAndroidManifest,withMainApplication,withDangerousMod}=require('expo/config-plugins'); +const fs=require('node:fs/promises'),path=require('node:path'); +module.exports=config=>{ + const pkg=config.android?.package;if(!/^cn\.cmvr\.wms(\.dev)?$/.test(pkg||''))throw Error('Unexpected application package'); + config=withAndroidManifest(config,cfg=>{ + const m=cfg.modResults.manifest;m.queries=m.queries||[{}];const query=m.queries[0];query.intent=query.intent||[]; + if(!query.intent.some(i=>i.data?.some(d=>d.$?.['android:mimeType']==='application/vnd.android.package-archive')))query.intent.push({action:[{$:{'android:name':'android.intent.action.VIEW'}}],data:[{$:{'android:mimeType':'application/vnd.android.package-archive'}}]}); + return cfg; + }); + config=withMainApplication(config,cfg=>{ + const marker='add(CmvrApkVerificationPackage())',source=cfg.modResults.contents; + if(!source.includes(marker)){const needle='PackageList(this).packages.apply {';if(!source.includes(needle))throw Error('Unexpected MainApplication template');cfg.modResults.contents=source.replace(needle,needle+'\n '+marker);} + return cfg; + }); + return withDangerousMod(config,['android',async cfg=>{ + const dir=path.join(cfg.modRequest.platformProjectRoot,'app/src/main/java',...pkg.split('.'));await fs.mkdir(dir,{recursive:true}); + await fs.writeFile(path.join(dir,'CmvrApkVerificationPackage.kt'),`package ${pkg} +import android.content.pm.PackageInfo +import android.content.pm.PackageManager +import android.net.Uri +import android.os.Build +import com.facebook.react.ReactPackage +import com.facebook.react.bridge.* +import com.facebook.react.uimanager.ViewManager +import java.io.File +import java.security.MessageDigest + +class CmvrApkVerificationPackage : ReactPackage { + override fun createNativeModules(context: ReactApplicationContext): List = listOf(CmvrApkVerification(context)) + override fun createViewManagers(context: ReactApplicationContext): List> = emptyList() +} +class CmvrApkVerification(private val context: ReactApplicationContext) : ReactContextBaseJavaModule(context) { + override fun getName() = "CmvrApkVerification" + @Suppress("DEPRECATION") + private fun signatures(info: PackageInfo): Set { + val signatures = if (Build.VERSION.SDK_INT >= 28) info.signingInfo?.apkContentsSigners else info.signatures + return signatures?.map { signature -> MessageDigest.getInstance("SHA-256").digest(signature.toByteArray()).joinToString("") { "%02x".format(it) } }?.toSet() ?: emptySet() + } + @Suppress("DEPRECATION") + @ReactMethod fun verify(uri: String, expectedVersion: Double, promise: Promise) { + try { + val parsed = Uri.parse(uri) + require(parsed.scheme == "file") + val file = File(requireNotNull(parsed.path)).canonicalFile + val base = File(context.cacheDir, "app-updates").canonicalFile + require(file.parentFile == base && file.isFile && expectedVersion >= 1 && expectedVersion <= Int.MAX_VALUE && expectedVersion % 1.0 == 0.0) + val flags = if (Build.VERSION.SDK_INT >= 28) PackageManager.GET_SIGNING_CERTIFICATES else PackageManager.GET_SIGNATURES + val manager = context.packageManager + val archive = requireNotNull(manager.getPackageArchiveInfo(file.path, flags)) + val current = manager.getPackageInfo(context.packageName, flags) + val version = if (Build.VERSION.SDK_INT >= 28) archive.longVersionCode else archive.versionCode.toLong() + val archiveSignatures = signatures(archive) + val installedSignatures = signatures(current) + require(archive.packageName == context.packageName && version == expectedVersion.toLong() && archiveSignatures.isNotEmpty() && archiveSignatures == installedSignatures) + promise.resolve(true) + } catch (error: Exception) { promise.reject("INVALID_APK", "安装包与当前应用的包名、签名或版本不一致,请联系管理员。") } + } +} +`); + return cfg; + }]); +}; diff --git a/mobile-app/src/App.tsx b/mobile-app/src/App.tsx index 3db499f..002ee14 100644 --- a/mobile-app/src/App.tsx +++ b/mobile-app/src/App.tsx @@ -1,3 +1,4 @@ +import {canViewPurchaseQuotes} from './core/purchase-quote-permission'; import {Text,ReadingContext,type ReadingSize} from './typography'; import {usePackageUpdates,PackageUpdateDialog,PackageUpdateStatus} from './PackageUpdates'; import {LoginView} from './screens/LoginView'; @@ -34,7 +35,7 @@ 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 base=Platform.OS==='web'?`${globalThis.location.origin}/native-api`:nativeBase; -type User={user:Row; permissions:string[]; pages?:string[];pwdChrtype?:string}; +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), put:async(key:string,value:string)=>{if(Platform.OS==='web')localStorage.setItem(key,value);else await SecureStore.setItemAsync(key,value);}}; export default function App(){ @@ -113,7 +114,7 @@ function Root({server,saveServer,updates}:{server:string;saveServer:(value:strin {!page&&tab==='me'&&} {page==='messages'&&} {aiVisited&&ai&&} - {selected?.key==='files'?:!!selected&&} + {selected?.key==='files'?:!!selected&&} {(page==='profile'||page==='password')&&setUser(old=>old?{...old,user:{...old.user,...profile}}:null)}/>} {(page==='feedback'||page==='feedback-list')&&} {(page==='settings'||page==='about')&&} logout={logout} about={page==='about'}/>} diff --git a/mobile-app/src/AppUpdateDialog.tsx b/mobile-app/src/AppUpdateDialog.tsx new file mode 100644 index 0000000..e3176dc --- /dev/null +++ b/mobile-app/src/AppUpdateDialog.tsx @@ -0,0 +1,17 @@ +import {Text} from './typography'; +import React from 'react'; +import {Modal,ScrollView,View} from 'react-native'; +import {Button,Icon,Note,useTheme} from './ui'; +import type {UpdateView} from './core/updates'; + +export function AppUpdateDialog({view,later,restart}:{view:UpdateView;later:()=>void;restart:()=>void}){ + const t=useTheme();if(!view.visible)return null; + return + + 发现新版本更新已下载完成,重启 App 后即可使用。 + 请先保存正在填写的内容,并等待当前操作完成。重启后,未提交的内容不会保留。 + {!!view.error&&{view.error}} + +