|
@@ -1,27 +0,0 @@
|
|
|
-import { injectable, Service } from '@/services/service'
|
|
|
|
|
-import NetService from '@/services/net.service'
|
|
|
|
|
-import useStore from '@/pages/store'
|
|
|
|
|
-
|
|
|
|
|
-@injectable
|
|
|
|
|
-export default class UserService extends Service {
|
|
|
|
|
- private netService = new NetService()
|
|
|
|
|
-
|
|
|
|
|
- private store = useStore()
|
|
|
|
|
-
|
|
|
|
|
- // protected baseUrl = `${import.meta.env.VITE_PROXY_URL}`
|
|
|
|
|
-
|
|
|
|
|
- /** 用户登录接口 */
|
|
|
|
|
- async login(account: string, password: string) {
|
|
|
|
|
- const { code, data, msg } = await this.netService.post('/sys/login', { account, password })
|
|
|
|
|
- if (code !== 200) throw msg
|
|
|
|
|
- this.store.setUserInfo(data)
|
|
|
|
|
- sessionStorage.setItem('token', data.satoken)
|
|
|
|
|
- // 页面跳转
|
|
|
|
|
- window.location.href = '/'
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /** 退出登录 */
|
|
|
|
|
- async loginOut() {
|
|
|
|
|
- sessionStorage.clear()
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|