|
@@ -3,14 +3,12 @@ import { useMainStore } from "@/stores/main";
|
|
|
import { storeToRefs } from "pinia";
|
|
|
import { onMounted } from "vue";
|
|
|
import { useI18n } from "vue-i18n";
|
|
|
-import { wsUrl } from "@/env";
|
|
|
|
|
|
const { t } = useI18n();
|
|
|
-const WS = new WebSocket(`${wsUrl}/api/v1/videos`);
|
|
|
-
|
|
|
const mainStore = useMainStore();
|
|
|
const mainStoreRef = storeToRefs(mainStore);
|
|
|
const videos = mainStoreRef.readVideos;
|
|
|
+const WS = mainStore.videosWebSocket;
|
|
|
|
|
|
const headers = [
|
|
|
{
|
|
@@ -38,14 +36,19 @@ function previewVideo(name: String) {
|
|
|
onMounted(async () => {
|
|
|
await mainStore.actionGetVideos();
|
|
|
WS.onmessage = function (e) {
|
|
|
+ console.log('onmessage',e);
|
|
|
const data = e.data.split(':');
|
|
|
mainStore.videos.map(e=>{
|
|
|
if(e.stored_filename===data[0]) {
|
|
|
- e.progress_state = data[1];
|
|
|
+ e.progress_state = data[1]; // 影片狀態
|
|
|
+ if (mainStore.userProfile && data[2]) {
|
|
|
+ mainStore.userProfile.available_time = mainStore.userProfile.available_time - parseInt(data[2]); // 使用秒數
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
};
|
|
|
});
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<template>
|