Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Room list #9

Merged
merged 11 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 30 additions & 25 deletions src/pages/RoomList.vue
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
<script setup lang="ts">
import { ref } from 'vue'
import { onMounted, ref } from 'vue'
import api, { GetRoomsInner } from '@/lib/apis'

defineProps<{ msg: string }>()

const count = ref(0)
const rooms = ref<GetRoomsInner[]>([])
onMounted(async () => {
const res = await api.apiRoomsGet()
rooms.value = res.data
})
</script>

<template>
<h1>{{ msg }}</h1>

<div class="card">
<button type="button" @click="count++">count is {{ count }}</button>
<p>
Edit
<code>components/HelloWorld.vue</code> to test HMR
</p>
<div>
<div v-for="room in rooms" :key="room.roomId">
<div
v-if="room.roomId && typeof room.isPublic == 'boolean'"
class="roomListForms"
>
<!-- 下のpathは選択した部屋に入るページに飛ぶようにする -->
<button
@click="
() => {
$router.push({ path: '/rooms/' + room.roomId + '/enter' })
}
"
>
<div v-if="room.isPublic">フリールーム</div>
<div v-if="!room.isPublic">プライベートルーム</div>
{{ room.roomName }}, {{ room.userCount }}人参加中
</button>
</div>
</div>
</div>

<p>
Check out
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
>create-vue</a
>, the official Vue + Vite starter
</p>
<p>
Install
<a href="https://github.com/vuejs/language-tools" target="_blank">Volar</a>
in your IDE for a better DX
</p>
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
</template>

<style scoped>
.read-the-docs {
color: #888;
}
.roomListForms {
margin: 10px;
}
</style>
8 changes: 8 additions & 0 deletions src/stores/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineStore } from 'pinia'

export const useStoreUser = defineStore('user', {
state: () => ({
userName: '',
userId: '',
}),
})
Loading