haiwei-ui 1.0.9 → 1.0.93

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.9",
3
+ "version": "1.0.93",
4
4
  "description": "HaiWei前端组件库",
5
5
  "author": "Eric",
6
6
  "license": "ISC",
@@ -190,7 +190,9 @@
190
190
  computed: {
191
191
  ...mapState('app/user', { token: 'token' }),
192
192
  uploadUrl() {
193
- return `${this.$api.baseURL}/api/admin/excel/parseexcel`
193
+ // 从axios默认配置中获取baseURL,如果不存在则使用全局变量或默认值
194
+ const baseURL = this.$http?.axios?.defaults?.baseURL || window.__HAIWEI_API_BASE_URL__ || '/api'
195
+ return `${baseURL}/admin/excel/parseexcel`
194
196
  },
195
197
  headers() {
196
198
  return {
@@ -338,17 +340,25 @@
338
340
  formData.append('maxPreviewRows', this.model.maxPreviewRows)
339
341
  formData.append('skipEmptyRows', this.model.skipEmptyRows)
340
342
 
341
- this.$api.post('/api/admin/excel/parseexcel', formData, {
342
- headers: { 'Content-Type': 'multipart/form-data' }
343
- })
343
+ // 使用axios直接发送请求,避免$api可能为undefined的问题
344
+ const config = {
345
+ headers: {
346
+ 'Content-Type': 'multipart/form-data',
347
+ 'Authorization': `Bearer ${this.token}`
348
+ }
349
+ }
350
+
351
+ // 使用与uploadUrl相同的逻辑获取API基础URL
352
+ const baseURL = this.$http?.axios?.defaults?.baseURL || window.__HAIWEI_API_BASE_URL__ || '/api'
353
+ this.$http.post(`${baseURL}/admin/excel/parseexcel`, formData, config)
344
354
  .then(response => {
345
- if (response.successful) {
346
- this.fileInfo = response.data.basicInfo
347
- this.parseResult = response.data
355
+ if (response.data.successful) {
356
+ this.fileInfo = response.data.data.basicInfo
357
+ this.parseResult = response.data.data
348
358
  this.initColumnMapping()
349
359
  this._success('文件解析成功')
350
360
  } else {
351
- this._error(response.msg || '文件解析失败')
361
+ this._error(response.data.msg || '文件解析失败')
352
362
  }
353
363
  })
354
364
  .catch(error => {
package/src/api/config.js CHANGED
@@ -70,6 +70,11 @@ const getUI = () => {
70
70
  },
71
71
  //自定义样式
72
72
  customCss: null
73
+ },
74
+ /** API配置 */
75
+ api: {
76
+ /** API基础URL */
77
+ baseUrl: '/api'
73
78
  }
74
79
  })
75
80
  })