完善地图交互、动画与罗盘调试
This commit is contained in:
24
miniprogram/utils/animationLevel.ts
Normal file
24
miniprogram/utils/animationLevel.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
export type AnimationLevel = 'standard' | 'lite'
|
||||
|
||||
const LITE_BENCHMARK_THRESHOLD = 18
|
||||
const LITE_DEVICE_MEMORY_GB = 3
|
||||
|
||||
export function resolveAnimationLevel(systemInfo?: WechatMiniprogram.SystemInfo): AnimationLevel {
|
||||
const info = systemInfo || wx.getSystemInfoSync()
|
||||
const benchmarkLevel = Number((info as WechatMiniprogram.SystemInfo & { benchmarkLevel?: number }).benchmarkLevel)
|
||||
const deviceMemory = Number((info as WechatMiniprogram.SystemInfo & { deviceMemory?: number }).deviceMemory)
|
||||
|
||||
if (Number.isFinite(benchmarkLevel) && benchmarkLevel > 0 && benchmarkLevel <= LITE_BENCHMARK_THRESHOLD) {
|
||||
return 'lite'
|
||||
}
|
||||
|
||||
if (Number.isFinite(deviceMemory) && deviceMemory > 0 && deviceMemory <= LITE_DEVICE_MEMORY_GB) {
|
||||
return 'lite'
|
||||
}
|
||||
|
||||
return 'standard'
|
||||
}
|
||||
|
||||
export function formatAnimationLevelText(level: AnimationLevel): string {
|
||||
return level === 'lite' ? '精简' : '标准'
|
||||
}
|
||||
Reference in New Issue
Block a user