Commit 8edce3874ac4c5da5fac60f8ed4e271f02e2d974

Authored by xingyu
1 parent 02315804

fix: axios bugs

yudao-ui-admin-vue3/src/config/axios/index.ts
@@ -55,17 +55,26 @@ service.interceptors.request.use( @@ -55,17 +55,26 @@ service.interceptors.request.use(
55 config.data = qs.stringify(data) 55 config.data = qs.stringify(data)
56 } 56 }
57 // get参数编码 57 // get参数编码
58 - if (config.method?.toUpperCase() === 'GET' && config.params) {  
59 - let url = config.url as string 58 + if (config.method?.toUpperCase() === 'GET' && params) {
  59 + let url = config.url + '?'
  60 + for (const propName of Object.keys(params)) {
  61 + const value = params[propName]
  62 + if (value !== void 0 && value !== null && typeof value !== 'undefined') {
  63 + if (typeof value === 'object') {
  64 + for (const val of Object.keys(value)) {
  65 + const params = propName + '[' + val + ']'
  66 + const subPart = encodeURIComponent(params) + '='
  67 + url += subPart + encodeURIComponent(value[val]) + '&'
  68 + }
  69 + } else {
  70 + url += `${propName}=${encodeURIComponent(value)}&`
  71 + }
  72 + }
  73 + }
60 // 给 get 请求加上时间戳参数,避免从缓存中拿数据 74 // 给 get 请求加上时间戳参数,避免从缓存中拿数据
61 // const now = new Date().getTime() 75 // const now = new Date().getTime()
62 // params = params.substring(0, url.length - 1) + `?_t=${now}` 76 // params = params.substring(0, url.length - 1) + `?_t=${now}`
63 - url += '?'  
64 - for (const key of Object.keys(params)) {  
65 - if (params[key] !== void 0 && params[key] !== null) {  
66 - url += `${key}=${encodeURIComponent(params[key])}&`  
67 - }  
68 - } 77 + url = url.slice(0, -1)
69 config.params = {} 78 config.params = {}
70 config.url = url 79 config.url = url
71 } 80 }
yudao-ui-admin-vue3/src/views/system/user/index.vue
@@ -269,6 +269,7 @@ const handleFileSuccess = (response: any): void => { @@ -269,6 +269,7 @@ const handleFileSuccess = (response: any): void => {
269 text += '< ' + username + ': ' + data.failureUsernames[username] + ' >' 269 text += '< ' + username + ': ' + data.failureUsernames[username] + ' >'
270 } 270 }
271 message.alert(text) 271 message.alert(text)
  272 + getList()
272 } 273 }
273 // 文件数超出提示 274 // 文件数超出提示
274 const handleExceed = (): void => { 275 const handleExceed = (): void => {
@@ -282,8 +283,8 @@ const excelUploadError = (): void =&gt; { @@ -282,8 +283,8 @@ const excelUploadError = (): void =&gt; {
282 onMounted(async () => { 283 onMounted(async () => {
283 await getTree() 284 await getTree()
284 await getPostOptions() 285 await getPostOptions()
  286 + await getList()
285 }) 287 })
286 -getList()  
287 </script> 288 </script>
288 289
289 <template> 290 <template>