feat(app): 添加平台信息工具并将其集成到应用初始化中
- 创建 utils/platform.ts 以提取并规范化设备/操作系统信息 - 将 globalData 中的普通 `system` 字符串替换为结构化的 `platformInfo` 对象 - 推导硬件/软件详情、设备类别和平台标志 - 更新 TypeScript 类型定义以支持新的平台数据类型
This commit is contained in:
1 parent
58cd96aaa3
commit
f19f4b8d41
3 files changed
+150
-6
No files matched your search
Vendored
+38
-1
@@ -1,6 +1,43 @@
|
||||
/// <reference path="./types/index.d.ts" />
|
||||
/// <reference path="./npm.d.ts" />
|
||||
|
||||
/** 微信小程序当前运行的客户端平台,对应 wx.getDeviceInfo().platform */
|
||||
type ClientPlatformType = 'ios' | 'android' | 'ohos' | 'ohos_pc' | 'windows' | 'mac' | 'devtools' | 'unknown'
|
||||
|
||||
/** 根据客户端平台归一化后的操作系统类型 */
|
||||
type OperatingSystemType = 'ios' | 'android' | 'harmonyos' | 'windows' | 'macos' | 'devtools' | 'unknown'
|
||||
|
||||
/** 根据客户端平台归类的硬件设备类别 */
|
||||
type HardwareDeviceClassType = 'mobile' | 'desktop' | 'devtools' | 'unknown'
|
||||
|
||||
interface HardwarePlatformInfoType {
|
||||
deviceClass: HardwareDeviceClassType
|
||||
brand: string
|
||||
model: string
|
||||
abi: string
|
||||
deviceAbi: string
|
||||
cpuType: string
|
||||
memorySize: string
|
||||
}
|
||||
|
||||
interface SoftwarePlatformInfoType {
|
||||
clientPlatform: ClientPlatformType
|
||||
rawClientPlatform: string
|
||||
operatingSystem: OperatingSystemType
|
||||
system: string
|
||||
wechatVersion: string
|
||||
baseLibraryVersion: string
|
||||
hostAppId: string
|
||||
}
|
||||
|
||||
interface PlatformInfoType {
|
||||
hardware: HardwarePlatformInfoType
|
||||
software: SoftwarePlatformInfoType
|
||||
isMobile: boolean
|
||||
isDesktop: boolean
|
||||
isDevtools: boolean
|
||||
}
|
||||
|
||||
interface IAppOption {
|
||||
globalData: {
|
||||
navBarHeight: number,
|
||||
@@ -12,7 +49,7 @@ interface IAppOption {
|
||||
tabbarHeight: number,
|
||||
safeAreaBottom: number,
|
||||
safeAreaInsetBottom: number
|
||||
system: string,
|
||||
platformInfo: PlatformInfoType
|
||||
token: string
|
||||
userInfo?: WechatMiniprogram.UserInfo
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user