mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
优化 JWT 令牌的存储和使用逻辑;调整布局样式和组件属性
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { cookie } from '@/api/account';
|
||||
import { AccountInfo } from '@/api/api-models'
|
||||
import { QueryGetAPI, QueryPostAPI } from '@/api/query'
|
||||
import { ACCOUNT_API_URL, TURNSTILE_KEY } from '@/data/constants'
|
||||
@@ -43,7 +44,6 @@ const registerModel = ref<RegisterModel>({} as RegisterModel)
|
||||
const loginModel = ref<LoginModel>({} as LoginModel)
|
||||
const token = ref('')
|
||||
const turnstile = ref()
|
||||
const cookie = useLocalStorage('JWT_Token', '')
|
||||
|
||||
const selectedTab = ref('login')
|
||||
const inputForgetPasswordValue = ref('')
|
||||
@@ -133,7 +133,10 @@ function onRegisterButtonClick() {
|
||||
.then((data) => {
|
||||
if (data.code == 200) {
|
||||
message.success(`注册成功`)
|
||||
cookie.value = data.data
|
||||
cookie.value = {
|
||||
cookie: data.data,
|
||||
refreshDate: Date.now()
|
||||
}
|
||||
setTimeout(() => {
|
||||
location.reload()
|
||||
}, 1000)
|
||||
@@ -159,7 +162,10 @@ function onLoginButtonClick() {
|
||||
})
|
||||
.then(async (data) => {
|
||||
if (data.code == 200) {
|
||||
localStorage.setItem('JWT_Token', data.data.token)
|
||||
cookie.value = {
|
||||
cookie: data.data.token,
|
||||
refreshDate: Date.now()
|
||||
}
|
||||
message.success(`成功登陆为 ${data?.data.account.name}`)
|
||||
setTimeout(() => {
|
||||
location.reload()
|
||||
|
||||
@@ -5,8 +5,8 @@ import { useStorage } from '@vueuse/core';
|
||||
import { NSpin, useLoadingBar, useMessage, useModal } from 'naive-ui'
|
||||
import { onMounted } from 'vue'
|
||||
import { useRoute } from 'vue-router';
|
||||
import { cookie } from '@/api/account';
|
||||
|
||||
const cookie = useStorage('JWT_Token', '')
|
||||
const accountInfo = useAccount()
|
||||
|
||||
// Setup code
|
||||
|
||||
Reference in New Issue
Block a user