Initial working translator implementation

This commit is contained in:
burnintuna 2026-07-30 14:53:36 +09:00
commit 9439858b11
35 changed files with 5365 additions and 0 deletions

View file

@ -0,0 +1,30 @@
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import { me as apiMe, logout as apiLogout } from '../api'
export const useAuthStore = defineStore('auth', () => {
const user_id = ref<string | null>(null)
const loaded = ref(false)
const isLoggedIn = computed(() => !!user_id.value && loaded.value)
async function check() {
if (loaded.value) return
try {
const data = await apiMe()
user_id.value = data.user_id
} catch {
user_id.value = null
} finally {
loaded.value = true
}
}
async function logout() {
await apiLogout()
user_id.value = null
window.location.hash = '#/login'
}
return { user_id, loaded, isLoggedIn, check, logout }
})