Bladeren bron

fix: 修改http游戏改为外链打开

Before 7 maanden geleden
bovenliggende
commit
b45915ae58
3 gewijzigde bestanden met toevoegingen van 12 en 4 verwijderingen
  1. 2 2
      src/app/[locale]/(TabBar)/[[...share]]/_home/HomeTabs.tsx
  2. 6 2
      src/components/Card/Card.tsx
  3. 4 0
      src/utils/index.ts

+ 2 - 2
src/app/[locale]/(TabBar)/[[...share]]/_home/HomeTabs.tsx

@@ -153,9 +153,9 @@ const Tabs: FC<Props> = (props) => {
     return (
         <>
             <Box pt={false}>
-                <Swiper slidesPerView={3.5} centeredSlidesBounds>
+                <Swiper slidesPerView={"auto"} centeredSlidesBounds>
                     {tabData?.map((group, index) => (
-                        <SwiperSlide key={index} className={"pt-[0.1389rem]"}>
+                        <SwiperSlide key={index} className={"max-w-fit pt-[0.1389rem]"}>
                             <TabItem
                                 item={group as TabItemType}
                                 active={index === active}

+ 6 - 2
src/components/Card/Card.tsx

@@ -56,8 +56,12 @@ const Card: FC<PropsWithChildren<CardProps>> = (props) => {
                 Toast.clear();
                 if (res.data && res.data.game_url) {
                     const url = `${res.data?.game_url}&brand=${brandRef.current}&return_url=${process.env.NEXT_PUBLIC_SHARE_URL}`;
-                    // window.open(url);
-                    router.push(`/game?${url}`);
+                    const protocol = new URL(url).protocol;
+                    if (protocol === "https:") {
+                        router.push(`/game?${url}`);
+                    } else {
+                        window.open(url);
+                    }
                 } else {
                     Toast.show(tcode("code.500"));
                 }

+ 4 - 0
src/utils/index.ts

@@ -37,6 +37,10 @@ export const isHttpUrl = (url: string) => {
     const regex = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\*\+,;=.]+$/;
     return regex.test(url);
 };
+export const isHttpsUrl = (url: string) => {
+    const regex = /^(?:https?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\*\+,;=.]+$/;
+    return regex.test(url);
+};
 /**
  * @description 是否是合格邮箱
  */