master
张同海 10 months ago
parent b634ae126c
commit 3b0630597a

@ -13,8 +13,8 @@ VITE_PROXY=[["/api","http://60.209.125.238:3008"],["/stage-api","https://www.666
VITE_DROP_CONSOLE = false VITE_DROP_CONSOLE = false
# 后台接口父地址(必填) # 后台接口父地址(必填)
VITE_GLOB_API_URL=http://localhost:3008 # VITE_GLOB_API_URL=http://localhost:3008
#VITE_GLOB_API_URL="/api" # 开发 测试环境 VITE_GLOB_API_URL="/api" # 开发 测试环境
# File upload address optional # File upload address optional
#VITE_GLOB_UPLOAD_URL=http://localhost:8091/api/Common/UploadFile #VITE_GLOB_UPLOAD_URL=http://localhost:8091/api/Common/UploadFile

@ -18,6 +18,7 @@ const viewUploadUrl = globSetting.viewUrl
enum Api { enum Api {
Login = '/adminApi/common/login', Login = '/adminApi/common/login',
GetUserInfo = '/adminApi/common/GetUserInfo', GetUserInfo = '/adminApi/common/GetUserInfo',
UserRefreshToken = '/adminApi/Common/UserRefreshToken',
getDictDrop = '/adminApi/Common/GetDictTypeDropDown', getDictDrop = '/adminApi/Common/GetDictTypeDropDown',
getDictOptions = '/adminApi/Common/GetDictOptions', getDictOptions = '/adminApi/Common/GetDictOptions',
getRoleList = '/adminApi/Common/GetRoleList', getRoleList = '/adminApi/Common/GetRoleList',
@ -137,6 +138,15 @@ export function getUserInfo() {
method: 'get', method: 'get',
}) })
} }
export function UserRefreshToken(data) {
return request<DataResult<CurrentUserViewModel>>({
url: Api.UserRefreshToken,
method: 'get',
headers:{
RefreshToken:data.refreshToken
}
})
}
export function userLogout() { export function userLogout() {
return request<DataResult>({ return request<DataResult>({
url: Api.userLogout, url: Api.userLogout,

@ -15,7 +15,13 @@ import { h } from 'vue'
import { Storage } from '/@/utils/Storage' import { Storage } from '/@/utils/Storage'
import { CurrentUserViewModel, LoginParams } from '/@/api/common/Model' 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 { DataResult } from '/@/api/model/baseModel'
import { initDictOptions } from '/@/utils/dictUtil' import { initDictOptions } from '/@/utils/dictUtil'
import { getThermometryWarningCount } from '/@/api/security/hkopen' import { getThermometryWarningCount } from '/@/api/security/hkopen'
@ -101,12 +107,14 @@ export const useUserStore = defineStore({
if (res !== undefined) { if (res !== undefined) {
const token = res?.data const token = res?.data
this.setToken(token) this.setToken(token)
return this.afterLoginAction(true) return this.afterLoginAction(true)
} }
} catch (error) { } catch (error) {
return Promise.reject(error) return Promise.reject(error)
} }
}, },
async afterLoginAction(goHome?: boolean): Promise<CurrentUserViewModel | null> { async afterLoginAction(goHome?: boolean): Promise<CurrentUserViewModel | null> {
if (!this.getToken) return null if (!this.getToken) return null
// get user info // get user info
@ -138,6 +146,14 @@ export const useUserStore = defineStore({
if (!this.getToken) return null if (!this.getToken) return null
const response = await getUserInfo() const response = await getUserInfo()
const userInfo = response.data 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 = [] // userInfo.roles = []
// this.setRoleList([]) // this.setRoleList([])
// } // }
//
console.log('用户信息', userInfo) console.log('用户信息', userInfo)
this.setUserInfo(userInfo) this.setUserInfo(userInfo)
return userInfo return userInfo

@ -1,6 +1,5 @@
<template> <BasicForm @register="registerForm" /> </template> <template> <BasicForm @register="registerForm" /> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { Item } from 'node_modules/ant-design-vue/lib/menu'
import { defineComponent, ref, watch, onMounted } from 'vue' import { defineComponent, ref, watch, onMounted } from 'vue'
import { BasicForm, useForm } from '/@/components/Form/index' import { BasicForm, useForm } from '/@/components/Form/index'
// import { authorization } from './columns' // import { authorization } from './columns'

@ -52,7 +52,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { reactive, ref, unref, computed } from 'vue' import { reactive, ref, unref, computed } from 'vue'
import { Md5 } from 'ts-md5/dist/md5'; import { Md5 } from 'ts-md5/dist/md5'
import { Checkbox, Form, Input, Row, Col, Button, Divider } from 'ant-design-vue' import { Checkbox, Form, Input, Row, Col, Button, Divider } from 'ant-design-vue'
import LoginFormTitle from './LoginFormTitle.vue' import LoginFormTitle from './LoginFormTitle.vue'
@ -102,7 +102,7 @@
mode: 'none', // mode: 'none', //
}) })
if (res) { if (res) {
console.log(res) console.log(res, 1111111111)
notification.success({ notification.success({
message: t('sys.login.loginSuccessTitle'), message: t('sys.login.loginSuccessTitle'),
description: `${t('sys.login.loginSuccessDesc')}`, description: `${t('sys.login.loginSuccessDesc')}`,

@ -94,6 +94,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
define: { define: {
// setting vue-i18-next // setting vue-i18-next
// Suppress warning // Suppress warning
// __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: true,
__INTLIFY_PROD_DEVTOOLS__: false, __INTLIFY_PROD_DEVTOOLS__: false,
__APP_INFO__: JSON.stringify(__APP_INFO__), __APP_INFO__: JSON.stringify(__APP_INFO__),
}, },

Loading…
Cancel
Save