diff --git a/ds-wms-admin-web/.env.development b/ds-wms-admin-web/.env.development index f3241d41..3db4cdce 100644 --- a/ds-wms-admin-web/.env.development +++ b/ds-wms-admin-web/.env.development @@ -13,8 +13,8 @@ VITE_PROXY=[["/api","http://60.209.125.238:3008"],["/stage-api","https://www.666 VITE_DROP_CONSOLE = false # 后台接口父地址(必填) -VITE_GLOB_API_URL=http://localhost:3008 -#VITE_GLOB_API_URL="/api" # 开发 测试环境 +# VITE_GLOB_API_URL=http://localhost:3008 +VITE_GLOB_API_URL="/api" # 开发 测试环境 # File upload address, optional #VITE_GLOB_UPLOAD_URL=http://localhost:8091/api/Common/UploadFile diff --git a/ds-wms-admin-web/src/api/common/index.ts b/ds-wms-admin-web/src/api/common/index.ts index f770c88f..eb8dd7aa 100644 --- a/ds-wms-admin-web/src/api/common/index.ts +++ b/ds-wms-admin-web/src/api/common/index.ts @@ -18,6 +18,7 @@ const viewUploadUrl = globSetting.viewUrl enum Api { Login = '/adminApi/common/login', GetUserInfo = '/adminApi/common/GetUserInfo', + UserRefreshToken = '/adminApi/Common/UserRefreshToken', getDictDrop = '/adminApi/Common/GetDictTypeDropDown', getDictOptions = '/adminApi/Common/GetDictOptions', getRoleList = '/adminApi/Common/GetRoleList', @@ -137,6 +138,15 @@ export function getUserInfo() { method: 'get', }) } +export function UserRefreshToken(data) { + return request>({ + url: Api.UserRefreshToken, + method: 'get', + headers:{ + RefreshToken:data.refreshToken + } + }) +} export function userLogout() { return request({ url: Api.userLogout, diff --git a/ds-wms-admin-web/src/store/modules/user.ts b/ds-wms-admin-web/src/store/modules/user.ts index 5c122235..b1cfb1aa 100644 --- a/ds-wms-admin-web/src/store/modules/user.ts +++ b/ds-wms-admin-web/src/store/modules/user.ts @@ -15,7 +15,13 @@ import { h } from 'vue' import { Storage } from '/@/utils/Storage' import { CurrentUserViewModel, LoginParams } from '/@/api/common/Model' -import { getUserInfo, login, userLogout, getCollectWarningCount } from '/@/api/common' +import { + getUserInfo, + login, + userLogout, + getCollectWarningCount, + UserRefreshToken, +} from '/@/api/common' import { DataResult } from '/@/api/model/baseModel' import { initDictOptions } from '/@/utils/dictUtil' import { getThermometryWarningCount } from '/@/api/security/hkopen' @@ -101,12 +107,14 @@ export const useUserStore = defineStore({ if (res !== undefined) { const token = res?.data this.setToken(token) + return this.afterLoginAction(true) } } catch (error) { return Promise.reject(error) } }, + async afterLoginAction(goHome?: boolean): Promise { if (!this.getToken) return null // get user info @@ -138,6 +146,14 @@ export const useUserStore = defineStore({ if (!this.getToken) return null const response = await getUserInfo() const userInfo = response.data + //获取 用户信息后 开启计时器 重置 token + setTimeout(async () => { + const Refres = await UserRefreshToken(userInfo) + if (Refres.succeeded) { + this.setToken(Refres.data.accessToken) + this.setUserInfo({ refreshToken: Refres.data.refreshToken }) + } + }, 6600000) /** * 初始化字典选项 */ @@ -150,6 +166,8 @@ export const useUserStore = defineStore({ // userInfo.roles = [] // this.setRoleList([]) // } + // + console.log('用户信息', userInfo) this.setUserInfo(userInfo) return userInfo diff --git a/ds-wms-admin-web/src/views/baseinfo/tenantaudit/Authorization.vue b/ds-wms-admin-web/src/views/baseinfo/tenantaudit/Authorization.vue index 05c63cc5..748c8979 100644 --- a/ds-wms-admin-web/src/views/baseinfo/tenantaudit/Authorization.vue +++ b/ds-wms-admin-web/src/views/baseinfo/tenantaudit/Authorization.vue @@ -1,6 +1,5 @@