refactor: update composable names

This commit is contained in:
Anthony Fu 2022-11-18 05:32:03 +08:00
parent 787a55bea7
commit 4fc6e405e0
9 changed files with 46 additions and 34 deletions

View file

@ -5,7 +5,8 @@ export default defineNuxtPlugin((nuxt) => {
const masto = login({
url: `https://${server.value}`,
accessToken: token.value,
accessToken: token.value || undefined,
})
nuxt.vueApp.provide('masto', masto)
nuxt.$masto = masto
})

View file

@ -1,10 +1,12 @@
import { login as loginMasto } from 'masto'
import type { UserLogin } from '~/types'
function createStore() {
function createClientState() {
const { server, token } = useAppCookies()
const accounts = useLocalStorage<UserLogin[]>('nuxtodon-accounts', [], { deep: true })
const currentId = useLocalStorage<string>('nuxtodon-current-user', '')
const currentUser = computed<UserLogin | undefined>(() => {
let user: UserLogin | undefined
if (currentId.value) {
@ -48,8 +50,8 @@ function createStore() {
}
}
export type AppStore = ReturnType<typeof createStore>
export type ClientState = ReturnType<typeof createClientState>
export default defineNuxtPlugin((nuxt) => {
nuxt.vueApp.provide('app-store', createStore())
nuxt.$clientState = createClientState()
})