Skip to content

Let's use AI to Earn!

feat: 发布记录图片优化

gaoSirb283ae2c5c2c
diff --git a/src/index.css b/src/index.css
index bfd9ec78..f4e835cf 100644
--- a/src/index.css
+++ b/src/index.css
@@ -22,6 +22,10 @@ html, body, #root {
-webkit-app-region: no-drag;
}
+.ant-image-preview-close {
+ top: 60px;
+}
+
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
diff --git a/src/router/index.tsx b/src/router/index.tsx
index 39231e45..66fbb776 100644
--- a/src/router/index.tsx
+++ b/src/router/index.tsx
@@ -33,7 +33,6 @@ import Publish from '@/views/publish/page';
import VideoPage from '@/views/publish/children/videoPage/page';
import ImagePage from '@/views/publish/children/imagePage/page';
import PubRecord from '@/views/publish/children/pubRecord/page';
-import Drafts from '@/views/publish/children/drafts/page';
import Statistics from '@/views/statistics';
import Task from '@/views/task';
// import HotTopic from '@/views/trending/hotTopic';
@@ -115,7 +114,6 @@ export const router: CustomRouteObject[] = [
// element: <TextPage />,
// },
{ path: 'pubRecord', element: <PubRecord /> },
- { path: 'drafts', element: <Drafts /> },
],
},
{
diff --git a/src/utils/index.ts b/src/utils/index.ts
index daffebad..db0a183f 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -22,7 +22,6 @@ export function formatTime(
time: string | number | Date,
format: string = 'YYYY-MM-DD HH:mm:ss',
) {
- console.log(time);
return dayjs(time).format(format);
}
diff --git a/src/views/publish/children/drafts/item.tsx b/src/views/publish/children/drafts/item.tsx
deleted file mode 100644
index e0977623..00000000
--- a/src/views/publish/children/drafts/item.tsx
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * @Author: nevin
- * @Date: 2025-02-17 19:28:13
- * @LastEditTime: 2025-02-17 22:30:22
- * @LastEditors: nevin
- * @Description: 草稿数据详情
- */
-import { forwardRef, useImperativeHandle, useState } from 'react';
-import {
- icpGetPubRecordItemList,
- icpPublishDelPubRecordById,
- icpPublishDelPubRecordItem,
-} from '@/icp/publish';
-import { icpGetAccountListByIds } from '@/icp/account';
-import { AccountInfo, AccountPlatInfoMap } from '@/views/account/comment';
-import { Avatar, Button, Drawer, Spin } from 'antd';
-import styles from './pubRecord.module.scss';
-import { PubRecordModel } from '../../comment';
-
-export interface PubItemRef {
- init: (pubRecord: PubRecordModel) => Promise<void>;
-}
-
-export default forwardRef<PubItemRef>((props, ref) => {
- const [open, setOpen] = useState(false);
- const [recordLoaidng, setRecordLoaidng] = useState(false);
- const [pubRecord, setPubRecord] = useState<PubRecordModel | null>(null);
- const [accountList, setAccountList] = useState<AccountInfo[]>([]);
-
- function close() {
- setOpen(false);
- }
-
- async function init(info: PubRecordModel) {
- setPubRecord(info);
-
- setRecordLoaidng(true);
-
- const res = await icpGetPubRecordItemList(
- {
- page_no: 1,
- page_size: 10,
- },
- info.id,
- );
-
- getAccountListByIds(res.list.map((item) => item.accountId));
-
- setOpen(true);
- setRecordLoaidng(false);
- }
-
- async function getAccountListByIds(ids: number[]) {
- const res = await icpGetAccountListByIds(ids);
- setAccountList(res || []);
- }
-
- async function delPubRecord() {
- if (!pubRecord) return;
- const res = await icpPublishDelPubRecordById(pubRecord.id);
- if (!res) setPubRecord(null);
- }
-
- /**
- * 删除账户
- * @param info
- */
- async function delPubRecordAccount(accountInfo: AccountInfo) {
- if (!pubRecord) return;
-
- const res = await icpPublishDelPubRecordItem(
- pubRecord.id,
- pubRecord.type,
- accountInfo.id,
- );
- if (!res) setPubRecord(null);
- }
-
- /**
- * TODO: 发布
- */
- async function pul() {}
-
- useImperativeHandle(ref, () => ({
- init: init,
- }));
-
- return (
- <div className={styles.pubRecord}>
- <Drawer title="关联账号" onClose={close} open={open} width={600}>
- <Spin spinning={recordLoaidng}>
- <div className={styles.pubRecord} style={{ padding: '0' }}>
- <ul className="pubRecord-record">
- {accountList.map((account) => {
- const plat = AccountPlatInfoMap.get(account.type);
- return (
- <li className="pubRecord-record-item" key={account.id}>
- <div className="pubRecord-record-item-con">
- <div className="pubRecord-record-item-con-avatar">
- <Avatar size="large" src={account?.avatar} />
- <img src={plat?.icon} />
- <p>{account.uid}</p>
- <p>{account.nickname}</p>
- </div>
- </div>
- <div className="pubRecord-record-item-btns">
- <Button
- type="link"
- onClick={() => delPubRecordAccount(account)}
- >
- 删除
- </Button>
- </div>
- </li>
- );
- })}
- </ul>
-
- <div
- style={{
- display: 'flex',
- justifyContent: 'center',
- marginTop: '20px',
- }}
- >
- <Button onClick={pul}>发布</Button>
- <Button onClick={delPubRecord}>删除</Button>
- </div>
- </div>
- </Spin>
- </Drawer>
- </div>
- );
-});
diff --git a/src/views/publish/children/drafts/page.tsx b/src/views/publish/children/drafts/page.tsx
deleted file mode 100644
index 5c742d3a..00000000
--- a/src/views/publish/children/drafts/page.tsx
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * @Author: nevin
- * @Date: 2025-02-13 19:11:37
- * @LastEditTime: 2025-02-17 22:31:25
- * @LastEditors: nevin
- * @Description: 草稿列表
- */
-import { useEffect, useRef, useState } from 'react';
-import { PubRecordModel } from '../../comment';
-import styles from './pubRecord.module.scss';
-import { icpGetPubRecordDraftsList } from '@/icp/publish';
-import { Button, Table, TableProps } from 'antd';
-import { getImgFile, IImgFile } from '@/components/Choose/ImgChoose';
-import { formatTime, getFilePathName } from '@/utils';
-import { PubType } from '../../../../../commont/publish/PublishEnum';
-import PubItem, { PubItemRef } from './item';
-
-const PubTypeNameMap = new Map<PubType, string>([
- [PubType.ARTICLE, '图文'],
- [PubType.VIDEO, '视频'],
-]);
-
-const PubStatusNameMap = new Map<number, string>([
- [0, '未发布'],
- [1, '已发布'],
- [2, '发布失败'],
-]);
-
-/**
- * 发布的图片
- * @param param0
- * @returns
- */
-const PubCon = ({ prm }: { prm: PubRecordModel }) => {
- const [imgFile, setImgFile] = useState<IImgFile>();
- useEffect(() => {
- getImgFile(prm.coverPath).then((res) => {
- setImgFile(res);
- });
- }, []);
- return (
- <div className="pubRecord-pubCon">
- {imgFile && <img src={imgFile.imgUrl} />}
- <span
- title={getFilePathName(prm.videoPath)}
- className="pubRecord-pubCon-name"
- >
- {getFilePathName(prm.videoPath)}
- </span>
- </div>
- );
-};
-
-export default function Page() {
- const [pulRecardList, setRecardList] = useState<PubRecordModel[]>([]);
-
- const Ref_PubItem = useRef<PubItemRef>(null);
-
- async function GetPubList() {
- const res = await icpGetPubRecordDraftsList({
- page_no: 1,
- page_size: 10,
- });
- setRecardList(res.list);
- }
-
- useEffect(() => {
- GetPubList();
- }, []);
-
- const columns: TableProps<PubRecordModel>['columns'] = [
- {
- title: '序号',
- render: (text, prm, ind) => ind + 1,
- width: 70,
- key: '序号',
- },
- {
- title: '发布内容',
- render: (text, prm) => <PubCon prm={prm} />,
- width: 200,
- key: '发布内容',
- },
- {
- title: '类型',
- render: (text, prm) => (
- <>
- <p>{PubTypeNameMap.get(prm.type) || ''}</p>
- </>
- ),
- width: 200,
- key: '发布类型',
- },
- {
- title: '创建时间',
- dataIndex: 'publishTime',
- key: 'publishTime',
- render: (text, prm) => formatTime(prm.publishTime),
- width: 200,
- },
- {
- title: '发布状态',
- render: (text, prm) => (
- <>
- <p>{PubStatusNameMap.get(prm.status) || ''}</p>
- </>
- ),
- width: 200,
- key: '发布状态',
- },
- {
- title: '操作',
- width: 100,
- key: '操作',
- render: (text, prm) => (
- <>
- <Button type="link" onClick={() => Ref_PubItem.current?.init(prm)}>
- 详情
- </Button>
- </>
- ),
- },
- ];
-
- return (
- <div className={styles.pubRecord}>
- <Table<PubRecordModel>
- columns={columns}
- dataSource={pulRecardList}
- scroll={{ y: '78vh' }}
- rowKey="id"
- />
-
- {/*发布记录详情*/}
- <PubItem ref={Ref_PubItem} />
- </div>
- );
-}
diff --git a/src/views/publish/children/drafts/pubRecord.module.scss b/src/views/publish/children/drafts/pubRecord.module.scss
deleted file mode 100644
index 494117e2..00000000
--- a/src/views/publish/children/drafts/pubRecord.module.scss
+++ /dev/null
@@ -1,89 +0,0 @@
-.pubRecord {
- width: 100%;
- min-width: 0;
- padding: 20px;
- box-sizing: border-box;
- :global {
- .pubRecord-pubCon {
- display: flex;
- align-items: center;
- //max-width: 350px;
- & > img {
- height: 60px;
- margin-right: 10px;
- }
- &-name {
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- }
-
- .pubRecord-record {
- margin-top: 20px;
- display: flex;
- &-item {
- background: rgb(247, 250, 250);
- padding: 15px 15px 5px 15px;
- border-radius: 6px;
- box-sizing: border-box;
- position: relative;
- width: calc(50% - 8px);
- &:nth-child(even) {
- margin-left: 16px;
- }
- &-btns {
- display: flex;
- justify-content: right;
- }
- &-status {
- position: absolute;
- top: 0;
- right: 0;
- font-size: var(--fs-xs);
- padding: 2px 5px;
- border-radius: 6px 6px 0 6px;
- }
- &--success {
- background: rgb(218, 245, 233);
- color: rgb(47, 178, 122);
- }
- &--fail {
- background-color: #ffcccc;
- color: #ff0000;
- }
- &-con {
- display: flex;
- &-avatar {
- position: relative;
- margin-right: 10px;
- & > img {
- width: 15px;
- position: absolute;
- border-radius: 50%;
- bottom: 0;
- right: 0;
- }
- }
- }
- &-failMsg {
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- width: 100%;
- font-size: var(--fs-xs);
- color: #ff0000;
- }
- &-userinfo {
- overflow: hidden;
- text-overflow: ellipsis;
- &-time {
- font-size: var(--fs-xs);
- margin-top: 3px;
- color: #b4b4b4;
- }
- }
- }
- }
- }
-}
diff --git a/src/views/publish/children/pubRecord/page.tsx b/src/views/publish/children/pubRecord/page.tsx
index d7fa1a45..f901ff3b 100644
--- a/src/views/publish/children/pubRecord/page.tsx
+++ b/src/views/publish/children/pubRecord/page.tsx
@@ -6,6 +6,7 @@ import {
Avatar,
Button,
Drawer,
+ Image,
Modal,
Spin,
Table,
@@ -25,7 +26,15 @@ import { AccountType } from '../../../../../commont/AccountEnum';
import WebView from '../../../../components/WebView';
import { getVideoFile } from '../../../../components/Choose/VideoChoose';
-const PubCon = ({ prm }: { prm: PubRecordModel }) => {
+export const ImageView = ({
+ prm,
+ width,
+ height,
+}: {
+ prm: PubRecordModel;
+ width: number | string;
+ height: number | string;
+}) => {
const [imgFile, setImgFile] = useState<IImgFile>();
useEffect(() => {
getImgFile(prm.coverPath).then((res) => {
@@ -33,8 +42,8 @@ const PubCon = ({ prm }: { prm: PubRecordModel }) => {
});
}, []);
return (
- <div className="pubRecord-pubCon">
- {imgFile && <img src={imgFile.imgUrl} />}
+ <div className={styles['pubRecord-pubCon']}>
+ {imgFile && <Image src={imgFile.imgUrl} height={height} width={width} />}
<span
title={getFilePathName(prm.videoPath)}
className="pubRecord-pubCon-name"
@@ -84,7 +93,7 @@ export default function Page() {
},
{
title: '发布内容',
- render: (text, prm) => <PubCon prm={prm} />,
+ render: (text, prm) => <ImageView prm={prm} width={50} height={70} />,
width: 200,
key: '发布内容',
},
@@ -215,7 +224,7 @@ export default function Page() {
<Drawer title="发布记录" onClose={close} open={open} width={600}>
<Spin spinning={recordLoaidng}>
<div className={styles.pubRecord} style={{ padding: '0' }}>
- <PubCon prm={currPubRecordModel!} />
+ <ImageView prm={currPubRecordModel!} width="auto" height={150} />
<ul className="pubRecord-record">
{pubRecordList.map((v) => {
diff --git a/src/views/publish/children/pubRecord/pubRecord.module.scss b/src/views/publish/children/pubRecord/pubRecord.module.scss
index 0b9172e9..6b6f3419 100644
--- a/src/views/publish/children/pubRecord/pubRecord.module.scss
+++ b/src/views/publish/children/pubRecord/pubRecord.module.scss
@@ -4,21 +4,6 @@
padding: 20px;
box-sizing: border-box;
:global {
- .pubRecord-pubCon {
- display: flex;
- align-items: center;
- //max-width: 350px;
- & > img {
- height: 60px;
- margin-right: 10px;
- }
- &-name {
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- }
-
.pubRecord-record {
margin-top: 20px;
display: flex;
@@ -93,3 +78,22 @@
}
}
}
+
+.pubRecord-pubCon {
+ display: flex;
+ align-items: center;
+ :global {
+ .ant-image {
+ flex-shrink: 0;
+ margin-right: 10px;
+ img {
+ object-fit: cover;
+ }
+ }
+ .pubRecord-pubCon-name {
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ }
+}
diff --git a/src/views/publish/page.tsx b/src/views/publish/page.tsx
index 69fda505..f57278b1 100644
--- a/src/views/publish/page.tsx
+++ b/src/views/publish/page.tsx
@@ -9,7 +9,6 @@ import styles from './publish.module.scss';
import {
VideoCameraOutlined,
FileImageOutlined,
- HddOutlined,
ContainerOutlined,
} from '@ant-design/icons';
import { message, Segmented } from 'antd';
@@ -68,11 +67,6 @@ export default function Page() {
value: '/publish/pubRecord',
icon: <ContainerOutlined />,
},
- {
- label: '草稿箱',
- value: '/publish/drafts',
- icon: <HddOutlined />,
- },
]}
onChange={(value) => {
navigate(value);