console.log({_at, ...})
This commit is contained in:
		
							parent
							
								
									07ad96602e
								
							
						
					
					
						commit
						db83067025
					
				
							
								
								
									
										41
									
								
								unitool.js
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								unitool.js
									
									
									
									
									
								
							@ -171,10 +171,10 @@ export default {
 | 
				
			|||||||
  }) {
 | 
					  }) {
 | 
				
			||||||
    const thisRoute = getCurrentPages()?.pop?.()?.route || 'VueApp' // 立刻保存 route,因为在调用后台后,可能已切换到了其他页面。
 | 
					    const thisRoute = getCurrentPages()?.pop?.()?.route || 'VueApp' // 立刻保存 route,因为在调用后台后,可能已切换到了其他页面。
 | 
				
			||||||
    const startTime = new Date().toJSON()
 | 
					    const startTime = new Date().toJSON()
 | 
				
			||||||
    let url = undefined
 | 
					    let apiurl = undefined
 | 
				
			||||||
    apiWhat._clientInfo = globalThis.wo?.envar?.clientInfo
 | 
					    apiWhat._clientInfo = globalThis.wo?.envar?.clientInfo
 | 
				
			||||||
    // #ifdef WEB
 | 
					    // #ifdef WEB
 | 
				
			||||||
    Object.assign(apiWhat._clientInfo, { url: globalThis.location?.href, lang: globalThis.wo?.ss?.i18n?.mylang })
 | 
					    Object.assign(apiWhat._clientInfo, { requrl: globalThis.location?.href, lang: globalThis.wo?.ss?.i18n?.mylang })
 | 
				
			||||||
    // #endif
 | 
					    // #endif
 | 
				
			||||||
    apiWhat._passtoken = uni.getStorageSync('_passtoken')
 | 
					    apiWhat._passtoken = uni.getStorageSync('_passtoken')
 | 
				
			||||||
    let result = {}
 | 
					    let result = {}
 | 
				
			||||||
@ -213,10 +213,10 @@ export default {
 | 
				
			|||||||
          apiWhat[key] = JSON.stringify(apiWhat[key])
 | 
					          apiWhat[key] = JSON.stringify(apiWhat[key])
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      url = this.make_server_url(`${apiVersion}/${apiWho}/${apiTodo}`)
 | 
					      apiurl = this.make_server_url(`${apiVersion}/${apiWho}/${apiTodo}`)
 | 
				
			||||||
      let [error, { statusCode, header, errMsg, data: resultServer = {} } = {}] = await uni.request({
 | 
					      let [error, { statusCode, header, errMsg, data: resultServer = {} } = {}] = await uni.request({
 | 
				
			||||||
        method: httpMethod,
 | 
					        method: httpMethod,
 | 
				
			||||||
        url,
 | 
					        url: apiurl,
 | 
				
			||||||
        data: apiWhat,
 | 
					        data: apiWhat,
 | 
				
			||||||
        timeout,
 | 
					        timeout,
 | 
				
			||||||
      })
 | 
					      })
 | 
				
			||||||
@ -240,22 +240,35 @@ export default {
 | 
				
			|||||||
    // 注意1,resultServer 和 resultCloud 推荐遵循同样的格式 { _state, error | data },这样方便前端做统一判断。
 | 
					    // 注意1,resultServer 和 resultCloud 推荐遵循同样的格式 { _state, error | data },这样方便前端做统一判断。
 | 
				
			||||||
    // 注意2,虽然预设了 resultServer 和 resultCloud = {},但如果后台返回了 null,那么 resultServer/resultCloud 也是 null。
 | 
					    // 注意2,虽然预设了 resultServer 和 resultCloud = {},但如果后台返回了 null,那么 resultServer/resultCloud 也是 null。
 | 
				
			||||||
    if (process.env.NODE_ENV !== 'production') {
 | 
					    if (process.env.NODE_ENV !== 'production') {
 | 
				
			||||||
      console.log(
 | 
					      console.log({
 | 
				
			||||||
        `%c ${startTime} (IN) ${thisRoute} :: ${apiTodo}`,
 | 
					        _at: startTime,
 | 
				
			||||||
        'background: #87cefa; border-radius: 0.5em;color: white; font-weight: bold; padding: 2px 0.5em;',
 | 
					        _type: 'REQ',
 | 
				
			||||||
        {
 | 
					        _path: `${thisRoute} => ${apiWho}/${apiTodo}`,
 | 
				
			||||||
 | 
					        apiurl,
 | 
				
			||||||
        baseType,
 | 
					        baseType,
 | 
				
			||||||
          apiWho,
 | 
					 | 
				
			||||||
          apiTodo,
 | 
					 | 
				
			||||||
        apiWhat,
 | 
					        apiWhat,
 | 
				
			||||||
        timeout,
 | 
					        timeout,
 | 
				
			||||||
          url,
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					        // `%c ${startTime} (IN) ${thisRoute} :: ${apiTodo}`,
 | 
				
			||||||
 | 
					        // 'background: #87cefa; border-radius: 0.5em;color: white; font-weight: bold; padding: 2px 0.5em;',
 | 
				
			||||||
 | 
					        // {
 | 
				
			||||||
 | 
					        //   baseType,
 | 
				
			||||||
 | 
					        //   apiWho,
 | 
				
			||||||
 | 
					        //   apiTodo,
 | 
				
			||||||
 | 
					        //   apiWhat,
 | 
				
			||||||
 | 
					        //   timeout,
 | 
				
			||||||
 | 
					        //   apiurl,
 | 
				
			||||||
 | 
					        // }
 | 
				
			||||||
      )
 | 
					      )
 | 
				
			||||||
      console.log(
 | 
					      console.log({
 | 
				
			||||||
        `%c ${new Date().toJSON()} (OUT) ${thisRoute} :: ${apiTodo}`,
 | 
					        _at: new Date().toJSON(),
 | 
				
			||||||
        'background: #4169e1; border-radius: 0.5em;color: white; font-weight: bold; padding: 2px 0.5em;',
 | 
					        _type: 'RES',
 | 
				
			||||||
 | 
					        _path: `${thisRoute} => ${apiWho}/${apiTodo}`,
 | 
				
			||||||
        result
 | 
					        result
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					        // `%c ${new Date().toJSON()} (OUT) ${thisRoute} :: ${apiTodo}`,
 | 
				
			||||||
 | 
					        // 'background: #4169e1; border-radius: 0.5em;color: white; font-weight: bold; padding: 2px 0.5em;',
 | 
				
			||||||
 | 
					        // result
 | 
				
			||||||
      )
 | 
					      )
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return result
 | 
					    return result
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user