Skip to content

Let's use AI to Earn!

feat(发布): 1. 修改图文校验。 2. 日历-发布记录,操作栏做了条件显示,有链接才显示复制链接,未发布才可删除。 3. 修复了无法修改发布时间的bug

gaoSir2f3c305fd3ac
diff --git a/package.json b/package.json
index 922763d5..eeaa2d4d 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,7 @@
"scripts": {
"postbuild": "next-sitemap",
"dev": "next dev -p 6060",
- "dev:local": "cross-env NEXT_PUBLIC_API_URL=http://localhost:7000/api/ next dev",
+ "dev:local": "cross-env NEXT_PUBLIC_API_URL=http://localhost:7001/api/ next dev",
"build": "next build",
"build:copy": "tsc && next build && npm run copy-static",
"copy-static": "xcopy public .next\\standalone\\public /E /I /Y && if exist .next\\static xcopy .next\\static .next\\standalone\\.next\\static /E /I /Y",
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx
index 683f30ab..667ebbc1 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx
+++ b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/RecordCore.tsx
@@ -32,9 +32,7 @@ import { TooltipRef } from "antd/lib/tooltip";
import { deletePublishRecordApi, nowPubTaskApi } from "@/api/plat/publish";
import { getDays } from "@/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils";
import { getOssUrl } from "@/utils/oss";
-import { useTransClient } from "@/app/i18n/client";
-
-
+import { useTransClient } from "@/app/i18n/client";
export interface IRecordCoreRef {}
@@ -44,7 +42,7 @@ export interface IRecordCoreProps {
const PubStatus = ({ status }: { status: PublishStatus }) => {
const { t } = useTransClient("publish");
-
+
return (
<div className={styles.pubStatus}>
{status === PublishStatus.FAIL ? (
@@ -96,27 +94,36 @@ const RecordCore = memo(
const [popoverOpen, setPopoverOpen] = useState(false);
const popoverRef = useRef<TooltipRef>(null);
const { t } = useTransClient("publish");
-
- const dropdownItems: MenuProps["items"] = [
- {
- key: "2",
- label: t("buttons.copyLink"),
- onClick: async () => {
- await navigator.clipboard.writeText(publishRecord.workLink);
- },
- },
- {
- key: "3",
- danger: true,
- label: t("buttons.delete"),
- onClick: async () => {
- setPopoverOpen(false);
- setListLoading(true);
- await deletePublishRecordApi(publishRecord.id);
- getPubRecord();
- },
- },
- ];
+
+ const dropdownItems: MenuProps["items"] = useMemo(() => {
+ if (publishRecord.workLink) {
+ return [
+ {
+ key: "2",
+ label: t("buttons.copyLink"),
+ onClick: async () => {
+ await navigator.clipboard.writeText(publishRecord.workLink);
+ },
+ },
+ ];
+ }
+
+ if (publishRecord.status === PublishStatus.UNPUBLISH) {
+ return [
+ {
+ key: "3",
+ danger: true,
+ label: t("buttons.delete"),
+ onClick: async () => {
+ setPopoverOpen(false);
+ setListLoading(true);
+ await deletePublishRecordApi(publishRecord.id);
+ getPubRecord();
+ },
+ },
+ ];
+ }
+ }, [publishRecord]);
const days = useMemo(() => {
return getDays(publishRecord.publishTime);
@@ -194,7 +201,7 @@ const RecordCore = memo(
getPubRecord();
}}
>
- {t("buttons.publishNow")}
+ {t("buttons.publishNow")}
</Button>
)}
<Dropdown menu={{ items: dropdownItems }} placement="top">
@@ -210,7 +217,7 @@ const RecordCore = memo(
style={{ width: calendarCallWidth + "px" }}
>
<div className="recordCore-left">
- <img src={platIcon} style={{width: '25px', height: '25px'}}/>
+ <img src={platIcon} style={{ width: "25px", height: "25px" }} />
<div className="recordCore-left-date">{days.format("HH:mm")}</div>
</div>
<div className="recordCore-right">
diff --git a/src/app/config/platConfig.ts b/src/app/config/platConfig.ts
index 2425d3cb..050fede1 100644
--- a/src/app/config/platConfig.ts
+++ b/src/app/config/platConfig.ts
@@ -126,7 +126,7 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
name: "Twitter",
icon: twitterSvg.src,
url: "https://x.com/",
- pubTypes: new Set([PubType.VIDEO]),
+ pubTypes: new Set([PubType.VIDEO, PubType.ImageText]),
commonPubParamsConfig: {
titleMax: 16,
topicMax: 10,
@@ -140,7 +140,7 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
name: "TikTok",
icon: tiktokSvg.src,
url: "https://www.tiktok.com/",
- pubTypes: new Set([PubType.VIDEO]),
+ pubTypes: new Set([PubType.VIDEO, PubType.ImageText]),
commonPubParamsConfig: {
titleMax: 16,
topicMax: 10,
@@ -154,7 +154,7 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
name: "Facebook",
icon: facebookSvg.src,
url: "https://www.facebook.com/",
- pubTypes: new Set([PubType.VIDEO]),
+ pubTypes: new Set([PubType.VIDEO, PubType.ImageText]),
commonPubParamsConfig: {
titleMax: 16,
topicMax: 10,
@@ -168,7 +168,7 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
name: "微信公众号",
icon: wxGzhSvg.src,
url: "https://mp.weixin.qq.com/",
- pubTypes: new Set([PubType.VIDEO]),
+ pubTypes: new Set([PubType.VIDEO, PubType.ImageText]),
commonPubParamsConfig: {
titleMax: 16,
topicMax: 10,
@@ -182,7 +182,7 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
name: "Instagram",
icon: instagramSvg.src,
url: "https://www.instagram.com/",
- pubTypes: new Set([PubType.VIDEO]),
+ pubTypes: new Set([PubType.VIDEO, PubType.ImageText]),
commonPubParamsConfig: {
titleMax: 16,
topicMax: 10,
@@ -196,7 +196,7 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
name: "Threads",
icon: threadsSvg.src,
url: "https://www.threads.net/",
- pubTypes: new Set([PubType.VIDEO]),
+ pubTypes: new Set([PubType.VIDEO, PubType.ImageText]),
commonPubParamsConfig: {
titleMax: 16,
topicMax: 10,
diff --git a/src/app/config/publishConfig.ts b/src/app/config/publishConfig.ts
index 55d34c7a..e7d3c4b1 100644
--- a/src/app/config/publishConfig.ts
+++ b/src/app/config/publishConfig.ts
@@ -1,23 +1,5 @@
// 发布类型
export enum PubType {
VIDEO = "video", // 视频
- ImageText = "image-text", // 图文
-}
-
-// 可见性
-export enum VisibleTypeEnum {
- // 所有人可见
- Public = 1,
- // 仅自己可见
- Private = 2,
- // 好友可见
- Friend = 3,
-}
-
-export enum PubStatus {
- UNPUBLISH = 0, // 未发布/草稿
- RELEASED = 1, // 已发布
- FAIL = 2, // 发布失败
- PartSuccess = 3, // 部分成功
- Audit = 4, // 审核中
+ ImageText = "article", // 图文
}
diff --git a/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload.tsx b/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload.tsx
index 6c1f6a13..99adf9f8 100644
--- a/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload.tsx
+++ b/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasTextareaUpload.tsx
@@ -161,7 +161,7 @@ const PubParmasTextareaUpload = memo(
<Tooltip title={t("upload.uploadImageOrVideo")}>
<Dragger
accept={uploadAccept}
- multiple={!uploadAccept.includes("video")}
+ multiple={uploadAccept.includes("image")}
listType="text"
beforeUpload={async (file, uploadFileList) => {
if (!checkFileListType(uploadFileList)) {
diff --git a/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx b/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx
index 19a17e1d..62c5a0a5 100644
--- a/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx
+++ b/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx
@@ -132,6 +132,11 @@ const PubParmasTextarea = memo(
if (!hasImage && hasVideo && platConfig.pubTypes.has(PubType.VIDEO))
return "video/*";
+ if (
+ platConfig.pubTypes.has(PubType.ImageText) &&
+ platConfig.pubTypes.has(PubType.VIDEO)
+ )
+ return "video/*,image/*";
if (platConfig.pubTypes.has(PubType.ImageText)) return "image/*";
if (platConfig.pubTypes.has(PubType.VIDEO)) return "video/*";
diff --git a/src/components/PublishDialog/compoents/PublishDialogDataPicker.tsx b/src/components/PublishDialog/compoents/PublishDialogDataPicker.tsx
index 7b5d2075..39ce1aa7 100644
--- a/src/components/PublishDialog/compoents/PublishDialogDataPicker.tsx
+++ b/src/components/PublishDialog/compoents/PublishDialogDataPicker.tsx
@@ -18,18 +18,13 @@ const PublishDialogDataPicker = memo(
{}: IPublishDialogDataPickerProps,
ref: ForwardedRef<IPublishDialogDataPickerRef>,
) => {
- const { pubTime } = usePublishDialog(
+ const { pubTime, setPubTime } = usePublishDialog(
useShallow((state) => ({
pubTime: state.pubTime,
+ setPubTime: state.setPubTime,
})),
);
- const onOk = (
- value: DatePickerProps["value"] | RangePickerProps["value"],
- ) => {
- console.log("onOk: ", value);
- };
-
// 禁用今天之前的日期
const disabledDate = (current: dayjs.Dayjs) => {
return current && current < dayjs().startOf("day");
@@ -94,11 +89,9 @@ const PublishDialogDataPicker = memo(
allowClear={false}
disabledDate={disabledDate}
disabledTime={disabledDateTime}
- onChange={(value, dateString) => {
- console.log("Selected Time: ", value);
- console.log("Formatted Selected Time: ", dateString);
+ onChange={(value) => {
+ setPubTime(value ? value.format() : undefined);
}}
- onOk={onOk}
/>
) : (
<div />
diff --git a/src/components/PublishDialog/index.tsx b/src/components/PublishDialog/index.tsx
index 017a1f40..7843d7d3 100644
--- a/src/components/PublishDialog/index.tsx
+++ b/src/components/PublishDialog/index.tsx
@@ -296,7 +296,7 @@ const PublishDialog = memo(
)}
{pubListChoosed.length >= 2 && (
<PubParmasTextarea
- platType={PlatType.KWAI}
+ platType={PlatType.Instagram}
rows={16}
desValue={commonPubParams.des}
videoFileValue={commonPubParams.video}
diff --git a/src/components/PublishDialog/usePublishDialog.ts b/src/components/PublishDialog/usePublishDialog.ts
index eb7eba33..d7cdc758 100644
--- a/src/components/PublishDialog/usePublishDialog.ts
+++ b/src/components/PublishDialog/usePublishDialog.ts
@@ -7,6 +7,8 @@ import {
PubItem,
} from "@/components/PublishDialog/publishDialog.type";
import { ErrPubParamsMapType } from "@/components/PublishDialog/hooks/usePubParamsVerify";
+import { AccountPlatInfoMap } from "@/app/config/platConfig";
+import { PubType } from "@/app/config/publishConfig";
export interface IPublishDialogStore {
// 选择的发布列表
@@ -42,7 +44,7 @@ const store: IPublishDialogStore = {
source: "",
},
facebook: {
- page_id: undefined,
+ page_id: undefined,
},
instagram: {
content_category: undefined,
@@ -135,9 +137,20 @@ export const usePublishDialog = create(
const keyType = key as "des";
const val = pubParmas[keyType];
commonPubParams[keyType] = pubParmas[keyType]!;
- pubList.map((v) => {
+
+ for (let i = 0; i < pubList.length; i++) {
+ const v = pubList[i];
+ const platConfig = AccountPlatInfoMap.get(v.account.type)!;
+ if (
+ (key === "video" &&
+ !platConfig.pubTypes.has(PubType.VIDEO)) ||
+ (key === "images" &&
+ !platConfig.pubTypes.has(PubType.ImageText))
+ ) {
+ continue;
+ }
v.params[keyType] = val!;
- });
+ }
}
}
@@ -168,22 +181,35 @@ export const usePublishDialog = create(
// 使用lodash的merge来正确处理嵌套对象
if (pubParmas.option) {
- findedData.params.option = lodash.merge({}, findedData.params.option, pubParmas.option);
+ findedData.params.option = lodash.merge(
+ {},
+ findedData.params.option,
+ pubParmas.option,
+ );
}
for (const key in pubParmas) {
- if (pubParmas.hasOwnProperty(key) && key !== 'option') {
+ if (pubParmas.hasOwnProperty(key) && key !== "option") {
(findedData.params as any)[key] = (pubParmas as any)[key];
}
}
- pubList.map((v) => {
+ for (let i = 0; i < pubList.length; i++) {
+ const v = pubList[i];
+ const platConfig = AccountPlatInfoMap.get(v.account.type)!;
if (!pubListChoosed.some((k) => k.account.id === v.account.id)) {
v.params.des = pubParmas.des || "";
- v.params.video = pubParmas.video;
- v.params.images = pubParmas.images;
+ if (platConfig.pubTypes.has(PubType.VIDEO) && pubParmas.video) {
+ v.params.video = pubParmas.video;
+ }
+ if (
+ platConfig.pubTypes.has(PubType.ImageText) &&
+ pubParmas.images
+ ) {
+ v.params.images = pubParmas.images;
+ }
}
- });
+ }
pubListChoosed = pubListChoosed.map((v) => {
const findData = pubList.find((k) => k.account.id === v.account.id);
diff --git a/src/components/notification/NotificationPanel.tsx b/src/components/notification/NotificationPanel.tsx
index c704e7ad..09eef503 100644
--- a/src/components/notification/NotificationPanel.tsx
+++ b/src/components/notification/NotificationPanel.tsx
@@ -149,7 +149,7 @@ const NotificationPanel: React.FC<NotificationPanelProps> = ({ visible, onClose
</Button>
]}
width={600}
- destroyOnClose
+ destroyOnHidden
>
<Spin spinning={loading}>
{notifications.length > 0 ? (