feat: 改变身份存储验证

- 避免在其他地方进入首页的时候出现登录失效的提示
This commit is contained in:
huangze
2025-07-08 09:35:51 +08:00
parent e1d5990ba6
commit 029ddc4e7a
2 changed files with 6 additions and 5 deletions

View File

@@ -1,8 +1,8 @@
export function hasLogin() {
return !!globalThis.localStorage.getItem('token')
return !!globalThis.sessionStorage.getItem('token')
}
export async function getToken() {
const token = globalThis.localStorage.getItem('token')
const token = globalThis.sessionStorage.getItem('token')
if (token) return token
}

View File

@@ -62,8 +62,9 @@ export default {
mounted() {
const params = getParamsFromUrl(globalThis.location.href)
const token = params.get('token')
if (token) {
globalThis.localStorage.setItem('token', token)
const stoken = globalThis.sessionStorage.getItem('token')
if (token || stoken) {
globalThis.sessionStorage.setItem('token', token)
fetchUserInfo().then(res => {
const { content } = res.content
this.name = content.name
@@ -84,7 +85,7 @@ export default {
<!-- 标题提示语部分 -->
<section class="title">
<!-- 反正背景图颜色 -->
<img width="78px" :src="titleSrc" style="width: 78px;"/>
<img width="78px" :src="titleSrc" style="width: 78px;" />
<h2> <span>您好</span> {{ title }}</h2>
</section>
<!-- 轮播图部分 -->