退出登录之后不是刷新页面,而是直接跳转到登录页面

This commit is contained in:
GeekMaster
2025-08-14 16:59:16 +08:00
parent f82270d097
commit c9a7449d2d
6 changed files with 47 additions and 41 deletions

View File

@@ -17,7 +17,7 @@
</el-form-item>
<el-form-item label="验证码">
<div class="flex">
<el-input v-model="form.code" maxlength="6" class="mr-2 w-1/2" />
<el-input v-model="form.code" maxlength="6" class="mr-2 max-w-[200px]" />
<send-msg size="" :receiver="form.mobile" type="mobile" />
</div>
</el-form-item>

View File

@@ -716,6 +716,7 @@ const sendSSERequest = async (message) => {
} else {
const errorMsg = `连接失败 (状态码: ${response.status})`
ElMessage.error(errorMsg)
console.error('SSE connection failed', response)
enableInput()
throw new Error(errorMsg)
}

View File

@@ -285,9 +285,7 @@ const logout = function () {
httpGet('/api/user/logout')
.then(() => {
removeUserToken()
// 刷新组件
routerViewKey.value += 1
loginUser.value = {}
router.push('/login')
})
.catch(() => {
ElMessage.error('注销失败!')

View File

@@ -28,7 +28,7 @@
<span v-if="!isLogin">
<el-button
@click="showLoginDialog = true"
@click="router.push('/login')"
class="btn-go animate__animated animate__pulse animate__infinite"
round
>登录/注册</el-button
@@ -51,15 +51,6 @@
<h1 class="animate__animated animate__backInDown">
{{ title }}
</h1>
<!-- <div class="msg-text cursor-ani">
<span
v-for="(char, index) in displayedChars"
:key="index"
:style="{ color: rainbowColor(index) }"
>
{{ char }}
</span>
</div> -->
<div class="navs animate__animated animate__backInDown">
<el-space wrap :size="14">
@@ -79,18 +70,6 @@
<footer-bar />
<!-- 登录弹窗 -->
<el-dialog v-model="showLoginDialog" width="500px" @close="showLoginDialog = false">
<template #header>
<div class="text-center text-xl" style="color: var(--theme-text-color-primary)">
登录解锁更多功能
</div>
</template>
<div class="p-4 pt-2 pb-2">
<LoginDialog @success="loginSuccess" @hide="showLoginDialog = false" />
</div>
</el-dialog>
<!-- 网站公告对话框 -->
<el-dialog v-model="showNotice" :show-close="true" class="notice-dialog" title="网站公告">
<div class="notice">
@@ -108,17 +87,16 @@
<script setup>
import FooterBar from '@/components/FooterBar.vue'
import LoginDialog from '@/components/LoginDialog.vue'
import ThemeChange from '@/components/ThemeChange.vue'
import { checkSession, getLicenseInfo, getSystemInfo } from '@/store/cache'
import { removeUserToken } from '@/store/session'
import { httpGet } from '@/utils/http'
import { isMobile } from '@/utils/libs'
import { ElMessage } from 'element-plus'
import MarkdownIt from 'markdown-it'
import emoji from 'markdown-it-emoji'
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { isMobile } from '@/utils/libs'
const router = useRouter()
@@ -127,7 +105,6 @@ const logo = ref('')
const license = ref({ de_copy: true })
const isLogin = ref(false)
const showLoginDialog = ref(false)
const docsURL = ref(import.meta.env.VITE_DOCS_URL)
const githubURL = ref(import.meta.env.VITE_GITHUB_URL)
const giteeURL = ref(import.meta.env.VITE_GITEE_URL)
@@ -204,12 +181,7 @@ onMounted(() => {
const logout = () => {
removeUserToken()
isLogin.value = false
}
const loginSuccess = () => {
isLogin.value = true
showLoginDialog.value = false
router.push('/login')
}
// 不再显示公告

View File

@@ -25,12 +25,19 @@
<script setup>
import LoginDialog from '@/components/LoginDialog.vue'
import { setUserToken } from '@/store/session'
import { getCurrentDeviceRedirectPath } from '@/utils/device'
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const loginDialogRef = ref(null)
const token = router.currentRoute.value.query.token
if (token) {
setUserToken(token)
router.push('/chat')
}
// 处理登录弹窗隐藏
const handleLoginHide = () => {
@@ -214,7 +221,7 @@ onMounted(() => {
border: none;
padding: 0 8px;
font-size: 14px;
&:hover {
background: var(--btn-bg);
border-radius: 6px;
@@ -222,7 +229,7 @@ onMounted(() => {
&.forget {
color: var(--theme-text-color-secondary);
&:hover {
color: var(--text-color-primary);
}

View File

@@ -23,6 +23,15 @@
<el-table-column label="账号">
<template #default="scope">
<span>{{ scope.row.username }}</span>
<el-tooltip content="复制用户名" placement="top">
<el-icon
class="copy-icon"
@click="copyUsername(scope.row.username)"
style="margin-left: 8px; cursor: pointer; color: #909399"
>
<DocumentCopy />
</el-icon>
</el-tooltip>
<el-image
v-if="scope.row.vip"
:src="vipImg"
@@ -198,12 +207,12 @@
</template>
<script setup>
import { onMounted, reactive, ref } from 'vue'
import { closeLoading, showLoading, showMessageError, showMessageOK } from '@/utils/dialog'
import { httpGet, httpPost } from '@/utils/http'
import { ElMessage, ElMessageBox } from 'element-plus'
import { dateFormat, disabledDate } from '@/utils/libs'
import { Delete, Plus, Search } from '@element-plus/icons-vue'
import { showLoading, closeLoading, showMessageError, showMessageOK } from '@/utils/dialog'
import { Delete, DocumentCopy, Plus, Search } from '@element-plus/icons-vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { onMounted, reactive, ref } from 'vue'
// 变量定义
const users = ref({ page: 1, page_size: 15, items: [] })
@@ -420,6 +429,16 @@ const copyLoginLink = () => {
showMessageError('复制失败')
}
}
// 复制用户名
const copyUsername = (username) => {
try {
navigator.clipboard.writeText(username)
ElMessage.success('用户名复制成功!')
} catch (e) {
ElMessage.error('复制失败')
}
}
</script>
<style lang="stylus" scoped>
@@ -456,5 +475,14 @@ const copyLoginLink = () => {
width: 100%
}
.copy-icon {
transition: all 0.3s ease;
&:hover {
color: #409eff !important;
transform: scale(1.1);
}
}
}
</style>