Skip to content

Commit

Permalink
fix: 해쉬라우터 사용
Browse files Browse the repository at this point in the history
  • Loading branch information
arkk200 committed Jan 20, 2024
1 parent a724abb commit c8258d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { store } from "@src/stores";
import { createRouter, createWebHistory } from "vue-router";
import { createRouter, createWebHashHistory } from "vue-router";

const router = createRouter({
history: createWebHistory(),
history: createWebHashHistory("PIXEL/"),
routes: [
{ path: "/PIXEL/", name: "main", component: () => import("./main.vue") },
{ path: "/", name: "main", component: () => import("./main.vue") },
{
path: "/PIXEL/play",
path: "/play",
name: "play",
component: () => import("./play.vue"),
beforeEnter: (_, __, next) => (store.state.isInGame ? next() : next("/")),
},
{
path: "/PIXEL/room",
path: "/room",
name: "room",
component: () => import("./room.vue"),
beforeEnter: (_, __, next) => (store.state.isInRoom ? next() : next("/")),
},
{
path: "/PIXEL/join/:roomID",
path: "/join/:roomID",
name: "join",
component: () => import("./join.vue"),
},
Expand Down
8 changes: 4 additions & 4 deletions src/socket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ socket.on("createRoom", (roomData) => {
store.state.roomData = roomData;
store.state.isInRoom = true;

router.push("/PIXEL/room");
router.push("/room");
});

socket.on("joinRoom", (roomData) => {
store.state.roomData = roomData;
store.state.isInRoom = true;

router.push("/PIXEL/room");
router.push("/room");
});

socket.on("updateRoom", ({ playerList }) => {
Expand All @@ -30,15 +30,15 @@ socket.on("updateRoom", ({ playerList }) => {
socket.on("startGame", (gameData) => {
store.state.isInGame = true;
store.state.gameData = gameData;
router.push("/PIXEL/play");
router.push("/play");
});

socket.on("updateGame", (gameData) => {
store.state.gameData = gameData;
});

socket.on("gameOver:disconnecting", () => {
router.push("/PIXEL/").then(() => {
router.push("/").then(() => {
store.state.isInGame = false;

toast.warning("누군가가 게임을 떠났습니다");
Expand Down

0 comments on commit c8258d4

Please sign in to comment.