From 38003935a2d2a31e62be415eb2c58334196f8ffd Mon Sep 17 00:00:00 2001 From: Tachibana Shin Date: Mon, 24 Apr 2023 15:58:33 +0700 Subject: [PATCH] fix deep value not sync --- src/pages/phim/_season.vue | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/pages/phim/_season.vue b/src/pages/phim/_season.vue index 8723c840..85df75e1 100644 --- a/src/pages/phim/_season.vue +++ b/src/pages/phim/_season.vue @@ -877,11 +877,16 @@ watchEffect(() => { }) // TOOD: check chapName in url is chapName watchEffect(() => { - if (!currentMetaChap.value) return + const chaps = currentDataSeason.value?.chaps + if (!chaps) return + + const { chap: epId } = route.params + + const metaEp = epId ? chaps.find((item) => item.id === epId) : chaps[0] + if (!metaEp) return - if (!route.params.chap) return // this first chap not need - const correctChapName = parseChapName(currentMetaChap.value.name) + const correctChapName = parseChapName(metaEp.name) const urlChapName = route.params.chapName if (urlChapName) { @@ -892,7 +897,7 @@ watchEffect(() => { `chapName wrong current: "${urlChapName}" not equal real: ${correctChapName}.\nAuto edit url to chapName correct` ) router.replace({ - path: `/phim/${route.params.season}/${correctChapName}-${route.params.chap}`, + path: `/phim/${route.params.season}/${correctChapName}-${epId}`, query: route.query, hash: route.hash, }) @@ -901,7 +906,7 @@ watchEffect(() => { // replace console.info("this url old type redirect to new type url") router.replace({ - path: `/phim/${route.params.season}/${correctChapName}-${route.params.chap}`, + path: `/phim/${route.params.season}/${correctChapName}-${epId}`, query: route.query, hash: route.hash, })