Files
熊熊熊子路 f19f4b8d41 feat(app): 添加平台信息工具并将其集成到应用初始化中
- 创建 utils/platform.ts 以提取并规范化设备/操作系统信息
- 将 globalData 中的普通 `system` 字符串替换为结构化的 `platformInfo` 对象
- 推导硬件/软件详情、设备类别和平台标志
- 更新 TypeScript 类型定义以支持新的平台数据类型
2026-07-31 11:31:31 +08:00

58 lines
1.6 KiB
TypeScript

/// <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,
navBarContentHeight: number,
statusBarHeight: number,
menuRight: number,
menuTop: number,
menuHeight: number,
tabbarHeight: number,
safeAreaBottom: number,
safeAreaInsetBottom: number
platformInfo: PlatformInfoType
token: string
userInfo?: WechatMiniprogram.UserInfo
}
userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback
}