Add doube void for error handeling

This commit is contained in:
Hepatica
2024-03-23 17:43:33 +01:00
parent 63d8066e18
commit 067b47de06

View File

@@ -40,7 +40,7 @@
</div> </div>
</template> </template>
<script> <script>
import { reactive, ref, onMounted } from 'vue' import { reactive, ref, onMounted } from "vue";
import AsideBarComponent from "@/components/AsidebarComponent.vue"; import AsideBarComponent from "@/components/AsidebarComponent.vue";
import HeaderComponent from "@/components/HeaderComponent.vue"; import HeaderComponent from "@/components/HeaderComponent.vue";
@@ -87,50 +87,49 @@ export default {
img: require("@/assets/icons-games/double-game/RectangleBlackDouble.png"), img: require("@/assets/icons-games/double-game/RectangleBlackDouble.png"),
target: "Red", target: "Red",
}, },
]) ]);
let autoPlay = ref(0) let autoPlay = ref(0);
let targetColor = ref('') let targetColor = ref("");
onMounted(() => { onMounted(() => {
eventBus.on('doubleGame', (dataDouble) => { eventBus.on("doubleGame", (dataDouble) => {
console.log('data mounted') console.log("data mounted");
const dataDoubleParse = JSON.parse(dataDouble) const dataDoubleParse = JSON.parse(dataDouble);
console.log(dataDoubleParse) console.log(dataDoubleParse);
if (dataDoubleParse.Status === 'InGame') { if (dataDoubleParse.Status === "InGame") {
autoPlay.value = 500 autoPlay.value = 500;
targetColor.value = dataDoubleParse.WInColor targetColor.value = dataDoubleParse.WInColor;
console.log('213') console.log("213");
} }
// else if (dataDoubleParse.Status === 'GameEnd') { // else if (dataDoubleParse.Status === 'GameEnd') {
// targetColor.value = dataDoubleParse.WInColor // targetColor.value = dataDoubleParse.WInColor
// } // }
}) });
}) });
function handleStepCarousel(data) { function handleStepCarousel(data) {
try { try {
if (targetColor.value !== '') { if (targetColor.value !== "") {
let { currentSlideIndex } = data let { currentSlideIndex } = data;
console.log(slides[currentSlideIndex].target == targetColor.value) console.log(slides[currentSlideIndex].target == targetColor.value);
if (slides[currentSlideIndex + 1].target == targetColor.value) { if (slides[currentSlideIndex + 1].target == targetColor.value) {
stopAutoPlay() stopAutoPlay();
} }
} }
} } catch (error) {
catch (error) { void(error);
console.error(error)
} }
} }
function stopAutoPlay() { function stopAutoPlay() {
autoPlay.value = 0 autoPlay.value = 0;
} }
return { slides, autoPlay, handleStepCarousel, stopAutoPlay, targetColor } return { slides, autoPlay, handleStepCarousel, stopAutoPlay, targetColor };
}, },
} };
</script> </script>
<style scoped> <style scoped>