before store
This commit is contained in:
21
src/stores/auth.ts
Normal file
21
src/stores/auth.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import { api } from 'boot/axios'
|
||||
import type { WebApp } from '@twa-dev/types'
|
||||
|
||||
export const useAuthStore = defineStore('auth', () => {
|
||||
const isInit = ref(false)
|
||||
const telegramUserData = ref()
|
||||
|
||||
async function init (tg: WebApp) {
|
||||
await api.post('/auth?' + tg?.initData)
|
||||
telegramUserData.value = tg?.initDataUnsafe.user
|
||||
isInit.value = true
|
||||
}
|
||||
|
||||
return {
|
||||
isInit,
|
||||
telegramUserData,
|
||||
init
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user