登录注册完成

This commit is contained in:
Guwan 2024-12-07 22:22:29 +08:00
parent 4671a6d390
commit 26712f144d
3 changed files with 12 additions and 8 deletions

View File

@ -32,7 +32,7 @@
</template>
<script setup lang="ts">
import { ref, inject } from 'vue'
import { ref, inject, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessageBox } from 'element-plus'
import { User, Setting, SwitchButton, Expand, Fold } from '@element-plus/icons-vue'
@ -46,6 +46,9 @@ const userInfo = ref({
avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png'
})
const toggleSidebar = () => {
isCollapsed.value = !isCollapsed.value
}

View File

@ -19,7 +19,7 @@ service.interceptors.request.use(
if (token) {
config.headers = {
...config.headers,
Authorization: token
Authorization: `Bearer ${token}`
}
}
return config
@ -55,6 +55,7 @@ service.interceptors.response.use(
// 处理 HTTP 错误
if (error.response) {
console.log(error.response)
const { status } = error.response
switch (status) {
case 400:

View File

@ -316,9 +316,9 @@ const handleLogin = async () => {
console.log(token)
userStore.setToken(token)
const res = await userApi.getCurrentUser()
//console.log(res)
console.log(res)
ElMessage.success('登录成功')
//router.push('/')
router.push('/')
} catch (error) {
console.error('登录失败:', error)
} finally {