feat: 实现官网与设备用户界面
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import { api, type Me } from '../api'
|
||||
|
||||
export const useSession = defineStore('session', () => {
|
||||
const me = ref<Me | null>(null)
|
||||
const ready = ref(false)
|
||||
|
||||
async function refresh() {
|
||||
try {
|
||||
me.value = await api.me()
|
||||
} catch {
|
||||
me.value = null
|
||||
} finally {
|
||||
ready.value = true
|
||||
}
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
await api.logout()
|
||||
me.value = null
|
||||
}
|
||||
|
||||
return { me, ready, refresh, logout }
|
||||
})
|
||||
Reference in New Issue
Block a user