haiwei-ui 1.0.93 → 1.0.95

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.93",
3
+ "version": "1.0.95",
4
4
  "description": "HaiWei前端组件库",
5
5
  "author": "Eric",
6
6
  "license": "ISC",
@@ -149,6 +149,7 @@
149
149
  <script>
150
150
  import dialog from '../../../../mixins/components/dialog'
151
151
  import { mapState } from 'vuex'
152
+ import token from '../../../../utils/token'
152
153
  export default {
153
154
  mixins: [dialog],
154
155
  data() {
@@ -191,12 +192,21 @@
191
192
  ...mapState('app/user', { token: 'token' }),
192
193
  uploadUrl() {
193
194
  // 从axios默认配置中获取baseURL,如果不存在则使用全局变量或默认值
194
- const baseURL = this.$http?.axios?.defaults?.baseURL || window.__HAIWEI_API_BASE_URL__ || '/api'
195
- return `${baseURL}/admin/excel/parseexcel`
195
+ let baseURL = this.$http?.axios?.defaults?.baseURL || window.__HAIWEI_API_BASE_URL__ || '/api'
196
+ // 确保baseURL以斜杠结尾,但不要有双斜杠
197
+ if (!baseURL.endsWith('/')) {
198
+ baseURL += '/'
199
+ }
200
+ // 移除路径开头的斜杠,避免双斜杠
201
+ const path = 'admin/excel/parseexcel'.replace(/^\//, '')
202
+ return baseURL + path
196
203
  },
197
204
  headers() {
205
+ // 从token模块获取token
206
+ const t = token.get()
207
+ const accessToken = t && t.accessToken ? t.accessToken : ''
198
208
  return {
199
- 'Authorization': `Bearer ${this.token}`
209
+ 'Authorization': `Bearer ${accessToken}`
200
210
  }
201
211
  },
202
212
  uploadData() {
@@ -341,16 +351,25 @@
341
351
  formData.append('skipEmptyRows', this.model.skipEmptyRows)
342
352
 
343
353
  // 使用axios直接发送请求,避免$api可能为undefined的问题
354
+ // 从token模块获取token
355
+ const t = token.get()
356
+ const accessToken = t && t.accessToken ? t.accessToken : ''
344
357
  const config = {
345
358
  headers: {
346
359
  'Content-Type': 'multipart/form-data',
347
- 'Authorization': `Bearer ${this.token}`
360
+ 'Authorization': `Bearer ${accessToken}`
348
361
  }
349
362
  }
350
363
 
351
364
  // 使用与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)
365
+ let baseURL = this.$http?.axios?.defaults?.baseURL || window.__HAIWEI_API_BASE_URL__ || '/api'
366
+ // 确保baseURL以斜杠结尾,但不要有双斜杠
367
+ if (!baseURL.endsWith('/')) {
368
+ baseURL += '/'
369
+ }
370
+ // 移除路径开头的斜杠,避免双斜杠
371
+ const path = 'admin/excel/parseexcel'.replace(/^\//, '')
372
+ this.$http.post(baseURL + path, formData, config)
354
373
  .then(response => {
355
374
  if (response.data.successful) {
356
375
  this.fileInfo = response.data.data.basicInfo