feat: add token validation api and auth module

This commit is contained in:
Tim
2025-07-05 13:34:47 +08:00
parent 3568e54984
commit 6bdc32ff05
4 changed files with 42 additions and 1 deletions

View File

@@ -56,6 +56,7 @@
<script>
import { API_BASE_URL, toast } from '../main'
import { setToken } from '../utils/auth'
export default {
name: 'LoginPageView',
data() {
@@ -77,7 +78,7 @@ export default {
this.isWaitingForLogin = false
const data = await res.json()
if (res.ok && data.token) {
localStorage.setItem('token', data.token)
setToken(data.token)
toast.success('登录成功')
this.$router.push('/')
} else {