style:去除手机/扫码器类型判断
parent
f97828400b
commit
08fe076728
@ -1,46 +0,0 @@
|
|||||||
const TerminalTypeKey = 'App-Terminal-Type'
|
|
||||||
|
|
||||||
export const TERMINAL_TYPE_MOBILE = 1
|
|
||||||
export const TERMINAL_TYPE_SCANNER = 2
|
|
||||||
|
|
||||||
function normalizeTerminalType(value: unknown) {
|
|
||||||
return Number(value) === TERMINAL_TYPE_SCANNER ? TERMINAL_TYPE_SCANNER : TERMINAL_TYPE_MOBILE
|
|
||||||
}
|
|
||||||
|
|
||||||
export function detectTerminalType() {
|
|
||||||
const systemInfo = uni.getSystemInfoSync()
|
|
||||||
const width = Number(systemInfo.windowWidth || systemInfo.screenWidth || 0)
|
|
||||||
const height = Number(systemInfo.windowHeight || systemInfo.screenHeight || 0)
|
|
||||||
|
|
||||||
if (width === 480 && height === 800) {
|
|
||||||
return TERMINAL_TYPE_SCANNER
|
|
||||||
}
|
|
||||||
|
|
||||||
return TERMINAL_TYPE_MOBILE
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getTerminalType() {
|
|
||||||
const storedValue = uni.getStorageSync(TerminalTypeKey)
|
|
||||||
if (storedValue === '' || storedValue === null || typeof storedValue === 'undefined') {
|
|
||||||
return TERMINAL_TYPE_MOBILE
|
|
||||||
}
|
|
||||||
return normalizeTerminalType(storedValue)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setTerminalType(value: unknown) {
|
|
||||||
const terminalType = normalizeTerminalType(value)
|
|
||||||
uni.setStorageSync(TerminalTypeKey, terminalType)
|
|
||||||
return terminalType
|
|
||||||
}
|
|
||||||
|
|
||||||
export function removeTerminalType() {
|
|
||||||
uni.removeStorageSync(TerminalTypeKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function initializeTerminalType() {
|
|
||||||
const storedValue = uni.getStorageSync(TerminalTypeKey)
|
|
||||||
if (storedValue === '' || storedValue === null || typeof storedValue === 'undefined') {
|
|
||||||
return setTerminalType(detectTerminalType())
|
|
||||||
}
|
|
||||||
return normalizeTerminalType(storedValue)
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue