Skip to content

Commit

Permalink
auto fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Rozelin-dc committed Jun 15, 2024
1 parent f6a8e07 commit 27bf5a8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 48 deletions.
2 changes: 1 addition & 1 deletion src/lib/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const api = new Apis(
import.meta.env.MODE === 'production'
? 'https://trap.show/h24s_19_server'
: 'http://localhost:3000',
})
}),
)

export default api
Expand Down
81 changes: 35 additions & 46 deletions src/pages/CreateRoom.vue
Original file line number Diff line number Diff line change
@@ -1,66 +1,59 @@
<script setup lang="ts">
import { ref } from 'vue'
import api, {PostRoom} from '@/lib/apis'
import router from '@/router';
import api, { PostRoom } from '@/lib/apis'
import router from '@/router'
// 部屋を作る
// 必須: 部屋の名前, open/private 選択
// private -> passwordも必要
const isPublic=ref(true)
const newRoomName=ref('')
const roomPassword=ref('')
const errorMsg=ref('')
const isPublic = ref(true)
const newRoomName = ref('')
const roomPassword = ref('')
const errorMsg = ref('')
const submit = async ()=> {
if(newRoomName.value==''){
errorMsg.value="部屋名を設定してください"
}else if(!isPublic.value && !roomPassword.value){
errorMsg.value="合言葉を設定してください"
}else{
const submit = async () => {
if (newRoomName.value == '') {
errorMsg.value = '部屋名を設定してください'
} else if (!isPublic.value && !roomPassword.value) {
errorMsg.value = '合言葉を設定してください'
} else {
// 全ての設定がOK
errorMsg.value=''
const roomInfo:PostRoom={
"isPublic": isPublic.value,
"roomName": newRoomName.value,
"password": roomPassword.value
errorMsg.value = ''
const roomInfo: PostRoom = {
isPublic: isPublic.value,
roomName: newRoomName.value,
password: roomPassword.value,
}
try{
try {
const resp = await api.apiRoomPost(roomInfo)
const roomId = resp.data.roomId
router.push(
{path: `/rooms/${roomId}`,query: {password:roomPassword.value}}
)
}catch(e){
router.push({
path: `/rooms/${roomId}`,
query: { password: roomPassword.value },
})
} catch (e) {
console.error(e)
}
}
}
</script>

<template>
<h1 id="title">
部屋を作る
</h1>
<label> 部屋を全体公開する
<input
v-model="isPublic"
type="checkbox"
>
<h1 id="title">部屋を作る</h1>
<label>
部屋を全体公開する
<input v-model="isPublic" type="checkbox" />
</label>
<label>
<p>部屋名
<input
v-model="newRoomName"
type="text"
>
<p>
部屋名
<input v-model="newRoomName" type="text" />
</p>
</label>
<label v-if="!isPublic">
<p>合言葉
<input
v-model="roomPassword"
type="text"
>
<p>
合言葉
<input v-model="roomPassword" type="text" />
</p>
</label>
<div>
Expand All @@ -71,13 +64,9 @@ const submit = async ()=> {
<span v-if="isPublic">する</span>
<span v-else>しない</span>
</p>
<p v-if="!isPublic">
合言葉: {{ roomPassword }}
</p>
<p v-if="!isPublic">合言葉: {{ roomPassword }}</p>
</div>
<button @click="submit()">
作成する
</button>
<button @click="submit()">作成する</button>
<div class="err">
{{ errorMsg }}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const routes: RouteRecordRaw[] = [
path: '/:pathMatch(.*)*',
name: 'NotFound',
component: () => import('@/pages/NotFound.vue'),
}
},
]

const router = createRouter({
Expand Down

0 comments on commit 27bf5a8

Please sign in to comment.