import {localStore} from 'mutants-microfx'; import {clientInfoKey} from '../const/app'; export default class ClientInfo { osRelease:string; networkStatus:string; manufacturer:string; model:string; constructor(osRelease,networkStatus,manufacturer,model){ this.osRelease = osRelease; this.networkStatus = networkStatus; this.manufacturer = manufacturer; this.model = model; } static getClientInfo(deviceInfo){ let clientInfo = new ClientInfo(deviceInfo.osRelease,deviceInfo.networkStatus,deviceInfo.manufacturer,deviceInfo.model); return clientInfo; } //缓存数据 cache(){ localStore.set(clientInfoKey,this); } //从缓存中恢复ClientInfo对象 static restore(){ let clientInfo = localStore.get(clientInfoKey); if(clientInfo){ return clientInfo; } return undefined; } }