diff --git a/src/components/Card.vue b/src/components/Card.vue index 03ab4a11..7d3ab72d 100644 --- a/src/components/Card.vue +++ b/src/components/Card.vue @@ -8,7 +8,7 @@ > import { Icon } from "@iconify/vue" +import { forceHttp2 } from "src/logic/forceHttp2" import { useI18n } from "vue-i18n" import Star from "./Star.vue" diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 1a4655de..70c9115d 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -110,7 +110,7 @@
@@ -408,7 +408,7 @@
@@ -553,7 +553,7 @@
{ + test("should use http 1", () => { + expect(forceHttp2("http://example.com/image.png")).toEqual( + "https://example.com/image.png" + ) + }) + test("should use http 2", () => { + expect(forceHttp2("https://example.com/image.png")).toEqual( + "https://example.com/image.png" + ) + }) +}) diff --git a/src/logic/forceHttp2.ts b/src/logic/forceHttp2.ts new file mode 100644 index 00000000..808897d3 --- /dev/null +++ b/src/logic/forceHttp2.ts @@ -0,0 +1,5 @@ +export function forceHttp2(url: string): string { + if (url.startsWith("http://")) return "https" + url.slice(4) + + return url +} diff --git a/src/logic/urlImage.spec.ts b/src/logic/urlImage.spec.ts index 06ae2406..4af7d16c 100644 --- a/src/logic/urlImage.spec.ts +++ b/src/logic/urlImage.spec.ts @@ -35,16 +35,16 @@ describe("urlImage", () => { describe("add host", () => { test("should url is removed host", () => { expect(addHostUrlImage("$@/image.png")).toEqual( - `${location.protocol}//${HOST_CURL}/image.png` + `https://${HOST_CURL}/image.png` ) expect(addHostUrlImage("$@:433/image.png")).toEqual( - `${location.protocol}//${HOST_CURL}:433/image.png` + `https://${HOST_CURL}:433/image.png` ) expect(addHostUrlImage("cdn.$@/image.png")).toEqual( - `${location.protocol}//cdn.${HOST_CURL}/image.png` + `https://cdn.${HOST_CURL}/image.png` ) expect(addHostUrlImage("cdn.$@:433/image.png")).toEqual( - `${location.protocol}//cdn.${HOST_CURL}:433/image.png` + `https://cdn.${HOST_CURL}:433/image.png` ) }) test("should url is not remove host", () => { diff --git a/src/logic/urlImage.ts b/src/logic/urlImage.ts index 5e1f92cb..758e11f2 100644 --- a/src/logic/urlImage.ts +++ b/src/logic/urlImage.ts @@ -11,6 +11,6 @@ export function removeHostUrlImage(url: string): string { export function addHostUrlImage(url: string): string { return url.replace( /^([^/]+.)?\$@(:\d+)?(?=\/)/, - location.protocol + "//$1" + HOST_CURL + "$2" + "https:" + "//$1" + HOST_CURL + "$2" ) } diff --git a/src/pages/index.vue b/src/pages/index.vue index 8b47b86f..37415532 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -88,7 +88,7 @@
@@ -353,12 +353,12 @@ import SkeletonGridCard from "components/SkeletonGridCard.vue" import { Index } from "src/apis/runs/index" import appIcon from "src/assets/app_icon.svg" import dayjs from "src/logic/dayjs" +import { forceHttp2 } from "src/logic/forceHttp2" import { Autoplay, Navigation } from "swiper" import { Swiper, SwiperSlide } from "swiper/vue" import { computed } from "vue" import { useI18n } from "vue-i18n" import { useRouter } from "vue-router" - // Import Swiper styles import "swiper/css" import "swiper/css/pagination" diff --git a/src/pages/news.vue b/src/pages/news.vue index b6fb7bf4..46946292 100644 --- a/src/pages/news.vue +++ b/src/pages/news.vue @@ -108,7 +108,7 @@ @click="open(item.href)" >
- +
@@ -146,6 +146,7 @@ import { Icon } from "@iconify/vue" import { QInfiniteScroll } from "quasar" import { NewsAnime } from "src/apis/runs/news-anime" import dayjs from "src/logic/dayjs" +import { forceHttp2 } from "src/logic/forceHttp2" import { ref, shallowReactive } from "vue" import { useI18n } from "vue-i18n" diff --git a/src/pages/notification.vue b/src/pages/notification.vue index 410e18b5..91aeffe4 100644 --- a/src/pages/notification.vue +++ b/src/pages/notification.vue @@ -47,7 +47,7 @@ import { Icon } from "@iconify/vue" import ScreenLoading from "src/components/ScreenLoading.vue" +import { forceHttp2 } from "src/logic/forceHttp2" import { useAuthStore } from "stores/auth" import { useNotificationStore } from "stores/notification" import { useI18n } from "vue-i18n" import { useRouter } from "vue-router" + const { t } = useI18n() const router = useRouter() const notificationStore = useNotificationStore() diff --git a/src/pages/phim/_season.vue b/src/pages/phim/_season.vue index b8f97bb7..36b4249b 100644 --- a/src/pages/phim/_season.vue +++ b/src/pages/phim/_season.vue @@ -26,7 +26,7 @@ :next-chap="nextChap" :prev-chap="prevChap" :name="data.name" - :poster="currentDataSeason?.poster" + :poster="currentDataSeason?.poster ? forceHttp2(currentDataSeason.poster) : undefined" :seasons="seasons" :_cache-data-seasons="_cacheDataSeasons" :fetch-season="fetchSeason" @@ -317,7 +317,7 @@ v-if="data?.image" width="152px" class="rounded-xl" - :src="data.image" + :src="forceHttp2(data.image)" />
@@ -409,6 +409,7 @@ import { PhimIdChap } from "src/apis/runs/phim/[id]/[chap]" // import BottomSheet from "src/components/BottomSheet.vue" import type { Source } from "src/components/sources" import { C_URL, labelToQuality } from "src/constants" +import { forceHttp2 } from "src/logic/forceHttp2" import { formatView } from "src/logic/formatView" import { fs } from "src/logic/fs" import { getRealSeasonId } from "src/logic/getRealSeasonId" diff --git a/src/pages/playlist/[playlist].vue b/src/pages/playlist/[playlist].vue index 2d205516..6c37ddd4 100644 --- a/src/pages/playlist/[playlist].vue +++ b/src/pages/playlist/[playlist].vue @@ -12,7 +12,7 @@
@@ -356,6 +356,7 @@ import { useHead } from "@vueuse/head" import AddToPlaylist from "components/AddToPlaylist.vue" import { QInfiniteScroll, useQuasar } from "quasar" import dayjs from "src/logic/dayjs" +import { forceHttp2 } from "src/logic/forceHttp2" import { parseChapName } from "src/logic/parseChapName" import { usePlaylistStore } from "stores/playlist" import { computed, ref, watch } from "vue" @@ -363,6 +364,7 @@ import { useI18n } from "vue-i18n" import { useRequest } from "vue-request" import { useRoute, useRouter } from "vue-router" + const { t } = useI18n() const route = useRoute() const router = useRouter() diff --git a/src/pages/tai-khoan/edit-profile.vue b/src/pages/tai-khoan/edit-profile.vue index 7f1d74e6..08c804b3 100644 --- a/src/pages/tai-khoan/edit-profile.vue +++ b/src/pages/tai-khoan/edit-profile.vue @@ -6,7 +6,10 @@
- + { diff --git a/src/pages/tai-khoan/history.vue b/src/pages/tai-khoan/history.vue index c48eaa4d..b943c69d 100644 --- a/src/pages/tai-khoan/history.vue +++ b/src/pages/tai-khoan/history.vue @@ -36,7 +36,7 @@ > @@ -98,6 +98,7 @@ import ScreenError from "components/ScreenError.vue" import ScreenLoading from "components/ScreenLoading.vue" import ScreenNotFound from "components/ScreenNotFound.vue" import { QInfiniteScroll } from "quasar" +import { forceHttp2 } from "src/logic/forceHttp2" import { parseChapName } from "src/logic/parseChapName" import { parseTime } from "src/logic/parseTime" import { useHistoryStore } from "stores/history" @@ -105,6 +106,7 @@ import { computed } from "vue" import { useI18n } from "vue-i18n" import { useRequest } from "vue-request" + const { t } = useI18n() const historyStore = useHistoryStore() diff --git a/src/pages/tai-khoan/index.vue b/src/pages/tai-khoan/index.vue index 8bb8c9ac..cbb4dea7 100644 --- a/src/pages/tai-khoan/index.vue +++ b/src/pages/tai-khoan/index.vue @@ -6,7 +6,10 @@ > - + @@ -330,6 +333,7 @@ import { compressToBase64 } from "lz-string" import QRCode from "qrcode" import { useQuasar } from "quasar" import { TuPhim } from "src/apis/runs/tu-phim" +import { forceHttp2 } from "src/logic/forceHttp2" import { parseChapName } from "src/logic/parseChapName" import { parseTime } from "src/logic/parseTime" import { useAuthStore } from "stores/auth" @@ -340,6 +344,7 @@ import { useRequest } from "vue-request" import { useRouter } from "vue-router" // import QrScanner from "qr-scanner" + const { t } = useI18n() const showDialogLogin = ref(false) const showDialogQR = ref(false)