You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
759 B
42 lines
759 B
import { Ref } from 'vue'
|
|
|
|
export enum LoginStateEnum {
|
|
LOGIN,
|
|
REGISTER,
|
|
RESET_PASSWORD,
|
|
MOBILE,
|
|
QR_CODE,
|
|
SSO
|
|
}
|
|
|
|
const currentState = ref(LoginStateEnum.LOGIN)
|
|
|
|
export function useLoginState() {
|
|
function setLoginState(state: LoginStateEnum) {
|
|
currentState.value = state
|
|
}
|
|
const getLoginState = computed(() => currentState.value)
|
|
|
|
function handleBackLogin() {
|
|
setLoginState(LoginStateEnum.LOGIN)
|
|
}
|
|
|
|
return {
|
|
setLoginState,
|
|
getLoginState,
|
|
handleBackLogin
|
|
}
|
|
}
|
|
|
|
export function useFormValid<T extends Object = any>(formRef: Ref<any>) {
|
|
async function validForm() {
|
|
const form = unref(formRef)
|
|
if (!form) return
|
|
const data = await form.validate()
|
|
return data as T
|
|
}
|
|
|
|
return {
|
|
validForm
|
|
}
|
|
}
|
|
|