增加关闭浏览器退出登录功能

This commit is contained in:
jiangzhe 2024-10-17 16:33:45 +08:00
parent a852c4b3d8
commit 71060c9e6e
7 changed files with 28 additions and 7 deletions

View File

@ -1,5 +1,5 @@
# 页面标题 # 页面标题
VITE_APP_TITLE = 云舒心理平台-学生端 VITE_APP_TITLE = 云舒心理成长平台-学生端
# 开发环境配置 # 开发环境配置
VITE_APP_ENV = 'development' VITE_APP_ENV = 'development'

View File

@ -1,8 +1,12 @@
# 页面标题 # 页面标题
VITE_APP_TITLE = 云舒心理平台-学生端 VITE_APP_TITLE = 云舒心理成长平台-学生端
# 生产环境配置 # 生产环境配置
VITE_APP_ENV = 'production' VITE_APP_ENV = 'production'
# 生产环境 # 生产环境
VITE_APP_BASE_API = 'https://api.ysmental.com/health-api' # VITE_APP_BASE_API = 'https://api.ysmental.com/health-api'
# 南昌生产环境
# VITE_APP_BASE_API = 'http://xlcp.xgc.nchu.edu.cn/health-api'
# 江海
VITE_APP_BASE_API = 'http://xlcz.jhu.cn:8000/health-api'

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>云舒-心理健康平台-学生端</title> <title>云舒心理成长平台-学生端</title>
<link rel="stylesheet" href="//at.alicdn.com/t/font_2143783_iq6z4ey5vu.css" /> <link rel="stylesheet" href="//at.alicdn.com/t/font_2143783_iq6z4ey5vu.css" />
</head> </head>
<body> <body>

View File

@ -1,5 +1,22 @@
<script setup> <script setup>
import { ref, onMounted, onBeforeUnmount } from 'vue';
const beforeunloadHandler = () => {
logout()
}
onMounted(() => {
window.addEventListener('beforeunload', e => beforeunloadHandler(e))
})
onBeforeUnmount(() => {
window.removeEventListener('beforeunload', e => beforeunloadHandler(e))
})
function logout() {
localStorage.removeItem('token')
localStorage.removeItem('userInfo')
router.replace("/login")
}
</script> </script>
<template> <template>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -6,7 +6,7 @@ import ScaleList from '@/views/ScaleList/index.vue'
import ExamDetail from '@/views/ExamDetail/index.vue' import ExamDetail from '@/views/ExamDetail/index.vue'
const router = createRouter({ const router = createRouter({
history: createWebHashHistory('/'), history: createWebHashHistory('/web'),
routes: [ routes: [
{ {
path: '/login', path: '/login',

View File

@ -18,7 +18,7 @@ export default defineConfig({
outDir: 'web', outDir: 'web',
chunkSizeWarningLimit: 1600 chunkSizeWarningLimit: 1600
}, },
base: '/', base: '/web',
plugins: [ plugins: [
vue(), vue(),
vueSetupExtend(), vueSetupExtend(),
@ -65,7 +65,7 @@ export default defineConfig({
server: { server: {
proxy: { proxy: {
'/api': { '/api': {
target: 'http://localhost:8080/', target: 'http://localhost:8070/',
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '') rewrite: (path) => path.replace(/^\/api/, '')
} }