feat: 改变身份存储验证
- 避免在其他地方进入首页的时候出现登录失效的提示
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
export function hasLogin() {
|
export function hasLogin() {
|
||||||
return !!globalThis.localStorage.getItem('token')
|
return !!globalThis.sessionStorage.getItem('token')
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getToken() {
|
export async function getToken() {
|
||||||
const token = globalThis.localStorage.getItem('token')
|
const token = globalThis.sessionStorage.getItem('token')
|
||||||
if (token) return token
|
if (token) return token
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,8 +62,9 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
const params = getParamsFromUrl(globalThis.location.href)
|
const params = getParamsFromUrl(globalThis.location.href)
|
||||||
const token = params.get('token')
|
const token = params.get('token')
|
||||||
if (token) {
|
const stoken = globalThis.sessionStorage.getItem('token')
|
||||||
globalThis.localStorage.setItem('token', token)
|
if (token || stoken) {
|
||||||
|
globalThis.sessionStorage.setItem('token', token)
|
||||||
fetchUserInfo().then(res => {
|
fetchUserInfo().then(res => {
|
||||||
const { content } = res.content
|
const { content } = res.content
|
||||||
this.name = content.name
|
this.name = content.name
|
||||||
@@ -84,7 +85,7 @@ export default {
|
|||||||
<!-- 标题提示语部分 -->
|
<!-- 标题提示语部分 -->
|
||||||
<section class="title">
|
<section class="title">
|
||||||
<!-- 反正背景图颜色 -->
|
<!-- 反正背景图颜色 -->
|
||||||
<img width="78px" :src="titleSrc" style="width: 78px;"/>
|
<img width="78px" :src="titleSrc" style="width: 78px;" />
|
||||||
<h2> <span>您好</span> {{ title }}</h2>
|
<h2> <span>您好</span> {{ title }}</h2>
|
||||||
</section>
|
</section>
|
||||||
<!-- 轮播图部分 -->
|
<!-- 轮播图部分 -->
|
||||||
|
|||||||
Reference in New Issue
Block a user