Browse Source

根据lint调整代码

zhangzf 6 days ago
parent
commit
a74d7a75c0

+ 11 - 11
src/app/(public)/category/[slug]/_components/FaqList.tsx

@@ -42,17 +42,17 @@ function FaqAccordionItem({
   );
 
   // 点赞爱心SVG提取
-  const LikeIcon = (
-    <svg
-      xmlns="http://www.w3.org/2000/svg"
-      width="16"
-      height="16"
-      fill="currentColor"
-      viewBox="0 0 16 16"
-    >
-      <path d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z" />
-    </svg>
-  );
+  // const LikeIcon = (
+  //   <svg
+  //     xmlns="http://www.w3.org/2000/svg"
+  //     width="16"
+  //     height="16"
+  //     fill="currentColor"
+  //     viewBox="0 0 16 16"
+  //   >
+  //     <path d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z" />
+  //   </svg>
+  // );
 
   return (
     <div className="border border-gray-100 rounded-lg bg-[#F9F9F9] p-4 mb-3">

+ 10 - 1
src/components/layout/navbar/NavbarSearchIcon.tsx

@@ -1,8 +1,17 @@
 "use client";
-import { useState } from "react";
+import { useState,useEffect } from "react";
 import SearchPop from "./SearchPop";
+import { usePathname } from "next/navigation";
 export default function NavbarSearchIcon() {
   const [searchOpen, setSearchOpen] = useState(false);
+    const pathname = usePathname();
+  useEffect(() => {
+    if (searchOpen) {
+      queueMicrotask(() => {
+        setSearchOpen(false);
+      });
+    }
+  }, [pathname, searchOpen]);
   return (
     <>
       <div

+ 8 - 8
src/components/layout/navbar/SearchPop.tsx

@@ -6,7 +6,7 @@ import Grid from "@/components/theme/ui/grid/Grid";
 import HotSearch from "@/app/(public)/search/_components/HotSearch"
 import { useMediaQuery } from "@utils/hooks/useMediaQueryHook";
 import Link from "next/link";
-import { usePathname } from "next/navigation";
+// import { usePathname } from "next/navigation";
 // const ProductGridItems = dynamicImport(
 //   () => import("@/components/catalog/product/ProductGridItems"),
 // );
@@ -25,13 +25,13 @@ export default function SearchPop({ open, onClose }: SearchPopProps) {
 
   const products = data?.edges?.map((e) => e.node) || [];
   const isDesktop = useMediaQuery("(min-width: 1024px)");
-    const pathname = usePathname();
-  useEffect(() => {
-    // 打开状态下,路由变化就关闭弹窗
-    if (open) {
-      handleClose();
-    }
-  }, [pathname]);
+  //   const pathname = usePathname();
+  // useEffect(() => {
+  //   // 打开状态下,路由变化就关闭弹窗
+  //   if (open) {
+  //     handleClose();
+  //   }
+  // }, [pathname]);
   // 执行搜索接口
   const triggerSearch = async (searchWord: string) => {
     if (!searchWord.trim()) return;