From a02748c82274bcc621166c987201252d46e0a049 Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Sun, 25 Apr 2021 13:18:46 +0800 Subject: [PATCH] u --- index.js | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/index.js b/index.js index b65e63f..48dacc0 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,10 @@ // #ifdef H5 // import device from 'current-device' // https://github.com/matthewhudson/current-device +// if (device.mobile()){ +// }else if (device.desktop()){ +// }else if (device.tablet()){ +// } // #endif import './ican-H5Api.js' // 对齐H5Api: https://ext.dcloud.net.cn/plugin?id=415 // 注意要取消默认自带的 showToast https://uniapp.dcloud.io/api/system/clipboard?id=%e6%b3%a8%e6%84%8f @@ -62,8 +66,8 @@ module.exports = { // 断网或云端返回异常 {errMsg, stack} = error if (/request:fail/.test(exp.errMsg)) { return { result: { _state: 'CLIENT_BACKEND_BROKEN' } } - }else { - return { result: { _state: 'CLIENT_BACKEND_EXCEPTION' }} + } else { + return { result: { _state: 'CLIENT_BACKEND_EXCEPTION' } } } }) result = resultCloud @@ -84,10 +88,10 @@ module.exports = { if (error.errMsg === 'request:fail') { // 后台断线 result = { _state: 'CLIENT_BACKEND_BROKEN' } - } else (error.errMsg==='request:fail timeout') { + } else if (error.errMsg === 'request:fail timeout') { // 后台异常而超时返回 result = { _state: 'CLIENT_BACKEND_TIMEOUT' } - }else{ + } else { result = { _state: 'CLIENT_BACKEND_EXCEPTION' } } } else { @@ -218,24 +222,13 @@ module.exports = { }, getSystemInfo() { - let systemInfo = uni.getSystemInfoSync() // 包含 platform (ios|android|other), model (iPhone, iPad, Nexus 6, ...), system (iOS 11.0, Android 4.0, Other 0, ...) 等等 + let systemInfo = uni.getSystemInfoSync() + // model=PC|iPhone|iPad|Nexus 6|..., + // platform=ios|android|mac|windows|linux|other, + // system=iOS 11.0|Android 4.0|Other 0|... 等等 // #ifdef H5 systemInfo.environment = 'h5' - - if (['ios', 'android'].indexOf(systemInfo.platform) >= 0) { - systemInfo.device = 'mobile' - } else { - systemInfo.device = 'desktop' - } - // if (device.mobile()){ - // systemInfo.device = 'mobile' - // }else if (device.desktop()){ - // systemInfo.device = 'desktop' - // }else if (device.tablet()){ - // systemInfo.device = 'tablet' - // } - let userAgent = window.navigator.userAgent.toLowerCase() systemInfo.browser = /msie/.test(userAgent) && !/opera/.test(userAgent) @@ -251,7 +244,6 @@ module.exports = { : /micromessenger/.test(userAgent) ? 'wechat' : 'unknown' - // #endif // #ifdef APP-PLUS || APP-PLUS-NVUE