|
@@ -1,7 +1,7 @@
|
|
|
"use client";
|
|
|
import { usePathname, useRouter } from "@/i18n";
|
|
|
import clsx from "clsx";
|
|
|
-import { FC, PropsWithChildren, ReactNode } from "react";
|
|
|
+import { FC, PropsWithChildren, ReactNode, useEffect, useState } from "react";
|
|
|
import "./style.scss";
|
|
|
import { useGlobalStore } from "@/stores";
|
|
|
|
|
@@ -36,7 +36,7 @@ const Footer: FC<PropsWithChildren> = () => {
|
|
|
{
|
|
|
iconSpanName: "icon-tiyu",
|
|
|
label: "Esportes",
|
|
|
- path: "/",
|
|
|
+ path: "/sports",
|
|
|
},
|
|
|
{
|
|
|
iconSpanName: "icon-yonghu",
|
|
@@ -46,13 +46,20 @@ const Footer: FC<PropsWithChildren> = () => {
|
|
|
];
|
|
|
|
|
|
const pathname = usePathname();
|
|
|
+ const [tabActiveName, setTabActiveName] = useState('/')
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ setTabActiveName(pathname)
|
|
|
+ }, [pathname])
|
|
|
|
|
|
const router = useRouter();
|
|
|
+
|
|
|
const goPage = (path = "/") => {
|
|
|
if(!token && (path == '/deposit' || path == "/profile")) {
|
|
|
- router.replace(`/login?redirect=${path}`)
|
|
|
+ router.push(`/login?redirect=${path}`)
|
|
|
return
|
|
|
}
|
|
|
+ setTabActiveName(path)
|
|
|
router.push(path);
|
|
|
};
|
|
|
|
|
@@ -62,7 +69,7 @@ const Footer: FC<PropsWithChildren> = () => {
|
|
|
{tabList.map((item, index) => {
|
|
|
return (
|
|
|
<li
|
|
|
- className={clsx(item.path == pathname && "active")}
|
|
|
+ className={clsx(item.path == tabActiveName && "active")}
|
|
|
onClick={() => goPage(item.path)}
|
|
|
key={index}
|
|
|
>
|