Skip to content

Commit

Permalink
Fix: router push and check seek
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 committed Nov 7, 2023
1 parent 3d46298 commit e9fceb8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/plugins/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const sync = (cbk: callback): resould => {

const checkSeek = () => {
if (!player || player.option.isLive) return;
player.duration - player.currentTime < 5 &&
player.duration - player.currentTime > 5 &&
cbk["publishStatus"](
ElementMessage.create({
type: ElementMessageType.CHECK_SEEK,
Expand Down
3 changes: 0 additions & 3 deletions src/stores/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { ref, computed } from "vue";
import { defineStore } from "pinia";
import type { MovieInfo, Status } from "@/proto/message";
export const roomStore = defineStore("roomStore", () => {
const login = ref(false);

const isDarkMode = ref(false);

// 影片列表
Expand Down Expand Up @@ -48,7 +46,6 @@ export const roomStore = defineStore("roomStore", () => {

return {
isDarkMode,
login,
movies,
totalMovies,
currentMovie,
Expand Down
11 changes: 6 additions & 5 deletions src/views/Cinema.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, ref, watch, defineAsyncComponent } from "vue";
import type { WatchStopHandle } from "vue";
import { useWebSocket, useWindowSize, useResizeObserver } from "@vueuse/core";
import { useWebSocket, useResizeObserver } from "@vueuse/core";
import { roomStore } from "@/stores/room";
import { ElNotification, ElMessage } from "element-plus";
import router from "@/router";
Expand Down Expand Up @@ -35,16 +35,17 @@ const watchers: WatchStopHandle[] = [];
onBeforeUnmount(() => {
watchers.forEach((w) => w());
});
const { width: WindowWidth } = useWindowSize();
const room = roomStore();
// 检查是否登录
(() => !room.login && router.push("/"))();
const room = roomStore();
// 获取房间信息
const roomID = useRouteParams("roomId");
const roomToken = localStorage.getItem(`room-${roomID.value}-token`) ?? "";
if (roomToken === "") {
router.push(`/joinRoom/${roomID.value}`);
}
// 启动websocket连接
const wsProtocol = location.protocol === "https:" ? "wss:" : "ws:";
const { status, data, send } = useWebSocket(`${wsProtocol}//${window.location.host}/api/room/ws`, {
Expand Down

0 comments on commit e9fceb8

Please sign in to comment.