mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
nothing
This commit is contained in:
@@ -1,20 +1,43 @@
|
||||
import QueryAPI from '@/api/query'
|
||||
import { BASE_API } from '@/data/constants'
|
||||
import { APIRoot } from './api-models'
|
||||
import { QueryPostAPI } from '@/api/query'
|
||||
import { UserInfo } from '@/api/api-models'
|
||||
import { ref } from 'vue'
|
||||
import { useCookies } from '@vueuse/integrations/useCookies'
|
||||
|
||||
const ACCOUNT_URL = `${BASE_API}account/`
|
||||
export const ACCOUNT = ref<UserInfo>()
|
||||
|
||||
export async function Register(name: string, email: string, password: string): Promise<APIRoot<string>> {
|
||||
return QueryAPI<string>(`${ACCOUNT_URL}register`, {
|
||||
const cookies = useCookies()
|
||||
|
||||
export async function GetSelfAccount() {
|
||||
const cookie = cookies.get('VTSURU_SESSION')
|
||||
if (cookie) {
|
||||
const result = await Self()
|
||||
if (result.code == 200) {
|
||||
ACCOUNT.value = result.data
|
||||
}
|
||||
}
|
||||
}
|
||||
export function useAccount() {
|
||||
return ACCOUNT
|
||||
}
|
||||
|
||||
export async function Register(name: string, email: string, password: string, token: string): Promise<APIRoot<string>> {
|
||||
return QueryPostAPI<string>(`${ACCOUNT_URL}register`, {
|
||||
name,
|
||||
email,
|
||||
password,
|
||||
token,
|
||||
})
|
||||
}
|
||||
|
||||
export async function Login(nameOrEmail: string, password: string): Promise<APIRoot<string>> {
|
||||
return QueryAPI<string>(`${ACCOUNT_URL}login`, {
|
||||
return QueryPostAPI<string>(`${ACCOUNT_URL}login`, {
|
||||
nameOrEmail,
|
||||
password,
|
||||
})
|
||||
}
|
||||
export async function Self(): Promise<APIRoot<UserInfo>> {
|
||||
return QueryPostAPI<UserInfo>(`${ACCOUNT_URL}self`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user