2023-01-15 08:38:02 +00:00
|
|
|
export default defineNuxtPlugin(() => {
|
|
|
|
const { params, query } = useRoute()
|
|
|
|
publicServer.value = params.server as string || useRuntimeConfig().public.defaultServer
|
2022-12-17 16:55:29 +00:00
|
|
|
|
2023-01-15 08:38:02 +00: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-26 19:33:36 +00:00
|
|
|
|
2023-01-15 08:38:02 +00:00
|
|
|
loginTo(masto, user)
|
2022-11-28 09:01:14 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
provide: {
|
2022-12-17 16:55:29 +00:00
|
|
|
masto,
|
2022-11-28 09:01:14 +00:00
|
|
|
},
|
|
|
|
}
|
2022-11-26 15:42:58 +00:00
|
|
|
})
|