Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat(热门内容): 爆款标题列表开发中
gaoSir0290be8f8cbb
diff --git a/src/app/[lng]/hotContent/components/HotEvent/hotEvent.module.scss b/src/app/[lng]/hotContent/components/HotEvent/hotEvent.module.scssindex 143d45c5..1cdfedf7 100644--- a/src/app/[lng]/hotContent/components/HotEvent/hotEvent.module.scss+++ b/src/app/[lng]/hotContent/components/HotEvent/hotEvent.module.scss@@ -17,37 +17,40 @@line-height: 45px;border-radius: 10px 10px 0 0;}- &-content {- .ant-table-body {- scrollbar-width: none;- &::-webkit-scrollbar {- display: none;- }- }- thead {- .ant-table-cell {- background: #fff;- padding: 8px 10px;- font-weight: 400;- font-size: var(--fs-xs);- color: var(--grayColor7);- border: none;- &:before {- display: none;- }- }- }- tbody {- .ant-table-cell {- padding: 10px;- border: none;- }- tr {- cursor: pointer;- }+ }+ }+}++.hotEvent-item-content {+ :global {+ .ant-table-body {+ scrollbar-width: none;+ &::-webkit-scrollbar {+ display: none;+ }+ }+ thead {+ .ant-table-cell {+ background: #fff !important;+ padding: 8px 10px !important;+ font-weight: 400 !important;+ font-size: var(--fs-xs) !important;+ color: var(--grayColor7) !important;+ border: none !important;+ &:before {+ display: none !important;}}}+ tbody {+ .ant-table-cell {+ padding: 10px !important;+ border: none !important;+ }+ tr {+ cursor: pointer;+ }+ }}}diff --git a/src/app/[lng]/hotContent/components/HotEvent/index.tsx b/src/app/[lng]/hotContent/components/HotEvent/index.tsxindex aa5abc63..7ef00adf 100644--- a/src/app/[lng]/hotContent/components/HotEvent/index.tsx+++ b/src/app/[lng]/hotContent/components/HotEvent/index.tsx@@ -189,7 +189,7 @@ const HotEvent = memo(><Icon component={material[i].icon} /> {platform.name} · 热点</div>- <div className="hotEvent-item-content">+ <div className={styles["hotEvent-item-content"]}><TabledataSource={topics}columns={getColumns(topics)}diff --git a/src/app/[lng]/hotContent/components/HotTitle/components/HotTitleCommons.tsx b/src/app/[lng]/hotContent/components/HotTitle/components/HotTitleCommons.tsxnew file mode 100644index 00000000..d7b2e38d--- /dev/null+++ b/src/app/[lng]/hotContent/components/HotTitle/components/HotTitleCommons.tsx@@ -0,0 +1,60 @@+import { ViralTitle } from "@/api/types/viralTitles";+import styles from "../hotTitle.module.scss";+import HotTitleBackSvg from "../svgs/hotTitleBack.svg";+import Icon from "@ant-design/icons";+import { CSSProperties } from "react";+import { Table, type TableProps } from "antd";+import hotEventStyles from "../../HotEvent/hotEvent.module.scss";+import hotContentStyles from "../../HotContent/hotContent.module.scss";++const columns: TableProps<ViralTitle>["columns"] = [+ {+ title: "排名",+ width: 60,+ render: (text, data, ind) => (+ <>+ {ind <= 2 ? (+ <div+ className={hotContentStyles.rankingTopthree}+ style={{ width: "20px", height: "20px", lineHeight: "20px" }}+ >+ {ind + 1}+ </div>+ ) : (+ <p style={{ width: "20px", textAlign: "center" }}>{ind + 1}</p>+ )}+ </>+ ),+ },+];++export const HotTitleItem = ({+ data,+ style,+}: {+ data: {+ category: string;+ titles: ViralTitle[];+ };+ style?: CSSProperties;+}) => {+ return (+ <div className={styles.hotTitleItem} style={style}>+ <div className="hotTitleItem-head">+ <div className="hotTitleItem-head-name">{data.category}</div>+ <Icon component={HotTitleBackSvg} />+ </div>+ <div+ className={`hotTitleItem-content ${hotEventStyles["hotEvent-item-content"]}`}+ >+ <Table+ dataSource={data.titles}+ columns={columns}+ rowKey={(record) => record._id}+ pagination={false}+ scroll={{ y: 400 }}+ />+ </div>+ </div>+ );+};diff --git a/src/app/[lng]/hotContent/components/HotTitle/hotTitle.module.scss b/src/app/[lng]/hotContent/components/HotTitle/hotTitle.module.scssindex 88cffae7..20033600 100644--- a/src/app/[lng]/hotContent/components/HotTitle/hotTitle.module.scss+++ b/src/app/[lng]/hotContent/components/HotTitle/hotTitle.module.scss@@ -1,3 +1,47 @@.hotTitle {+ display: flex;+ flex-direction: column;+ height: 100%;+ min-height: 0;+ :global {+ .hotTitle-content {+ height: 100%;+ min-height: 0;+ .hotTitle-content-wrapper {+ height: 100%;+ min-height: 0;+ display: flex;+ flex-wrap: wrap;+ justify-content: space-between;+ overflow: auto;+ scrollbar-width: none;+ &::-webkit-scrollbar {+ display: none;+ }+ }+ }+ }+}+.hotTitleItem {+ :global {+ .hotTitleItem-head {+ display: flex;+ align-items: center;+ background-image: linear-gradient(to left, rgba(90,246,242,.1), rgba(254,44,85,.1));+ position: relative;+ padding: 10px 20px;+ border-radius: 10px 10px 0 0;+ font-weight: 500;+ .anticon {+ position: relative;+ left: -20px;+ svg {+ width: 120px;+ }+ }+ }+ .hotTitleItem-content {+ }+ }}\ No newline at end of filediff --git a/src/app/[lng]/hotContent/components/HotTitle/index.tsx b/src/app/[lng]/hotContent/components/HotTitle/index.tsxindex 6bc24fac..0b1a2a73 100644--- a/src/app/[lng]/hotContent/components/HotTitle/index.tsx+++ b/src/app/[lng]/hotContent/components/HotTitle/index.tsx@@ -2,6 +2,8 @@ import {ForwardedRef,forwardRef,memo,+ useCallback,+ useEffect,useMemo,useRef,useState,@@ -9,8 +11,11 @@ import {import styles from "./hotTitle.module.scss";import { useHotContent } from "@/app/[lng]/hotContent/useHotContent";import { useShallow } from "zustand/react/shallow";-import { PlatformRanking } from "@/api/hot";+import { platformApi, PlatformRanking } from "@/api/hot";import HotContentLabel from "@/app/[lng]/hotContent/components/HotContentLabel";+import { Spin } from "antd";+import { ViralTitle } from "@/api/types/viralTitles";+import { HotTitleItem } from "@/app/[lng]/hotContent/components/HotTitle/components/HotTitleCommons";export interface IHotTitleRef {}@@ -39,6 +44,14 @@ const HotTitle = memo(const allDates = useRef(["近7天", "近30天", "近90天"]);// 当前选择的日期范围const [currDate, setCurrDate] = useState(allDates.current[0]);+ const [loading, setLoading] = useState(false);+ // 所有爆款标题前五条数据+ const [allHotTitleData, setAllHotTitleData] = useState<+ {+ category: string;+ titles: ViralTitle[];+ }[]+ >();// 获取当前选中的标签、日期、榜单const selectedLabelInfo = useMemo(() => {@@ -51,9 +64,24 @@ const HotTitle = memo((v) => v.id === currentRankCategory,) ?? {}) as PlatformRanking,labelData: labelData[platId] || [],+ platId,};}, [labelData, rankingData, twoMenuKey, currentRankCategory]);+ // 获取所有爆款数据+ const getAllData = useCallback(async () => {+ const res = await platformApi.findTopByPlatformAndCategories(+ selectedLabelInfo.platId,+ currDate,+ );+ console.log(res);+ setAllHotTitleData(res?.data);+ }, [currDate, selectedLabelInfo.platId]);++ useEffect(() => {+ getAllData();+ }, [twoMenuKey]);+return (<div className={styles.hotTitle}><HotContentLabel@@ -66,12 +94,27 @@ const HotTitle = memo(/><HotContentLabel+ style={{ marginBottom: "15px" }}labels={allDates.current}value={currDate}onChange={(value) => {setCurrDate(value);}}/>++ <Spin wrapperClassName="hotTitle-content" spinning={loading}>+ <div className="hotTitle-content-wrapper">+ {allHotTitleData?.map((v) => {+ return (+ <HotTitleItem+ data={v}+ key={v.category}+ style={{ width: "calc(50% - 15px)", marginBottom: "30px" }}+ />+ );+ })}+ </div>+ </Spin></div>);}),diff --git a/src/app/[lng]/hotContent/components/HotTitle/svgs/hotTitleBack.svg b/src/app/[lng]/hotContent/components/HotTitle/svgs/hotTitleBack.svgnew file mode 100644index 00000000..28fd32e5--- /dev/null+++ b/src/app/[lng]/hotContent/components/HotTitle/svgs/hotTitleBack.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" width="229.711" height="12.999" viewBox="0 0 229.711 12.999" class=" absolute top-[50%] left-0 -translate-y-[50%] z-[0]"><defs><linearGradient id="icon-titleBg_svg__a" x1="0.033" y1="0.5" x2="0.899" y2="0.509" gradientUnits="objectBoundingBox"><stop offset="0" stop-color="#ff2442" stop-opacity="0"></stop><stop offset="0.297" stop-color="#ff3e58"></stop><stop offset="0.473" stop-color="#0bdabb"></stop><stop offset="1" stop-color="#ffbfc8" stop-opacity="0"></stop></linearGradient></defs><path d="M221.9 12 210.78 0h5.526l11.117 12Zm-11.952 0-11.12-12h5.526l11.117 12Zm-11.951 0L186.878 0h5.522l11.12 12Zm-11.952 0L174.926 0h5.526l11.116 12Zm-10.864 0-11.12-12h5.526L180.7 12Zm-11.951 0L152.11 0h5.526l11.117 12Zm-11.952 0-11.12-12h5.526L156.8 12Zm-11.951 0-11.12-12h5.526l11.116 12Zm-10.866 0L117.342 0h5.526l11.116 12Zm-11.951 0L105.39 0h5.526l11.117 12Zm-11.952 0L93.438 0h5.526l11.117 12ZM92.6 12 81.487 0h5.526L98.13 12Zm-10.861 0L70.622 0h5.526l11.117 12Zm-11.951 0L58.672 0H64.2l11.114 12Zm-11.952 0L46.72 0h5.526l11.116 12Zm-11.951 0L34.769 0h5.526l11.117 12Zm-10.866 0L23.9 0h5.526l11.119 12ZM23.07 12 11.953 0h5.526L28.6 12Zm-11.952 0L0 0h5.527l11.117 12Z" transform="translate(1.143 .499)" style="stroke: transparent; stroke-miterlimit: 10; opacity: 0.2; fill: url("#icon-titleBg_svg__a");"></path></svg>\ No newline at end of file