Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat(热门内容): 热门内容抽出通用组件
gaoSir078991d3ed7f
diff --git a/src/app/[lng]/hotContent/components/HotContent/hotContent.module.scss b/src/app/[lng]/hotContent/components/HotContent/hotContent.module.scssindex 375f1e15..7d49ba51 100644--- a/src/app/[lng]/hotContent/components/HotContent/hotContent.module.scss+++ b/src/app/[lng]/hotContent/components/HotContent/hotContent.module.scss@@ -61,47 +61,6 @@overflow: visible !important;}- .hotContent-table {- height: 100%;- box-sizing: border-box;- overflow: auto;- margin-top: 15px;- position: relative;- @include table-flex-container-with-selectors;-- scrollbar-width: none;- &::-webkit-scrollbar {- display: none;- }-- thead {- position: sticky;- top: 0;- z-index: 10;- .ant-table-cell {- background: rgba(237, 242, 242);- padding: 10px 16px;- font-weight: 400 !important;-- &:last-of-type {- border-bottom-right-radius: 8px;- }- &:first-of-type {- border-bottom-left-radius: 8px;- }- }- }-- tbody {- .ant-table-cell {- padding: 10px;- }- tr {- cursor: pointer;- }- }- }-.ant-spin-container, .ant-spin-nested-loading {height: 100%;min-height: 0;@@ -175,6 +134,49 @@}}+.hotContent-table {+ height: 100%;+ box-sizing: border-box;+ overflow: auto;+ margin-top: 15px;+ position: relative;+ @include table-flex-container-with-selectors;++ scrollbar-width: none;+ &::-webkit-scrollbar {+ display: none;+ }++ :global {+ .ant-table-thead {+ position: sticky;+ top: 0;+ z-index: 10;+ .ant-table-cell {+ background: rgba(237, 242, 242);+ padding: 10px 16px;+ font-weight: 400 !important;++ &:last-of-type {+ border-bottom-right-radius: 8px;+ }+ &:first-of-type {+ border-bottom-left-radius: 8px;+ }+ }+ }++ .ant-table-tbody {+ .ant-table-cell {+ padding: 10px;+ }+ tr {+ cursor: pointer;+ }+ }+ }+}+.anaAddCall {display: flex;flex-direction: column;diff --git a/src/app/[lng]/hotContent/components/HotContent/hotContentCommonWidget.tsx b/src/app/[lng]/hotContent/components/HotContent/hotContentCommonWidget.tsxnew file mode 100644index 00000000..d9523ae5--- /dev/null+++ b/src/app/[lng]/hotContent/components/HotContent/hotContentCommonWidget.tsx@@ -0,0 +1,101 @@+import styles from "@/app/[lng]/hotContent/components/HotContent/hotContent.module.scss";+import Icon from "@ant-design/icons";+import Uparrow from "@/app/[lng]/hotContent/svgs/uparrow.svg";+import { describeNumber } from "@/utils";+import { Avatar } from "antd";++export const AnaAddCall = ({+ add,+ total,+ highlight = false,+}: {+ add: number;+ total: number;+ highlight?: boolean;+}) => {+ return (+ <div+ className={`${styles.anaAddCall} ${highlight ? styles["anaAddCall-highlight"] : ""}`}+ >+ <div className="anaAddCall-add">+ {add ? (+ <>+ <Icon component={Uparrow} />+ {describeNumber(add)}+ </>+ ) : (+ "-"+ )}+ </div>+ <div className="anaAddCall-total">总{describeNumber(total)}</div>+ </div>+ );+};++export const SingleNumberCall = ({+ total,+ highlight = false,+}: {+ total: number;+ highlight?: boolean;+}) => {+ return (+ <p+ style={{+ textAlign: "center",+ fontSize: "var(--fs-md)",+ color: highlight ? "var(--colorPrimary5)" : "#3d4242",+ fontFamily: "DIN",+ fontWeight: 100,+ }}+ >+ {describeNumber(total)}+ </p>+ );+};++export const HotContentBaseInfo = ({+ cover,+ title,+ avatar,+ nickname,+ fansCount,+ publishTime,+}: {+ cover: string;+ title: string;+ avatar: string;+ nickname: string;+ fansCount?: number;+ publishTime: string;+}) => {+ return (+ <div className={styles.baseInfo}>+ <img className="baseInfo-cover" src={cover} />+ <div className="baseInfo-right">+ {title ? (+ <div className="baseInfo-right-title" title={title}>+ {title}+ </div>+ ) : (+ <div className="baseInfo-right-noTitle">暂无标题</div>+ )}++ <div className="baseInfo-right-author">+ <Avatar+ className="baseInfo-right-author-avatar"+ src={avatar}+ size="small"+ />+ <p className="baseInfo-right-author-name">{nickname}</p>+ {fansCount && (+ <p className="baseInfo-right-author-fans">+ 粉丝数 {describeNumber(fansCount)}+ </p>+ )}+ <p className="baseInfo-right-author-pubTime">发布于{publishTime}</p>+ </div>+ </div>+ </div>+ );+};diff --git a/src/app/[lng]/hotContent/components/HotContent/index.tsx b/src/app/[lng]/hotContent/components/HotContent/index.tsxindex 367a9aed..f3924b8c 100644--- a/src/app/[lng]/hotContent/components/HotContent/index.tsx+++ b/src/app/[lng]/hotContent/components/HotContent/index.tsx@@ -12,15 +12,18 @@ import { useHotContent } from "@/app/[lng]/hotContent/useHotContent";import { useShallow } from "zustand/react/shallow";import HotContentLabel from "@/app/[lng]/hotContent/components/HotContentLabel";import styles from "./hotContent.module.scss";-import { Avatar, Popover, Select, Skeleton, Spin, Table } from "antd";+import { Popover, Select, Skeleton, Spin, Table } from "antd";import Icon, { QuestionCircleOutlined } from "@ant-design/icons";import type { TableProps } from "antd";import { platformApi, PlatformRanking, RankingContent } from "@/api/hot";import InfiniteScroll from "react-infinite-scroll-component";-import { describeNumber } from "@/utils";-import Uparrow from "../../svgs/uparrow.svg";import HotSvg from "../../svgs/hotContent.svg";import ReadSvg from "./svgs/read.svg";+import {+ AnaAddCall,+ HotContentBaseInfo,+ SingleNumberCall,+} from "@/app/[lng]/hotContent/components/HotContent/hotContentCommonWidget";export interface IHotContentRef {}@@ -30,56 +33,6 @@ const icons = {wechat: [ReadSvg, HotSvg],};-const AnaAddCall = ({- add,- total,- highlight = false,-}: {- add: number;- total: number;- highlight?: boolean;-}) => {- return (- <div- className={`${styles.anaAddCall} ${highlight ? styles["anaAddCall-highlight"] : ""}`}- >- <div className="anaAddCall-add">- {add ? (- <>- <Icon component={Uparrow} />- {describeNumber(add)}- </>- ) : (- "-"- )}- </div>- <div className="anaAddCall-total">总{describeNumber(total)}</div>- </div>- );-};--const SingleNumberCall = ({- total,- highlight = false,-}: {- total: number;- highlight?: boolean;-}) => {- return (- <p- style={{- textAlign: "center",- fontSize: "var(--fs-md)",- color: highlight ? "var(--colorPrimary5)" : "#3d4242",- fontFamily: "DIN",- fontWeight: 100,- }}- >- {describeNumber(total)}- </p>- );-};-const HotContent = memo(forwardRef(({}: IHotContentProps, ref: ForwardedRef<IHotContentRef>) => {const {@@ -301,37 +254,14 @@ const HotContent = memo(dataIndex: "baseInfo",render: (text, data) => {return (- <div className={styles.baseInfo}>- <img className="baseInfo-cover" src={data.cover} />- <div className="baseInfo-right">- {data.title ? (- <div className="baseInfo-right-title" title={data.title}>- {data.title}- </div>- ) : (- <div className="baseInfo-right-noTitle">暂无标题</div>- )}-- <div className="baseInfo-right-author">- <Avatar- className="baseInfo-right-author-avatar"- src={data.author.avatar}- size="small"- />- <p className="baseInfo-right-author-name">- {data.author.name}- </p>- {data.author.fansCount && (- <p className="baseInfo-right-author-fans">- 粉丝数 {describeNumber(data.author.fansCount)}- </p>- )}- <p className="baseInfo-right-author-pubTime">- 发布于{data.publishTime}- </p>- </div>- </div>- </div>+ <HotContentBaseInfo+ title={data.title}+ avatar={data.author.avatar}+ publishTime={data.publishTime}+ fansCount={data.author.fansCount}+ nickname={data.author.name}+ cover={data.cover}+ />);},},@@ -472,7 +402,7 @@ const HotContent = memo(<Spin spinning={loading}><div- className={`hotContent-table hotContent--${selectedLabelInfo?.ranking?.platform?.type}`}+ className={`${styles["hotContent-table"]} hotContent--${selectedLabelInfo?.ranking?.platform?.type}`}id="hotContent-table"><InfiniteScroll