import {ref} from 'vue' import {createGlobalState,useStorage} from '@vueuse/core' import {sendCode} from '@/api/auth/index.js' import {message} from "@/utils/message.js" export const useAuth=createGlobalState(()=>{ const token = useStorage('token', '', localStorage) const telNum =ref('') const code=ref('') const clickSendCode=async ()=>{ if (!telNum.value){ message.warning('请输入手机号') return } const data={ telNum:telNum.value } const res=await sendCode(data) if (res.status===0){ message.success('发送成功') } } return { code, clickSendCode, telNum, token } })