first commit
CI / Type-check & Build (push) Failing after 5m50s
CI / Build & Push image (push) Skipped

This commit is contained in:
ysj7705 committed 2026-08-12 15:01:43 +09:00
commit 69b647145f
58 files changed
+15796

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
import { useLocalStorage } from '@vueuse/core'
export function useRoomAccess(roomId: MaybeRefOrGetter<string>) {
const storageKey = computed(() => `sejong.roomAccess.${toValue(roomId)}`)
const accessToken = useLocalStorage(storageKey, '')
async function requestAccess(options: {
clientId: string
password?: string
accessToken?: string
}) {
const id = toValue(roomId)
const res = await $fetch<{ accessToken: string; room: { id: string; name: string } }>(
`/api/rooms/${id}/access`,
{
method: 'POST',
body: {
clientId: options.clientId,
password: options.password,
accessToken: options.accessToken || accessToken.value || undefined,
},
},
)
accessToken.value = res.accessToken
return res
}
function clearAccess() {
accessToken.value = ''
}
return { accessToken, requestAccess, clearAccess }
}