12 lines
686 B
Plaintext
12 lines
686 B
Plaintext
import { getSession } from './api.uts'
|
|||
|
|
|
||
|
|
// 旧的设备级缓存不自动归给新登录用户;按稳定userId隔离,匿名使用独立空间。
|
||
|
|
export function userStorageKey(key: string): string {
|
||
|
|
const session = getSession()
|
||
|
|
const owner = session == null ? 'guest' : 'user:' + (session['userId'] as string)
|
||
|
|
return 'airz:v1:' + owner + ':' + key
|
||
|
|
}
|
||
|
|
export function getUserStorage(key: string): any | null { return uni.getStorageSync(userStorageKey(key)) }
|
||
|
|
export function setUserStorage(key: string, value: any): void { uni.setStorageSync(userStorageKey(key), value) }
|
||
|
|
export function removeUserStorage(key: string): void { uni.removeStorageSync(userStorageKey(key)) }
|