This commit is contained in:
陆柯 2021-10-03 08:09:46 +08:00
parent db048bc98c
commit f2ea4ac0a7

View File

@ -24,13 +24,10 @@ module.exports = {
// 快速输出详尽提示,可用来取代 console.log
clog(...message) {
process.env.NODE_ENV === 'production' ||
console.log(
process.env.NODE_ENV === 'production' || console.log(
'【',
getCurrentPages().length > 0 ? getCurrentPages().pop().route : 'App', // 在首页时getApp() 或 getCurrentPages() 有可能获取不到。
'【',
...message,
'】】'
'【', ...message, '】】'
)
},
@ -118,9 +115,12 @@ module.exports = {
}
}
console.log('👇 Request 👇 ', { method, url, header, data }, ' 👆 👆')
process.env.NODE_ENV === 'production' || console.log('👇 Request 👇 ', { method, url, header, data }, ' 👆 👆')
let [error, response] = await uni.request({ method, url, header, data })
console.log('⬇️ Response ⬇️ ', response, ' ⬆️ ⬆️')
process.env.NODE_ENV === 'production' || console.log('⬇️ Response ⬇️ ', response, ' ⬆️ ⬆️')
return [error, response]
},
@ -131,7 +131,7 @@ module.exports = {
* - CLINET_BACKEND_EXCEPTION: 前端发现后台异常
**/
async callBackend({ backend = this.BACKEND, httpMethod = 'POST', apiVersion = 'api', apiWho, apiTodo, apiWhat = {} }) {
console.log('👇 BackendRequest 👇 ', { apiWho, apiTodo, apiWhat }, ' 👆 👆')
process.env.NODE_ENV === 'production' || console.log('👇 BackendRequest 👇 ', { backend, apiWho, apiTodo, apiWhat }, ' 👆 👆')
let result = {}
if (backend === 'UNICLOUD') {
let { /* success, header, requestedId, */ result: resultCloud = {} } = await uniCloud
@ -182,7 +182,7 @@ module.exports = {
result = resultServer
}
}
console.log('⬇️ BackendResult ⬇️ ', JSON.stringify(result), ' ⬆️ ⬆️') // 不知为何,直接用 result 会输出一个奇怪的对象,要主动添加 JSON.stringify 才按照期望输出。
process.env.NODE_ENV === 'production' || console.log('⬇️ BackendResult ⬇️ ', JSON.stringify(result), ' ⬆️ ⬆️') // 不知为何,直接用 result 会输出一个奇怪的对象,要主动添加 JSON.stringify 才按照期望输出。
return result
},