1
0
mirror of https://github.com/elk-zone/elk synced 2024-11-27 14:28:10 +09:00
elk/plugins/masto.ts

22 lines
578 B
TypeScript
Raw Normal View History

2023-01-15 17:38:02 +09:00
export default defineNuxtPlugin(() => {
const { params, query } = useRoute()
publicServer.value = params.server as string || useRuntimeConfig().public.defaultServer
2023-01-15 17:38:02 +09:00
const masto = createMasto()
const user = typeof query.server === 'string' && typeof query.token === 'string'
? {
server: query.server,
token: query.token,
vapidKey: typeof query.vapid_key === 'string' ? query.vapid_key : undefined,
}
: currentUser.value || { server: publicServer.value }
2022-11-27 04:33:36 +09:00
2023-01-15 17:38:02 +09:00
loginTo(masto, user)
return {
provide: {
masto,
},
}
})