feat: log out
This commit is contained in:
parent
eff2f60bd7
commit
0c5e89b36f
|
@ -78,6 +78,7 @@ const handleConfirm = () => {
|
||||||
height: 30px;
|
height: 30px;
|
||||||
color: var(--kungalgame-font-color-3);
|
color: var(--kungalgame-font-color-3);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
border-radius: 2px;
|
||||||
&:nth-child(1) {
|
&:nth-child(1) {
|
||||||
background-color: var(--kungalgame-trans-blue-1);
|
background-color: var(--kungalgame-trans-blue-1);
|
||||||
border: 1px solid var(--kungalgame-blue-4);
|
border: 1px solid var(--kungalgame-blue-4);
|
||||||
|
|
|
@ -1,7 +1,19 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
const container = ref<HTMLElement>()
|
import { useRouter } from 'vue-router'
|
||||||
|
// 全局消息组件(顶部)
|
||||||
|
import message from '@/components/alert/Message'
|
||||||
|
// 全局消息组件(底部)
|
||||||
|
import { useKUNGalgameMessageStore } from '@/store/modules/message'
|
||||||
|
import { useKUNGalgameUserStore } from '@/store/modules/kungalgamer'
|
||||||
|
import { storeToRefs } from 'pinia'
|
||||||
|
// 重置 store
|
||||||
|
import { kungalgameStoreReset } from '@/store'
|
||||||
|
|
||||||
|
const { uid, name, moemoepoint } = storeToRefs(useKUNGalgameUserStore())
|
||||||
|
|
||||||
|
const container = ref<HTMLElement>()
|
||||||
|
const router = useRouter()
|
||||||
const emit = defineEmits({
|
const emit = defineEmits({
|
||||||
close,
|
close,
|
||||||
})
|
})
|
||||||
|
@ -15,8 +27,19 @@ const handlePanelBlur = async () => {
|
||||||
emit('close')
|
emit('close')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 退出登录
|
// 退出登录,简单起见这里不和后端通信使 token 从 redis 移除了
|
||||||
const logOut = () => {}
|
const logOut = async () => {
|
||||||
|
// 获取用户点击的结果
|
||||||
|
const res = await useKUNGalgameMessageStore().alert(
|
||||||
|
'AlertInfo.edit.logout',
|
||||||
|
true
|
||||||
|
)
|
||||||
|
if (res) {
|
||||||
|
kungalgameStoreReset()
|
||||||
|
router.push('/login')
|
||||||
|
message('Logout successfully!', '登出成功', 'success')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 自动获取焦点
|
// 自动获取焦点
|
||||||
|
@ -30,12 +53,18 @@ onMounted(() => {
|
||||||
<span class="triangle2"></span>
|
<span class="triangle2"></span>
|
||||||
<div class="kungalgamer">
|
<div class="kungalgamer">
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<p>KUN</p>
|
<p>{{ name }}</p>
|
||||||
<p>MP: <span>1007</span></p>
|
<p>
|
||||||
|
MP: <span>{{ moemoepoint }}</span>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="func">
|
<div class="func">
|
||||||
<span><RouterLink to="/kungalgamer">个人主页</RouterLink></span>
|
<span>
|
||||||
<span>退出登录</span>
|
<RouterLink to="/kungalgamer">
|
||||||
|
{{ $tm('header.user.profile') }}
|
||||||
|
</RouterLink>
|
||||||
|
</span>
|
||||||
|
<span @click="logOut">{{ $tm('header.user.logout') }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -50,6 +79,7 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
.triangle1 {
|
.triangle1 {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
top: 1px;
|
||||||
width: 0;
|
width: 0;
|
||||||
height: 0;
|
height: 0;
|
||||||
border-left: 10px solid transparent;
|
border-left: 10px solid transparent;
|
||||||
|
@ -63,7 +93,7 @@ onMounted(() => {
|
||||||
height: 0;
|
height: 0;
|
||||||
border-left: 10px solid transparent;
|
border-left: 10px solid transparent;
|
||||||
border-right: 10px solid transparent;
|
border-right: 10px solid transparent;
|
||||||
border-bottom: 17px solid var(--kungalgame-blue-4);
|
border-bottom: 17px solid var(--kungalgame-blue-1);
|
||||||
}
|
}
|
||||||
.kungalgamer {
|
.kungalgamer {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
@ -71,6 +101,7 @@ onMounted(() => {
|
||||||
transform: translateX(-43%);
|
transform: translateX(-43%);
|
||||||
width: 130px;
|
width: 130px;
|
||||||
background-color: var(--kungalgame-white);
|
background-color: var(--kungalgame-white);
|
||||||
|
border: 1px solid var(--kungalgame-blue-1);
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -108,7 +139,7 @@ onMounted(() => {
|
||||||
color: var(--kungalgame-blue-5);
|
color: var(--kungalgame-blue-5);
|
||||||
}
|
}
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: var(--kungalgame-blue-1);
|
background-color: var(--kungalgame-trans-blue-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,10 @@ export default {
|
||||||
restore: 'Restore blank background',
|
restore: 'Restore blank background',
|
||||||
recover: 'Recover all settings to default',
|
recover: 'Recover all settings to default',
|
||||||
},
|
},
|
||||||
|
user: {
|
||||||
|
profile: 'Profile Page',
|
||||||
|
logout: 'Log out',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
back: {
|
back: {
|
||||||
back: 'Back',
|
back: 'Back',
|
||||||
|
@ -224,6 +228,7 @@ export default {
|
||||||
closePanel: 'Confirm closing the panel? Your changes will not be saved.',
|
closePanel: 'Confirm closing the panel? Your changes will not be saved.',
|
||||||
draft: 'The draft has been saved successfully!',
|
draft: 'The draft has been saved successfully!',
|
||||||
leave: 'Confirm leaving the page? Your changes will not be saved.',
|
leave: 'Confirm leaving the page? Your changes will not be saved.',
|
||||||
|
logout: 'Are you sure you want to log out?',
|
||||||
},
|
},
|
||||||
login: {
|
login: {
|
||||||
invalidUsername:
|
invalidUsername:
|
||||||
|
|
|
@ -23,6 +23,10 @@ export default {
|
||||||
restore: '恢复空白背景',
|
restore: '恢复空白背景',
|
||||||
recover: '恢复所有设置为默认',
|
recover: '恢复所有设置为默认',
|
||||||
},
|
},
|
||||||
|
user: {
|
||||||
|
profile: '个人主页',
|
||||||
|
logout: '退出登录',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
back: {
|
back: {
|
||||||
back: '返回',
|
back: '返回',
|
||||||
|
@ -221,6 +225,7 @@ export default {
|
||||||
closePanel: '确认关闭面板吗?您的更改将不会被保存',
|
closePanel: '确认关闭面板吗?您的更改将不会被保存',
|
||||||
draft: '草稿已经保存成功!',
|
draft: '草稿已经保存成功!',
|
||||||
leave: '确认离开界面吗?您的更改将不会保存',
|
leave: '确认离开界面吗?您的更改将不会保存',
|
||||||
|
logout: '您确定退出登录吗?',
|
||||||
},
|
},
|
||||||
login: {
|
login: {
|
||||||
invalidUsername:
|
invalidUsername:
|
||||||
|
|
|
@ -33,7 +33,7 @@ export function setupPinia(app: App<Element>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重置所有 store,用于登出
|
// 重置所有 store,用于登出
|
||||||
export function storeReset() {
|
export function kungalgameStoreReset() {
|
||||||
const editStore = useKUNGalgameEditStore()
|
const editStore = useKUNGalgameEditStore()
|
||||||
const homeStore = useKUNGalgameHomeStore()
|
const homeStore = useKUNGalgameHomeStore()
|
||||||
const userStore = useKUNGalgameUserStore()
|
const userStore = useKUNGalgameUserStore()
|
||||||
|
|
|
@ -25,6 +25,7 @@ export const useKUNGalgameUserStore = defineStore({
|
||||||
uid: 0,
|
uid: 0,
|
||||||
name: '',
|
name: '',
|
||||||
avatar: '',
|
avatar: '',
|
||||||
|
moemoepoint: 0,
|
||||||
moemoeAccessToken: '',
|
moemoeAccessToken: '',
|
||||||
}),
|
}),
|
||||||
getters: {},
|
getters: {},
|
||||||
|
|
1
src/store/types/kungalgamer.d.ts
vendored
1
src/store/types/kungalgamer.d.ts
vendored
|
@ -3,5 +3,6 @@ export interface KUNGalgamerStore {
|
||||||
uid: number
|
uid: number
|
||||||
name: string
|
name: string
|
||||||
avatar: string
|
avatar: string
|
||||||
|
moemoepoint: number
|
||||||
moemoeAccessToken: string
|
moemoeAccessToken: string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue