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