haiwei-ui 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "haiwei-ui",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "HaiWei前端组件库",
5
5
  "author": "Eric",
6
6
  "license": "ISC",
@@ -194,9 +194,27 @@ export default config => {
194
194
  if (t && t.accessToken) {
195
195
  config.headers.Authorization = 'Bearer ' + t.accessToken
196
196
  }
197
+
198
+ // 开发环境下打印请求日志
199
+ if (process.env.NODE_ENV === 'development') {
200
+ console.group(`🌐 API请求 ${config.method.toUpperCase()} ${config.url}`)
201
+ console.log('请求配置:', {
202
+ 方法: config.method,
203
+ URL: config.url,
204
+ 参数: config.params,
205
+ 数据: config.data,
206
+ 头信息: config.headers
207
+ })
208
+ console.groupEnd()
209
+ }
210
+
197
211
  return config
198
212
  },
199
213
  function(error) {
214
+ // 开发环境下打印请求错误日志
215
+ if (process.env.NODE_ENV === 'development') {
216
+ console.error('❌ 请求拦截器错误:', error)
217
+ }
200
218
  return Promise.reject(error)
201
219
  }
202
220
  )
@@ -205,6 +223,19 @@ export default config => {
205
223
  axios.interceptors.response.use(
206
224
  response => {
207
225
  const { config } = response
226
+
227
+ // 开发环境下打印响应成功日志
228
+ if (process.env.NODE_ENV === 'development') {
229
+ console.group(`✅ API响应 ${config.method.toUpperCase()} ${config.url}`)
230
+ console.log('响应信息:', {
231
+ 状态码: response.status,
232
+ 状态文本: response.statusText,
233
+ 数据: response.data,
234
+ 头信息: response.headers
235
+ })
236
+ console.groupEnd()
237
+ }
238
+
208
239
  // 文件下载/预览
209
240
  if (config.responseType && config.responseType === 'blob') {
210
241
  return handleDownload(response)
@@ -224,6 +255,18 @@ export default config => {
224
255
  }
225
256
  },
226
257
  error => {
258
+ // 开发环境下打印响应错误日志
259
+ if (process.env.NODE_ENV === 'development') {
260
+ console.group(`❌ API错误 ${error.config?.method?.toUpperCase()} ${error.config?.url}`)
261
+ console.log('错误信息:', {
262
+ 状态码: error.response?.status,
263
+ 错误消息: error.message,
264
+ 响应数据: error.response?.data,
265
+ 请求配置: error.config
266
+ })
267
+ console.groupEnd()
268
+ }
269
+
227
270
  let currentRoute = router.currentRoute
228
271
  let redirect = currentRoute.name !== 'login' ? currentRoute.fullPath : '/' // 跳转页面
229
272
  if (error && error.response) {