From 8d4f3561d5431dfb6df5edb3d643d93a0bb7dba1 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期五, 11 十二月 2020 18:45:57 +0800 Subject: [PATCH] 修复mybatis-plus插件不生效bug --- ruoyi-ui/src/utils/request.js | 29 ++++++++++++++++++++++++----- 1 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ruoyi-ui/src/utils/request.js b/ruoyi-ui/src/utils/request.js index f62368e..e7e6519 100644 --- a/ruoyi-ui/src/utils/request.js +++ b/ruoyi-ui/src/utils/request.js @@ -19,6 +19,28 @@ if (getToken() && !isToken) { config.headers['Authorization'] = 'Bearer ' + getToken() // 璁╂瘡涓姹傛惡甯﹁嚜瀹氫箟token 璇锋牴鎹疄闄呮儏鍐佃嚜琛屼慨鏀� } + // get璇锋眰鏄犲皠params鍙傛暟 + if (config.method === 'get' && config.params) { + let url = config.url + '?'; + for (const propName of Object.keys(config.params)) { + const value = config.params[propName]; + var part = encodeURIComponent(propName) + "="; + if (value && typeof(value) !== "undefined") { + if (typeof value === 'object') { + for (const key of Object.keys(value)) { + let params = propName + '[' + key + ']'; + var subPart = encodeURIComponent(params) + "="; + url += subPart + encodeURIComponent(value[key]) + "&"; + } + } else { + url += part + encodeURIComponent(value) + "&"; + } + } + } + url = url.slice(0, -1); + config.params = {}; + config.url = url; + } return config }, error => { console.log(error) @@ -32,17 +54,14 @@ // 鑾峰彇閿欒淇℃伅 const msg = errorCode[code] || res.data.msg || errorCode['default'] if (code === 401) { - MessageBox.confirm( - '鐧诲綍鐘舵�佸凡杩囨湡锛屾偍鍙互缁х画鐣欏湪璇ラ〉闈紝鎴栬�呴噸鏂扮櫥褰�', - '绯荤粺鎻愮ず', - { + MessageBox.confirm('鐧诲綍鐘舵�佸凡杩囨湡锛屾偍鍙互缁х画鐣欏湪璇ラ〉闈紝鎴栬�呴噸鏂扮櫥褰�', '绯荤粺鎻愮ず', { confirmButtonText: '閲嶆柊鐧诲綍', cancelButtonText: '鍙栨秷', type: 'warning' } ).then(() => { store.dispatch('LogOut').then(() => { - location.reload() // 涓轰簡閲嶆柊瀹炰緥鍖杤ue-router瀵硅薄 閬垮厤bug + location.href = '/index'; }) }) } else if (code === 500) { -- Gitblit v1.9.3