提交 dae610b5 authored 作者: haodaking's avatar haodaking

chore: update

上级 2adb4b1e
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
const user = useUserStore() const user = useUserStore()
const LOGINURL = `${import.meta.env.VITE_LOGIN_URL}?rd=${encodeURIComponent(location.href)}` const loginUrl = `${import.meta.env.VITE_LOGIN_URL}?rd=${encodeURIComponent(location.href)}`
// 退出登录 // 退出登录
function handleLogout() { function handleLogout() {
...@@ -22,8 +22,10 @@ function handleLogout() { ...@@ -22,8 +22,10 @@ function handleLogout() {
</router-link> </router-link>
</div> </div>
<div class="app-header-right"> <div class="app-header-right">
<template v-if="user.isLogin"> 你好,{{ user.userName }} <span class="app-header-logout" @click="handleLogout">退出</span> </template> <template v-if="user.isLogin">
<template v-else><a :href="LOGINURL">登录</a></template> 你好,{{ user.userName }} <span class="app-header-logout" @click="handleLogout">退出</span>
</template>
<template v-else><a :href="loginUrl">登录</a></template>
</div> </div>
</div> </div>
</header> </header>
...@@ -36,7 +38,7 @@ function handleLogout() { ...@@ -36,7 +38,7 @@ function handleLogout() {
background: #fff; background: #fff;
box-shadow: 0px 0px 29px rgba(0, 0, 0, 0.1); box-shadow: 0px 0px 29px rgba(0, 0, 0, 0.1);
border-top: 10px solid #aa1941; border-top: 10px solid #aa1941;
z-index: 1000; z-index: 2001;
} }
.app-header-inner { .app-header-inner {
width: 1440px; width: 1440px;
...@@ -49,7 +51,6 @@ function handleLogout() { ...@@ -49,7 +51,6 @@ function handleLogout() {
color: #aa1941; color: #aa1941;
} }
.app-header-left { .app-header-left {
flex: 1;
.logo { .logo {
display: flex; display: flex;
align-items: center; align-items: center;
...@@ -61,6 +62,7 @@ function handleLogout() { ...@@ -61,6 +62,7 @@ function handleLogout() {
line-height: 26px; line-height: 26px;
font-weight: 500; font-weight: 500;
letter-spacing: 2px; letter-spacing: 2px;
white-space: nowrap;
border-left: 1px solid #707070; border-left: 1px solid #707070;
} }
} }
......
...@@ -51,19 +51,15 @@ httpRequest.interceptors.request.use( ...@@ -51,19 +51,15 @@ httpRequest.interceptors.request.use(
httpRequest.interceptors.response.use( httpRequest.interceptors.response.use(
function (response) { function (response) {
const { data } = response const { data } = response
if (data.code === 0) {
return data
}
// 未登录 // 未登录
if (data.code === 4001) { if (data.code === 4001) {
location.href = `${import.meta.env.VITE_LOGIN_URL}?rd=${encodeURIComponent(location.href)}` location.href = `${import.meta.env.VITE_LOGIN_URL}?rd=${encodeURIComponent(location.href)}`
return Promise.reject(data) return Promise.reject(data)
} }
if (data.code === 1) { return Promise.reject(data)
return Promise.reject(data)
}
if (data.code === 4008) {
ElMessage.error(data.message || data.msg)
return Promise.reject(data)
}
return data
}, },
function (error) { function (error) {
if (error.response) { if (error.response) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论