refactor: refactor api usage

This commit is contained in:
张传龙
2022-07-25 18:36:22 +08:00
parent e5768fa1e3
commit 7762e02b31
11 changed files with 34 additions and 101 deletions

View File

@@ -43,11 +43,11 @@
</template>
<script setup>
import { login } from '@/api/auth'
import { lStorage } from '@/utils/cache'
import { setToken } from '@/utils/token'
import { useStorage } from '@vueuse/core'
import bgImg from '@/assets/images/login_bg.jpg'
import api from './api'
const title = import.meta.env.VITE_APP_TITLE
@@ -80,7 +80,7 @@ async function handleLogin() {
try {
$message.loading('正在验证...')
loging.value = true
const res = await login({ name, password: password.toString() })
const res = await api.login({ name, password: password.toString() })
if (res.code === 0) {
$message.success('登录成功')
setToken(res.data.token)