diff --git a/sub-admin/src/api/login.js b/sub-admin/src/api/login.js index 44486b7..e8ad5a9 100644 --- a/sub-admin/src/api/login.js +++ b/sub-admin/src/api/login.js @@ -1,4 +1,4 @@ -import request from '@/utils/request'; +import request from '@/utils/request' // 登录方法 export function login(username, password, code, uuid) { @@ -10,7 +10,7 @@ export function login(username, password, code, uuid) { }, method: 'post', data: { username, password, code, uuid }, - }); + }) } // 注册方法 @@ -22,7 +22,7 @@ export function register(data) { }, method: 'post', data: data, - }); + }) } // 刷新方法 @@ -30,7 +30,7 @@ export function refreshToken() { return request({ url: '/auth/refresh', method: 'post', - }); + }) } // 获取用户详细信息 @@ -38,7 +38,7 @@ export function getInfo() { return request({ url: '/system/user/getInfo', method: 'get', - }); + }) } // 退出方法 @@ -46,7 +46,7 @@ export function logout() { return request({ url: '/auth/logout', method: 'delete', - }); + }) } // 获取验证码 @@ -58,5 +58,5 @@ export function getCodeImg() { }, method: 'get', timeout: 20000, - }); + }) } diff --git a/sub-admin/src/utils/auth.js b/sub-admin/src/utils/auth.js index a6a5e6c..3d87deb 100644 --- a/sub-admin/src/utils/auth.js +++ b/sub-admin/src/utils/auth.js @@ -7,14 +7,13 @@ const TokenKey = 'Admin-Token'; const ExpiresInKey = 'Admin-Expires-In'; export function getToken() { - return true - // let token = Cookies.get(TokenKey); - // if (undefined === token || null == token || 'null' === token) { - // token = getQueryString('Authorization'); - // if (null != token || 'null' !== token) Cookies.set(TokenKey, token); - // } - // if (undefined === token || null == token || 'null' === token) token = false; - // return token; + let token = Cookies.get(TokenKey); + if (undefined === token || null == token || 'null' === token) { + token = getQueryString('Authorization'); + if (null != token || 'null' !== token) Cookies.set(TokenKey, token); + } + if (undefined === token || null == token || 'null' === token) token = false; + return token; } export function setToken(token) { diff --git a/sub-admin/src/utils/request.js b/sub-admin/src/utils/request.js index b2a9676..f77343b 100644 --- a/sub-admin/src/utils/request.js +++ b/sub-admin/src/utils/request.js @@ -28,7 +28,7 @@ service.interceptors.request.use( // 是否需要防止数据重复提交 const isRepeatSubmit = (config.headers || {}).repeatSubmit === false; if (getToken() && !isToken) { - config.headers['Authorization'] = 'Bearer ' + getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改 + config.headers['Authorization'] = getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改 } // get请求映射params参数 if (config.method === 'get' && config.params) { diff --git a/sub-admin/vue.config.js b/sub-admin/vue.config.js index 35d1797..164df24 100644 --- a/sub-admin/vue.config.js +++ b/sub-admin/vue.config.js @@ -18,7 +18,7 @@ module.exports = { // 部署生产环境和开发环境下的URL。 // 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上 // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。 - publicPath: `/sub-admin/`, + publicPath: './', // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist) outputDir: 'dist', // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下) @@ -68,7 +68,7 @@ module.exports = { libraryTarget: 'umd', // 把微应用打包成 umd 库格式 jsonpFunction: `${name}`, filename: `[name].[hash].js`, - chunkFilename: `[name].[hash].js` + chunkFilename: `[name].[hash].js`, }, plugins: [ new CompressionPlugin({