Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat(热门内容): 热门专题顶部添加平台过滤条件
gaoSir30d1648670dd
diff --git a/src/app/[lng]/hotContent/components/HotContentLabel/hotContentLabel.module.scss b/src/app/[lng]/hotContent/components/HotContentLabel/hotContentLabel.module.scssindex 4493c80f..686d5ade 100644--- a/src/app/[lng]/hotContent/components/HotContentLabel/hotContentLabel.module.scss+++ b/src/app/[lng]/hotContent/components/HotContentLabel/hotContentLabel.module.scss@@ -9,10 +9,18 @@padding-right: 35px;.hotContentLabel-item {+ display: flex;+ align-items: center;cursor: pointer;padding: 4px 8px;border-radius: 6px;+ .hotContentLabel-icon {+ width: 18px;+ border-radius: 3px;+ margin-right: 4px;+ }+&--active {background: var(--colorPrimary1);color: var(--colorPrimary5);diff --git a/src/app/[lng]/hotContent/components/HotContentLabel/index.tsx b/src/app/[lng]/hotContent/components/HotContentLabel/index.tsxindex 0245252e..9f1270cb 100644--- a/src/app/[lng]/hotContent/components/HotContentLabel/index.tsx+++ b/src/app/[lng]/hotContent/components/HotContentLabel/index.tsx@@ -5,6 +5,7 @@ import {useRef,useState,useLayoutEffect,+ CSSProperties,} from "react";import styles from "./hotContentLabel.module.scss";@@ -12,14 +13,16 @@ export interface IHotContentLabelRef {}export interface IHotContentLabelProps {labels: string[];+ icons?: string[];value: string;onChange: (label: string) => void;+ style?: CSSProperties;}const HotContentLabel = memo(forwardRef((- { labels, value, onChange }: IHotContentLabelProps,+ { labels, value, onChange, style, icons }: IHotContentLabelProps,ref: ForwardedRef<IHotContentLabelRef>,) => {const listRef = useRef<HTMLUListElement>(null);@@ -42,7 +45,7 @@ const HotContentLabel = memo(}, [labels]);return (- <div className={styles.hotContentLabelWrapper}>+ <div className={styles.hotContentLabelWrapper} style={style}><ulclassName="hotContentLabel"ref={listRef}@@ -52,7 +55,7 @@ const HotContentLabel = memo(transition: "max-height 0.3s cubic-bezier(0.4,0,0.2,1)",}}>- {labels.map((label) => (+ {labels.map((label, i) => (<likey={label}className={`hotContentLabel-item ${@@ -61,6 +64,13 @@ const HotContentLabel = memo(title={label}onClick={() => onChange(label)}>+ {icons && icons[i] && (+ <img+ src={icons[i]}+ alt={label}+ className="hotContentLabel-icon"+ />+ )}{label}</li>))}diff --git a/src/app/[lng]/hotContent/components/HotFeatures/index.tsx b/src/app/[lng]/hotContent/components/HotFeatures/index.tsxindex 423ededd..5f737ca6 100644--- a/src/app/[lng]/hotContent/components/HotFeatures/index.tsx+++ b/src/app/[lng]/hotContent/components/HotFeatures/index.tsx@@ -1,24 +1,49 @@-import { ForwardedRef, forwardRef, memo, useRef, useState } from "react";+import { ForwardedRef, forwardRef, memo, useEffect, useRef, useState } from "react";import styles from "./hotFeatures.module.scss";import HotContentLabel from "@/app/[lng]/hotContent/components/HotContentLabel";+import { useHotContent } from "@/app/[lng]/hotContent/useHotContent";+import { useShallow } from "zustand/react/shallow";export interface IHotFeaturesRef {}export interface IHotFeaturesProps {}+const NEXT_PUBLIC_YIKA_OSS_HOST = process.env.NEXT_PUBLIC_YIKA_OSS_HOST;+const HotFeatures = memo(forwardRef(({}: IHotFeaturesProps, ref: ForwardedRef<IHotFeaturesRef>) => {+ const { hotContentPlatformList } = useHotContent(+ useShallow((state) => ({+ hotContentPlatformList: state.hotContentPlatformList,+ })),+ );const allDates = useRef(["近3天", "近7天", "近15天", "近30天"]);// 当前选择的日期范围- const [currDate, setCurrDate] = useState("");+ const [currDate, setCurrDate] = useState(allDates.current[2]);// 当前选择的平台const [currPlat, setCurrPlat] = useState("");// 当前选择的分类const [labelValue, setLabelValue] = useState("");+ useEffect(() => {+ setCurrPlat(hotContentPlatformList[0]?.name || "");+ }, [hotContentPlatformList]);+return (<div className={styles.hotFeatures}><HotContentLabel+ style={{ marginBottom: "15px" }}+ labels={hotContentPlatformList.map((v) => v.name)}+ icons={hotContentPlatformList.map(+ (v) => `${NEXT_PUBLIC_YIKA_OSS_HOST}/${v.icon}`,+ )}+ value={currPlat}+ onChange={(value) => {+ setCurrDate(value);+ }}+ />+ <HotContentLabel+ style={{ marginBottom: "15px" }}labels={["AI教程","AI绘画",@@ -36,7 +61,6 @@ const HotFeatures = memo(}}}/>-<HotContentLabellabels={allDates.current}value={currDate}