builtinTscCapabilityLog.ts
1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* 内置走 TSC/TSPL 时软件无法自动检测机芯是否支持;用于控制台排查与用户确认留痕。
* 搜索关键字:`[builtin-tsc-capability]`
*/
const STORAGE_ACK = 'builtinTscUserAcknowledgedV1'
export function hasUserAcknowledgedBuiltinTsc (): boolean {
try {
return uni.getStorageSync(STORAGE_ACK) === '1'
} catch {
return false
}
}
export function setUserAcknowledgedBuiltinTsc (ack: boolean): void {
try {
if (ack) uni.setStorageSync(STORAGE_ACK, '1')
else uni.removeStorageSync(STORAGE_ACK)
} catch (_) {}
}
export function logBuiltinTscCapability (
reason: string,
detail: Record<string, unknown> = {},
): void {
const payload = {
tag: 'builtin-tsc-capability',
reason,
ts: new Date().toISOString(),
userAckStored: hasUserAcknowledgedBuiltinTsc(),
...detail,
}
try {
console.warn('[builtin-tsc-capability]', JSON.stringify(payload))
} catch {
console.warn('[builtin-tsc-capability]', reason, payload)
}
}