diff --git a/index.js b/index.js index 7410129..63101c3 100644 --- a/index.js +++ b/index.js @@ -24,9 +24,10 @@ module.exports = { // 快速输出详尽提示,可用来取代 console.log clog(...message) { + process.env.NODE_ENV === 'production' || console.log( '【', - getCurrentPages().length > 0 ? getCurrentPages().pop().route : 'pages/Welcome', // 在首页时,getApp() 或 getCurrentPages() 有可能获取不到。 + getCurrentPages().length > 0 ? getCurrentPages().pop().route : 'App', // 在首页时,getApp() 或 getCurrentPages() 有可能获取不到。 '【', ...message, '】】' @@ -117,9 +118,9 @@ module.exports = { } } - console.log('👇 👇 👇 👇 < Request > 👇 👇 👇 👇 ', { method, url, header, data }, '👆 👆 👆 👆 < /Request > 👆 👆 👆 👆') + console.log('👇 Request 👇 ', { method, url, header, data }, ' 👆 👆') let [error, response] = await uni.request({ method, url, header, data }) - console.log('⬇️ ⬇️ ⬇️ ⬇️ < Response > ⬇️ ⬇️ ⬇️ ⬇️ ', response, '⬆️ ⬆️ ⬆️ ⬆️ < /Response > ⬆️ ⬆️ ⬆️ ⬆️') + console.log('⬇️ Response ⬇️ ', response, ' ⬆️ ⬆️') return [error, response] }, @@ -130,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 }, ' < /BackendRequest > 👇') + console.log('👇 BackendRequest 👇 ', { apiWho, apiTodo, apiWhat }, ' 👆 👆') let result = {} if (backend === 'UNICLOUD') { let { /* success, header, requestedId, */ result: resultCloud = {} } = await uniCloud @@ -181,7 +182,7 @@ module.exports = { result = resultServer } } - console.log('👆 < BackendResult > ️', JSON.stringify(result), '< /BackendResult > 👆') // 不知为何,直接用 result 会输出一个奇怪的对象,要主动添加 JSON.stringify 才按照期望输出。 + console.log('⬇️ BackendResult ⬇️ ', JSON.stringify(result), ' ⬆️ ⬆️') // 不知为何,直接用 result 会输出一个奇怪的对象,要主动添加 JSON.stringify 才按照期望输出。 return result },