Skip to content

Let's use AI to Earn!

fix: Fix tiktok ux (#453)

Gao13cb7f46bbe3
diff --git a/project/web/src/app/i18n/locales/en/publish.json b/project/web/src/app/i18n/locales/en/publish.json
index 9e57176f..a116ab84 100644
--- a/project/web/src/app/i18n/locales/en/publish.json
+++ b/project/web/src/app/i18n/locales/en/publish.json
@@ -315,9 +315,13 @@
"default": "By posting, you agree to TikTok's Music Usage Confirmation.",
"organic": "By posting, you agree to TikTok's Music Usage Confirmation.",
"branded": "By posting, you agree to TikTok's Branded Content Policy and Music Usage Confirmation.",
- "both": "By posting, you agree to TikTok's Branded Content Policy and Music Usage Confirmation."
+ "both": "By posting, you agree to TikTok's Branded Content Policy and Music Usage Confirmation.",
+ "processNote": "Note: After publishing, it may take a few minutes for the content to process and appear on your profile."
}
},
+ "messages": {
+ "publishSubmitted": "Your post has been submitted. It may take a few minutes for the content to process and appear on your TikTok profile."
+ },
"previewvideo": "Preview Video",
"record": {
"metrics": {
diff --git a/project/web/src/app/i18n/locales/zh-CN/publish.json b/project/web/src/app/i18n/locales/zh-CN/publish.json
index eb60798e..82ab7b31 100644
--- a/project/web/src/app/i18n/locales/zh-CN/publish.json
+++ b/project/web/src/app/i18n/locales/zh-CN/publish.json
@@ -316,9 +316,13 @@
"default": "发布即表示您同意 TikTok 的音乐使用确认。",
"organic": "发布即表示您同意 TikTok 的音乐使用确认。",
"branded": "发布即表示您同意 TikTok 的品牌内容政策音乐使用确认。",
- "both": "发布即表示您同意 TikTok 的品牌内容政策音乐使用确认。"
+ "both": "发布即表示您同意 TikTok 的品牌内容政策音乐使用确认。",
+ "processNote": "提示:发布后内容可能需要几分钟处理,才会显示在您的个人主页上。"
}
},
+ "messages": {
+ "publishSubmitted": "发布已提交,系统正在处理,内容可能需要几分钟才会显示在您的 TikTok 个人主页上。"
+ },
"previewvideo": "预览视频",
"record": {
"metrics": {
diff --git a/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss b/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss
index e59f9d7a..c04c01ab 100644
--- a/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss
+++ b/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/platParamsSetting.module.scss
@@ -36,6 +36,7 @@
.platParamsSetting-label {
flex-shrink: 0;
width: 90px;
+ margin-right: 10px;
}
}
}
diff --git a/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/plats/TikTokParams.tsx b/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/plats/TikTokParams.tsx
index 6398f854..738f2c3e 100644
--- a/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/plats/TikTokParams.tsx
+++ b/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/plats/TikTokParams.tsx
@@ -63,6 +63,8 @@ const TikTokParams = memo(
brand_organic_toggle: false,
brand_content_toggle: false,
}
+ // add brand_disclosure_enabled as an extra property without changing types
+ ;(option.tiktok as any).brand_disclosure_enabled = false
console.log('Initializing TikTok options:', option.tiktok)
setOnePubParams({ option }, pubItem.account.id)
}
@@ -76,11 +78,11 @@ const TikTokParams = memo(
const getPrivacyLevelLabel = (value: string) => {
switch (value) {
case 'PUBLIC_TO_EVERYONE':
- return t('tiktok.privacy.public' as any)
+ return t('tiktok.privacy.public')
case 'MUTUAL_FOLLOW_FRIENDS':
- return t('tiktok.privacy.friends' as any)
+ return t('tiktok.privacy.friends')
case 'SELF_ONLY':
- return t('tiktok.privacy.private' as any)
+ return t('tiktok.privacy.private')
default:
return value
}
@@ -98,35 +100,39 @@ const TikTokParams = memo(
// 根据选择确定文本
let text = ''
if (brand_organic_toggle && brand_content_toggle) {
- text = t('tiktok.compliance.both' as any)
+ text = t('tiktok.compliance.both')
}
else if (brand_content_toggle) {
- text = t('tiktok.compliance.branded' as any)
+ text = t('tiktok.compliance.branded')
}
else if (brand_organic_toggle) {
- text = t('tiktok.compliance.organic' as any)
+ text = t('tiktok.compliance.organic')
}
else {
- text = t('tiktok.compliance.default' as any)
+ text = t('tiktok.compliance.default')
}
- // 返回整个文本作为可点击的链接
+ // 返回整个文本作为可点击的链接,同时附加简短提示(中/英)
return (
- // <></>
- <a
- href={linkUrl}
- target="_blank"
- rel="noopener noreferrer"
- style={{
- color: '#1890ff',
- textDecoration: 'underline',
- cursor: 'pointer',
- display: 'block',
- width: '100%',
- }}
- >
- {text}
- </a>
+ <div>
+ <a
+ href={linkUrl}
+ target="_blank"
+ rel="noopener noreferrer"
+ style={{
+ color: '#1890ff',
+ textDecoration: 'underline',
+ cursor: 'pointer',
+ display: 'block',
+ width: '100%',
+ }}
+ >
+ {text}
+ </a>
+ <div style={{ marginTop: 6, fontSize: 12, color: '#666' }}>
+ {t('tiktok.compliance.processNote')}
+ </div>
+ </div>
)
}
@@ -139,7 +145,7 @@ const TikTokParams = memo(
{/* Creator Info Display */}
{creatorInfo && (
<div className={styles.commonTitleInput} style={{ marginTop: '10px' }}>
- <div className="platParamsSetting-label">{t('tiktok.creatorInfo' as any)}</div>
+ <div className="platParamsSetting-label">{t('tiktok.creatorInfo')}</div>
<div style={{
display: 'flex',
alignItems: 'center',
@@ -166,7 +172,7 @@ const TikTokParams = memo(
{/* Privacy Level Selection */}
{creatorInfo && (
<div className={styles.commonTitleInput} style={{ marginTop: '10px' }}>
- <div className="platParamsSetting-label">{t('tiktok.privacy.title' as any)}</div>
+ <div className="platParamsSetting-label">{t('tiktok.privacy.title')}</div>
<Select
style={{ width: '100%', marginLeft: '3px' }}
value={pubItem.params.option.tiktok?.privacy_level}
@@ -175,7 +181,7 @@ const TikTokParams = memo(
option.tiktok!.privacy_level = value
setOnePubParams({ option }, pubItem.account.id)
}}
- placeholder={t('tiktok.privacy.placeholder' as any)}
+ placeholder={t('tiktok.privacy.placeholder')}
options={creatorInfo.privacy_level_options.map(level => ({
value: level,
label: getPrivacyLevelLabel(level),
@@ -186,7 +192,7 @@ const TikTokParams = memo(
{/* Allow users to interact */}
<div className={styles.commonTitleInput} style={{ marginTop: '10px' }}>
- <div className="platParamsSetting-label">{t('tiktok.interactions.title' as any)}</div>
+ <div className="platParamsSetting-label">{t('tiktok.interactions.title')}</div>
<div style={{ display: 'flex', flexDirection: 'row', gap: '8px', marginLeft: '3px' }}>
<Checkbox
checked={!pubItem.params.option.tiktok?.comment_disabled}
@@ -197,7 +203,7 @@ const TikTokParams = memo(
setOnePubParams({ option }, pubItem.account.id)
}}
>
- {t('tiktok.interactions.comment' as any)}
+ {t('tiktok.interactions.comment')}
</Checkbox>
<Checkbox
checked={!pubItem.params.option.tiktok?.duet_disabled}
@@ -208,7 +214,7 @@ const TikTokParams = memo(
setOnePubParams({ option }, pubItem.account.id)
}}
>
- {t('tiktok.interactions.duet' as any)}
+ {t('tiktok.interactions.duet')}
</Checkbox>
<Checkbox
checked={!pubItem.params.option.tiktok?.stitch_disabled}
@@ -219,14 +225,14 @@ const TikTokParams = memo(
setOnePubParams({ option }, pubItem.account.id)
}}
>
- {t('tiktok.interactions.stitch' as any)}
+ {t('tiktok.interactions.stitch')}
</Checkbox>
</div>
</div>
{/* Commercial Content Disclosure */}
<div className={styles.commonTitleInput} style={{ marginTop: '10px' }}>
- <div className="platParamsSetting-label">{t('tiktok.commercial.title' as any)}</div>
+ <div className="platParamsSetting-label">{t('tiktok.commercial.title')}</div>
<div style={{ marginBottom: '0px' }}>
{/* <div style={{ fontSize: '12px', color: '#666', marginBottom: '4px' }}>
当前状态: {JSON.stringify({
@@ -236,7 +242,8 @@ const TikTokParams = memo(
})}
</div> */}
<Switch
- checked={pubItem.params.option.tiktok?.brand_organic_toggle || pubItem.params.option.tiktok?.brand_content_toggle}
+ // Switch 用于显示/隐藏披露子项;不应自动选择任何子项
+ checked={(pubItem.params.option.tiktok as any)?.brand_disclosure_enabled}
size="small"
style={{ marginTop: '2px', marginLeft: '3px' }}
onChange={(checked) => {
@@ -251,28 +258,31 @@ const TikTokParams = memo(
brand_organic_toggle: false,
brand_content_toggle: false,
}
+ ;(option.tiktok as any).brand_disclosure_enabled = false
}
if (!checked) {
- // 关闭时,清空所有商业内容选项
+ // 关闭时,隐藏披露并清空所有商业内容选项
+ ;(option.tiktok as any).brand_disclosure_enabled = false
option.tiktok.brand_organic_toggle = false
option.tiktok.brand_content_toggle = false
}
else {
- // 开启时,默认选择"您的品牌"选项
- option.tiktok.brand_organic_toggle = true
+ // 开启时,仅展示子选项,子选项默认不选中,需要用户手动选择
+ ;(option.tiktok as any).brand_disclosure_enabled = true
+ option.tiktok.brand_organic_toggle = false
option.tiktok.brand_content_toggle = false
}
console.log('TikTok options after change:', option.tiktok)
setOnePubParams({ option }, pubItem.account.id)
}}
/>
- <span style={{ marginLeft: '8px', fontSize: '11px' }}>{t('tiktok.commercial.toggle' as any)}</span>
+ <span style={{ marginLeft: '8px', fontSize: '11px' }}>{t('tiktok.commercial.toggle')}</span>
</div>
</div>
- {(pubItem.params.option.tiktok?.brand_organic_toggle || pubItem.params.option.tiktok?.brand_content_toggle) && (
+ {((pubItem.params.option.tiktok as any)?.brand_disclosure_enabled) && (
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px', marginTop: '8px', fontSize: '12px' }}>
<Checkbox
checked={pubItem.params.option.tiktok?.brand_organic_toggle}
@@ -292,7 +302,7 @@ const TikTokParams = memo(
setOnePubParams({ option }, pubItem.account.id)
}}
>
- {t('tiktok.commercial.yourBrand' as any)}
+ {t('tiktok.commercial.yourBrand')}
</Checkbox>
<Checkbox
checked={pubItem.params.option.tiktok?.brand_content_toggle}
@@ -312,13 +322,12 @@ const TikTokParams = memo(
setOnePubParams({ option }, pubItem.account.id)
}}
>
- {t('tiktok.commercial.brandedContent' as any)}
+ {t('tiktok.commercial.brandedContent')}
{' '}
- 11
</Checkbox>
{/* Compliance Declaration */}
- <div className={styles.commonTitleInput} style={{ marginTop: '10px' }}>
+ <div className={styles.commonTitleInput} style={{ marginTop: '10px', height: 'auto' }}>
<Alert
description={getComplianceContent()}
type="info"
diff --git a/project/web/src/components/PublishDialog/index.tsx b/project/web/src/components/PublishDialog/index.tsx
index 7237afdb..843fe70e 100644
--- a/project/web/src/components/PublishDialog/index.tsx
+++ b/project/web/src/components/PublishDialog/index.tsx
@@ -1,14 +1,18 @@
+import type { ForwardedRef } from "react";
+import type { SocialAccount } from "@/api/types/account.type";
import type {
- ForwardedRef,
-} from 'react'
-import type { SocialAccount } from '@/api/types/account.type'
-import type { AIAction, IPublishDialogAiRef } from '@/components/PublishDialog/compoents/PublishDialogAi'
-import type { IImgFile, IVideoFile } from '@/components/PublishDialog/publishDialog.type'
+ AIAction,
+ IPublishDialogAiRef,
+} from "@/components/PublishDialog/compoents/PublishDialogAi";
+import type {
+ IImgFile,
+ IVideoFile,
+} from "@/components/PublishDialog/publishDialog.type";
import type {
PlatformPublishTask,
PluginPlatformType,
PublishParams as PluginPublishParams,
-} from '@/store/plugin'
+} from "@/store/plugin";
import {
ArrowRightOutlined,
@@ -16,13 +20,13 @@ import {
ExclamationCircleFilled,
InfoCircleOutlined,
SendOutlined,
-} from '@ant-design/icons'
+} from "@ant-design/icons";
-import { Button, Tooltip } from 'antd'
-import { toast } from '@/lib/toast'
-import { confirm } from '@/lib/confirm'
-import { Modal } from '@/components/ui/modal'
-import dayjs from 'dayjs'
+import { Button, Tooltip } from "antd";
+import { toast } from "@/lib/toast";
+import { confirm } from "@/lib/confirm";
+import { Modal } from "@/components/ui/modal";
+import dayjs from "dayjs";
import {
forwardRef,
memo,
@@ -32,70 +36,70 @@ import {
useMemo,
useRef,
useState,
-} from 'react'
-import { CSSTransition } from 'react-transition-group'
-import { useWindowSize } from 'react-use'
-import { useShallow } from 'zustand/react/shallow'
-import { getChatModels } from '@/api/ai'
-import { apiCreatePublish } from '@/api/plat/publish'
-import { toolsApi } from '@/api/tools'
+} from "react";
+import { CSSTransition } from "react-transition-group";
+import { useWindowSize } from "react-use";
+import { useShallow } from "zustand/react/shallow";
+import { getChatModels } from "@/api/ai";
+import { apiCreatePublish } from "@/api/plat/publish";
+import { toolsApi } from "@/api/tools";
import {
getDays,
getUtcDays,
-} from '@/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils'
-import { useCalendarTiming } from '@/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming'
-import { bilibiliSkip } from '@/app/[lng]/accounts/plat/BilibiliLogin'
+} from "@/app/[lng]/accounts/components/CalendarTiming/calendarTiming.utils";
+import { useCalendarTiming } from "@/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming";
+import { bilibiliSkip } from "@/app/[lng]/accounts/plat/BilibiliLogin";
import {
FacebookPagesModal,
facebookSkip,
-} from '@/app/[lng]/accounts/plat/FacebookLogin'
-import { instagramSkip } from '@/app/[lng]/accounts/plat/InstagramLogin'
+} from "@/app/[lng]/accounts/plat/FacebookLogin";
+import { instagramSkip } from "@/app/[lng]/accounts/plat/InstagramLogin";
// 导入各平台授权函数
-import { kwaiSkip } from '@/app/[lng]/accounts/plat/kwaiLogin'
-import { linkedinSkip } from '@/app/[lng]/accounts/plat/LinkedinLogin'
-import { pinterestSkip } from '@/app/[lng]/accounts/plat/PinterestLogin'
-import { threadsSkip } from '@/app/[lng]/accounts/plat/ThreadsLogin'
-import { tiktokSkip } from '@/app/[lng]/accounts/plat/TiktokLogin'
-import { twitterSkip } from '@/app/[lng]/accounts/plat/TwtterLogin'
-import { wxGzhSkip } from '@/app/[lng]/accounts/plat/WxGzh'
-import { youtubeSkip } from '@/app/[lng]/accounts/plat/YoutubeLogin'
-import { AccountPlatInfoMap, PlatType } from '@/app/config/platConfig'
-import { PubType } from '@/app/config/publishConfig'
-import { useTransClient } from '@/app/i18n/client'
-import AvatarPlat from '@/components/AvatarPlat'
-import DownloadAppModal from '@/components/common/DownloadAppModal'
-import PlatParamsSetting from '@/components/PublishDialog/compoents/PlatParamsSetting'
-import PublishDatePicker from '@/components/PublishDialog/compoents/PublishDatePicker'
-import PublishDialogAi from '@/components/PublishDialog/compoents/PublishDialogAi'
-import PublishDialogPreview from '@/components/PublishDialog/compoents/PublishDialogPreview'
-import { UploadTaskTypeEnum } from '@/components/PublishDialog/compoents/PublishManageUpload/publishManageUpload.enum'
-import { usePublishManageUpload } from '@/components/PublishDialog/compoents/PublishManageUpload/usePublishManageUpload'
-import PubParmasTextarea from '@/components/PublishDialog/compoents/PubParmasTextarea'
-import TextSelectionToolbar from '@/components/PublishDialog/compoents/TextSelectionToolbar'
-import usePubParamsVerify from '@/components/PublishDialog/hooks/usePubParamsVerify'
-import { usePublishDialog } from '@/components/PublishDialog/usePublishDialog'
-import { usePublishDialogStorageStore } from '@/components/PublishDialog/usePublishDialogStorageStore'
-import { useAccountStore } from '@/store/account'
+import { kwaiSkip } from "@/app/[lng]/accounts/plat/kwaiLogin";
+import { linkedinSkip } from "@/app/[lng]/accounts/plat/LinkedinLogin";
+import { pinterestSkip } from "@/app/[lng]/accounts/plat/PinterestLogin";
+import { threadsSkip } from "@/app/[lng]/accounts/plat/ThreadsLogin";
+import { tiktokSkip } from "@/app/[lng]/accounts/plat/TiktokLogin";
+import { twitterSkip } from "@/app/[lng]/accounts/plat/TwtterLogin";
+import { wxGzhSkip } from "@/app/[lng]/accounts/plat/WxGzh";
+import { youtubeSkip } from "@/app/[lng]/accounts/plat/YoutubeLogin";
+import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";
+import { PubType } from "@/app/config/publishConfig";
+import { useTransClient } from "@/app/i18n/client";
+import AvatarPlat from "@/components/AvatarPlat";
+import DownloadAppModal from "@/components/common/DownloadAppModal";
+import PlatParamsSetting from "@/components/PublishDialog/compoents/PlatParamsSetting";
+import PublishDatePicker from "@/components/PublishDialog/compoents/PublishDatePicker";
+import PublishDialogAi from "@/components/PublishDialog/compoents/PublishDialogAi";
+import PublishDialogPreview from "@/components/PublishDialog/compoents/PublishDialogPreview";
+import { UploadTaskTypeEnum } from "@/components/PublishDialog/compoents/PublishManageUpload/publishManageUpload.enum";
+import { usePublishManageUpload } from "@/components/PublishDialog/compoents/PublishManageUpload/usePublishManageUpload";
+import PubParmasTextarea from "@/components/PublishDialog/compoents/PubParmasTextarea";
+import TextSelectionToolbar from "@/components/PublishDialog/compoents/TextSelectionToolbar";
+import usePubParamsVerify from "@/components/PublishDialog/hooks/usePubParamsVerify";
+import { usePublishDialog } from "@/components/PublishDialog/usePublishDialog";
+import { usePublishDialogStorageStore } from "@/components/PublishDialog/usePublishDialogStorageStore";
+import { useAccountStore } from "@/store/account";
import {
PlatformTaskStatus,
PLUGIN_SUPPORTED_PLATFORMS,
usePluginStore,
-} from '@/store/plugin'
-import { generateUUID } from '@/utils'
-import styles from './publishDialog.module.scss'
-import { PublishDetailModal } from '../Plugin'
+} from "@/store/plugin";
+import { generateUUID } from "@/utils";
+import styles from "./publishDialog.module.scss";
+import { PublishDetailModal } from "../Plugin";
export interface IPublishDialogRef {
// 设置发布时间
- setPubTime: (pubTime?: string) => void
+ setPubTime: (pubTime?: string) => void;
}
export interface IPublishDialogProps {
- open: boolean
- onClose: () => void
- accounts: SocialAccount[]
+ open: boolean;
+ onClose: () => void;
+ accounts: SocialAccount[];
// 发布成功事件
- onPubSuccess?: () => void
+ onPubSuccess?: () => void;
// 默认选中的账户Id
defaultAccountId?: string
// 是否抑制自动发布(用于从任务页面打开,先让用户确认后再发布)
@@ -120,22 +124,18 @@ const PublishDialog = memo(
taskIdForPublish,
onPublishConfirmed,
}: IPublishDialogProps,
- ref: ForwardedRef<IPublishDialogRef>,
+ ref: ForwardedRef<IPublishDialogRef>
) => {
- const { width } = useWindowSize()
- const {
- setPubData,
- restorePubData,
- _hasHydrated,
- setPubListData,
- } = usePublishDialogStorageStore(
- useShallow(state => ({
- setPubData: state.setPubData,
- restorePubData: state.restorePubData,
- _hasHydrated: state._hasHydrated,
- setPubListData: state.setPubListData,
- })),
- )
+ const { width } = useWindowSize();
+ const { setPubData, restorePubData, _hasHydrated, setPubListData } =
+ usePublishDialogStorageStore(
+ useShallow((state) => ({
+ setPubData: state.setPubData,
+ restorePubData: state.restorePubData,
+ _hasHydrated: state._hasHydrated,
+ setPubListData: state.setPubListData,
+ }))
+ );
const {
pubListChoosed,
setPubListChoosed,
@@ -157,7 +157,7 @@ const PublishDialog = memo(
openLeft,
setPubList,
} = usePublishDialog(
- useShallow(state => ({
+ useShallow((state) => ({
pubListChoosed: state.pubListChoosed,
setPubListChoosed: state.setPubListChoosed,
init: state.init,
@@ -177,74 +177,76 @@ const PublishDialog = memo(
setOnePubParams: state.setOnePubParams,
openLeft: state.openLeft,
setOpenLeft: state.setOpenLeft,
- })),
- )
- const { errParamsMap, warningParamsMap }
- = usePubParamsVerify(pubListChoosed)
- const [createLoading, setCreateLoading] = useState(false)
+ }))
+ );
+ const { errParamsMap, warningParamsMap } =
+ usePubParamsVerify(pubListChoosed);
+ const [createLoading, setCreateLoading] = useState(false);
// 内容安全检测状态
- const [moderationLoading, setModerationLoading] = useState(false)
+ const [moderationLoading, setModerationLoading] = useState(false);
const [moderationResult, setModerationResult] = useState<boolean | null>(
- null,
- )
- const [moderationDesc, setModerationDesc] = useState<string>('')
- const [moderationLevel, setModerationLevel] = useState<any>(null)
+ null
+ );
+ const [moderationDesc, setModerationDesc] = useState<string>("");
+ const [moderationLevel, setModerationLevel] = useState<any>(null);
// 下载App弹窗状态
- const [downloadModalVisible, setDownloadModalVisible] = useState(false)
- const [currentPlatform, setCurrentPlatform] = useState<string>('')
+ const [downloadModalVisible, setDownloadModalVisible] = useState(false);
+ const [currentPlatform, setCurrentPlatform] = useState<string>("");
// Facebook页面选择弹窗状态
- const [showFacebookPagesModal, setShowFacebookPagesModal]
- = useState(false)
+ const [showFacebookPagesModal, setShowFacebookPagesModal] =
+ useState(false);
// 发布详情弹框状态
- const [publishDetailVisible, setPublishDetailVisible] = useState(false)
- const [currentPublishTaskId, setCurrentPublishTaskId] = useState<string | undefined>(undefined)
- const { t } = useTransClient('publish')
+ const [publishDetailVisible, setPublishDetailVisible] = useState(false);
+ const [currentPublishTaskId, setCurrentPublishTaskId] = useState<
+ string | undefined
+ >(undefined);
+ const { t } = useTransClient("publish");
// AI助手ref
- const aiAssistantRef = useRef<IPublishDialogAiRef>(null)
+ const aiAssistantRef = useRef<IPublishDialogAiRef>(null);
// 聊天模型列表
- const [chatModels, setChatModels] = useState<any[]>([])
+ const [chatModels, setChatModels] = useState<any[]>([]);
// 中间内容区域ref,用于划词功能
- const contentAreaRef = useRef<HTMLDivElement>(null)
+ const contentAreaRef = useRef<HTMLDivElement>(null);
const { tasks, md5Cache, enqueueUpload } = usePublishManageUpload(
- useShallow(state => ({
+ useShallow((state) => ({
tasks: state.tasks,
md5Cache: state.md5Cache,
enqueueUpload: state.enqueueUpload,
- })),
- )
+ }))
+ );
// 是否clear
- const isClear = useRef(true)
+ const isClear = useRef(true);
// 是否init
- const isInit = useRef(false)
+ const isInit = useRef(false);
// 获取账户store
const { accountGroupList, getAccountList } = useAccountStore(
- useShallow(state => ({
+ useShallow((state) => ({
accountGroupList: state.accountGroupList,
getAccountList: state.getAccountList,
- })),
- )
+ }))
+ );
// 匹配上传结果的ossUrl到发布参数中
useEffect(() => {
const newPubList = pubListChoosed.map((v) => {
- const newPubItem = { ...v }
- const video = newPubItem.params.video
- const images = newPubItem.params.images
+ const newPubItem = { ...v };
+ const video = newPubItem.params.video;
+ const images = newPubItem.params.images;
// 视频匹配
if (video) {
// 如果视频本身没有ossUrl,从上传任务中获取
if (!video.ossUrl && video.uploadTaskIds?.video) {
- newPubItem.params.video!.ossUrl
- = md5Cache[tasks[video.uploadTaskIds.video].md5!]?.ossUrl
+ newPubItem.params.video!.ossUrl =
+ md5Cache[tasks[video.uploadTaskIds.video].md5!]?.ossUrl;
}
// 如果封面没有ossUrl,从上传任务中获取
if (!video.cover.ossUrl && video.uploadTaskIds?.cover) {
- newPubItem.params.video!.cover.ossUrl
- = md5Cache[tasks[video.uploadTaskIds.cover].md5!]?.ossUrl
+ newPubItem.params.video!.cover.ossUrl =
+ md5Cache[tasks[video.uploadTaskIds.cover].md5!]?.ossUrl;
}
- return newPubItem
+ return newPubItem;
}
// 图片匹配
if (images) {
@@ -252,355 +254,353 @@ const PublishDialog = memo(
// 只有当图片没有ossUrl且有uploadTaskId时,才从上传任务中获取
// AI生成的图片已经有ossUrl,不需要从上传任务获取
if (!img.ossUrl && img.uploadTaskId && tasks[img.uploadTaskId]) {
- const taskMd5 = tasks[img.uploadTaskId].md5
+ const taskMd5 = tasks[img.uploadTaskId].md5;
if (taskMd5 && md5Cache[taskMd5]) {
- img.ossUrl = md5Cache[taskMd5].ossUrl
+ img.ossUrl = md5Cache[taskMd5].ossUrl;
}
}
- return img
- })
- return newPubItem
+ return img;
+ });
+ return newPubItem;
}
- return newPubItem
- })
- setPubListChoosed(newPubList)
- }, [md5Cache, tasks])
+ return newPubItem;
+ });
+ setPubListChoosed(newPubList);
+ }, [md5Cache, tasks]);
useEffect(() => {
if (open && _hasHydrated) {
- restorePubData()
+ restorePubData();
}
- }, [open, _hasHydrated])
+ }, [open, _hasHydrated]);
// 处理Facebook授权成功后的页面选择
const handleFacebookAuthSuccess = () => {
- setShowFacebookPagesModal(true)
- }
+ setShowFacebookPagesModal(true);
+ };
// 处理离线账户头像点击,直接跳转到对应平台授权页面
const handleOfflineAvatarClick = useCallback(
async (account: SocialAccount) => {
- const platform = account.type
- const targetSpaceId = account.groupId // 使用账户原本的空间ID
+ const platform = account.type;
+ const targetSpaceId = account.groupId; // 使用账户原本的空间ID
try {
// 记录授权前的账号数量,用于后续识别新账号
const beforeAuthCount = accountGroupList.reduce(
(total, group) => total + group.children.length,
- 0,
- )
+ 0
+ );
// 根据平台类型调用对应的授权函数,传递目标空间ID
switch (platform) {
case PlatType.KWAI:
- await kwaiSkip(platform, targetSpaceId)
- break
+ await kwaiSkip(platform, targetSpaceId);
+ break;
case PlatType.BILIBILI:
- await bilibiliSkip(platform, targetSpaceId)
- break
+ await bilibiliSkip(platform, targetSpaceId);
+ break;
case PlatType.YouTube:
- await youtubeSkip(platform, targetSpaceId)
- break
+ await youtubeSkip(platform, targetSpaceId);
+ break;
case PlatType.Twitter:
- await twitterSkip(platform, targetSpaceId)
- break
+ await twitterSkip(platform, targetSpaceId);
+ break;
case PlatType.Tiktok:
- await tiktokSkip(platform, targetSpaceId)
- break
+ await tiktokSkip(platform, targetSpaceId);
+ break;
case PlatType.Facebook:
try {
- await facebookSkip(platform, targetSpaceId)
+ await facebookSkip(platform, targetSpaceId);
// Facebook授权成功后显示页面选择弹窗
- handleFacebookAuthSuccess()
+ handleFacebookAuthSuccess();
+ } catch (error) {
+ console.error(t("messages.facebookAuthFailed" as any), error);
}
- catch (error) {
- console.error(t('messages.facebookAuthFailed' as any), error)
- }
- break
+ break;
case PlatType.Instagram:
- await instagramSkip(platform, targetSpaceId)
- break
+ await instagramSkip(platform, targetSpaceId);
+ break;
case PlatType.Threads:
- await threadsSkip(platform, targetSpaceId)
- break
+ await threadsSkip(platform, targetSpaceId);
+ break;
case PlatType.WxGzh:
- await wxGzhSkip(platform, targetSpaceId)
- break
+ await wxGzhSkip(platform, targetSpaceId);
+ break;
case PlatType.Pinterest:
- await pinterestSkip(platform, targetSpaceId)
- break
+ await pinterestSkip(platform, targetSpaceId);
+ break;
case PlatType.LinkedIn:
- await linkedinSkip(platform, targetSpaceId)
- break
+ await linkedinSkip(platform, targetSpaceId);
+ break;
default:
console.warn(
- `${t('messages.unsupportedPlatformType' as any)}: ${platform}`,
- )
+ `${t("messages.unsupportedPlatformType" as any)}: ${platform}`
+ );
toast.warning(
- t('messages.platformNotSupportedDirect' as any, { platform }),
- )
- return
+ t("messages.platformNotSupportedDirect" as any, { platform })
+ );
+ return;
}
// Refresh account list after authorization
setTimeout(async () => {
try {
- await getAccountList()
- }
- catch (error) {
+ await getAccountList();
+ } catch (error) {
console.error(
- t('messages.refreshAccountListFailed' as any),
- error,
- )
+ t("messages.refreshAccountListFailed" as any),
+ error
+ );
}
- }, 3000) // Wait 3 seconds for authorization to complete
- }
- catch (error) {
- console.error(t('messages.authFailed' as any), error)
- toast.error(t('messages.authFailedRetry' as any))
+ }, 3000); // Wait 3 seconds for authorization to complete
+ } catch (error) {
+ console.error(t("messages.authFailed" as any), error);
+ toast.error(t("messages.authFailedRetry" as any));
}
},
- [accountGroupList, getAccountList],
- )
+ [accountGroupList, getAccountList]
+ );
// 处理Facebook页面选择成功
const handleFacebookPagesSuccess = () => {
- setShowFacebookPagesModal(false)
+ setShowFacebookPagesModal(false);
// 可以在这里添加成功提示或其他逻辑
- }
+ };
// 内容安全检测函数
const handleContentModeration = useCallback(async () => {
// 获取当前描述内容
- let contentToCheck = ''
+ let contentToCheck = "";
if (step === 0 && pubListChoosed.length >= 2) {
- contentToCheck = commonPubParams.des || ''
- }
- else if (step === 1 && expandedPubItem) {
- contentToCheck = expandedPubItem.params.des || ''
- }
- else if (pubListChoosed.length === 1) {
- contentToCheck = pubListChoosed[0].params.des || ''
+ contentToCheck = commonPubParams.des || "";
+ } else if (step === 1 && expandedPubItem) {
+ contentToCheck = expandedPubItem.params.des || "";
+ } else if (pubListChoosed.length === 1) {
+ contentToCheck = pubListChoosed[0].params.des || "";
}
if (!contentToCheck.trim()) {
- toast.warning(t('messages.pleaseInputContent' as any))
- return
+ toast.warning(t("messages.pleaseInputContent" as any));
+ return;
}
try {
- setModerationLoading(true)
- setModerationResult(null)
- setModerationDesc('')
- setModerationLevel(null)
- const result = await toolsApi.textModeration(contentToCheck)
+ setModerationLoading(true);
+ setModerationResult(null);
+ setModerationDesc("");
+ setModerationLevel(null);
+ const result = await toolsApi.textModeration(contentToCheck);
if (result?.code === 0) {
- const data: any = result?.data || ({} as any)
- const descriptions: string
- = (data && (data.descriptions as string)) || ''
- const labels: string = (data && (data.labels as string)) || ''
- const reason: any
- = data && (data.reason ? JSON.parse(data.reason) : '')
- const isSafe = !descriptions && !labels && !reason
- setModerationResult(isSafe)
- setModerationLevel(reason)
+ const data: any = result?.data || ({} as any);
+ const descriptions: string =
+ (data && (data.descriptions as string)) || "";
+ const labels: string = (data && (data.labels as string)) || "";
+ const reason: any =
+ data && (data.reason ? JSON.parse(data.reason) : "");
+ const isSafe = !descriptions && !labels && !reason;
+ setModerationResult(isSafe);
+ setModerationLevel(reason);
setModerationDesc(
isSafe
- ? ''
- : descriptions || reason || t('actions.contentUnsafe' as any),
- )
+ ? ""
+ : descriptions || reason || t("actions.contentUnsafe" as any)
+ );
if (isSafe) {
- toast.success(t('actions.contentSafe' as any))
- }
- else {
- toast.error(t('actions.contentUnsafe' as any))
+ toast.success(t("actions.contentSafe" as any));
+ } else {
+ toast.error(t("actions.contentUnsafe" as any));
}
}
+ } catch (error) {
+ console.error(t("messages.contentModerationError" as any), error);
+ toast.error(t("messages.contentModerationFailed" as any));
+ } finally {
+ setModerationLoading(false);
}
- catch (error) {
- console.error(t('messages.contentModerationError' as any), error)
- toast.error(t('messages.contentModerationFailed' as any))
- }
- finally {
- setModerationLoading(false)
- }
- }, [step, pubListChoosed, commonPubParams, expandedPubItem, t])
+ }, [step, pubListChoosed, commonPubParams, expandedPubItem, t]);
// 检查是否有描述内容
const hasDescription = useMemo(() => {
if (step === 0 && pubListChoosed.length >= 2) {
- return !!(commonPubParams.des && commonPubParams.des.trim())
- }
- else if (step === 1 && expandedPubItem) {
+ return !!(commonPubParams.des && commonPubParams.des.trim());
+ } else if (step === 1 && expandedPubItem) {
return !!(
expandedPubItem.params.des && expandedPubItem.params.des.trim()
- )
- }
- else if (pubListChoosed.length === 1) {
+ );
+ } else if (pubListChoosed.length === 1) {
return !!(
pubListChoosed[0].params.des && pubListChoosed[0].params.des.trim()
- )
+ );
}
- return false
- }, [step, pubListChoosed, commonPubParams, expandedPubItem])
+ return false;
+ }, [step, pubListChoosed, commonPubParams, expandedPubItem]);
// 实时保存数据
useEffect(() => {
- if (!open)
- return
- if (!expandedPubItem?.params.des && expandedPubItem?.params.images?.length === 0 && !expandedPubItem?.params.video) {
- return
+ if (!open) return;
+ if (
+ !expandedPubItem?.params.des &&
+ expandedPubItem?.params.images?.length === 0 &&
+ !expandedPubItem?.params.video
+ ) {
+ return;
}
if (isClear.current) {
- isClear.current = false
- return
+ isClear.current = false;
+ return;
}
- setPubData(pubListChoosed)
- }, [pubListChoosed])
+ setPubData(pubListChoosed);
+ }, [pubListChoosed]);
useEffect(() => {
- if (!expandedPubItem || pubList.length === 0)
- return
+ if (!expandedPubItem || pubList.length === 0) return;
if (isInit.current) {
- isInit.current = false
- return
+ isInit.current = false;
+ return;
}
- setPubListData(pubList)
- }, [pubList])
+ setPubListData(pubList);
+ }, [pubList]);
// 检查选中的平台是否需要内容安全检测
const needsContentModeration = useMemo(() => {
- if (pubListChoosed.length === 0)
- return false
+ if (pubListChoosed.length === 0) return false;
// 检查所有选中的账户对应的平台是否需要内容检测
return pubListChoosed.some((pubItem) => {
const platInfo = AccountPlatInfoMap.get(
- pubItem.account.type as PlatType,
- )
- return platInfo?.jiancha === true
- })
- }, [pubListChoosed])
+ pubItem.account.type as PlatType
+ );
+ return platInfo?.jiancha === true;
+ });
+ }, [pubListChoosed]);
// 监听内容变化,重置内容安全检测状态
useEffect(() => {
- setModerationResult(null)
- setModerationDesc('')
- setModerationLevel(null)
+ setModerationResult(null);
+ setModerationDesc("");
+ setModerationLevel(null);
}, [
commonPubParams.des,
expandedPubItem?.params.des,
- pubListChoosed.map(item => item.params.des).join(','),
- ])
+ pubListChoosed.map((item) => item.params.des).join(","),
+ ]);
// 当内容被清空时,也重置检测状态
useEffect(() => {
if (!hasDescription) {
- setModerationResult(null)
- setModerationDesc('')
- setModerationLevel(null)
+ setModerationResult(null);
+ setModerationDesc("");
+ setModerationLevel(null);
}
- }, [hasDescription])
+ }, [hasDescription]);
useEffect(() => {
if (open) {
- isInit.current = true
- init(accounts, defaultAccountId)
+ isInit.current = true;
+ init(accounts, defaultAccountId);
// 获取聊天模型列表(使用 sessionStorage 缓存)
- const cachedModels = sessionStorage.getItem('ai_chat_models')
+ const cachedModels = sessionStorage.getItem("ai_chat_models");
if (cachedModels) {
try {
- setChatModels(JSON.parse(cachedModels))
- }
- catch (error) {
- console.error(t('messages.parseCachedChatModelsFailed' as any), error)
+ setChatModels(JSON.parse(cachedModels));
+ } catch (error) {
+ console.error(
+ t("messages.parseCachedChatModelsFailed" as any),
+ error
+ );
}
- }
- else {
+ } else {
// 如果没有缓存,则请求
- getChatModels().then((res: any) => {
- if (res?.code === 0 && res.data && Array.isArray(res.data)) {
- setChatModels(res.data)
- sessionStorage.setItem('ai_chat_models', JSON.stringify(res.data))
- }
- }).catch((error) => {
- console.error(t('messages.getChatModelsFailed' as any), error)
- })
+ getChatModels()
+ .then((res: any) => {
+ if (res?.code === 0 && res.data && Array.isArray(res.data)) {
+ setChatModels(res.data);
+ sessionStorage.setItem(
+ "ai_chat_models",
+ JSON.stringify(res.data)
+ );
+ }
+ })
+ .catch((error) => {
+ console.error(t("messages.getChatModelsFailed" as any), error);
+ });
}
- }
- else {
+ } else {
// 弹窗关闭时只清除选中状态和步骤,保留pubList以便下次打开
- isClear.current = true
- setPubListChoosed([])
- setStep(0)
- setExpandedPubItem(undefined)
- clear()
+ isClear.current = true;
+ setPubListChoosed([]);
+ setStep(0);
+ setExpandedPubItem(undefined);
+ clear();
}
- }, [open])
+ }, [open]);
// 离线账号(status === 0)不可参与发布:如被默认选中则自动移除
useEffect(() => {
const filtered = pubListChoosed.filter(
- item => item.account.status !== 0,
- )
+ (item) => item.account.status !== 0
+ );
if (filtered.length !== pubListChoosed.length) {
- setPubListChoosed(filtered)
+ setPubListChoosed(filtered);
}
- }, [pubListChoosed, setPubListChoosed])
+ }, [pubListChoosed, setPubListChoosed]);
// 移除PC端不支持的平台账户过滤逻辑,改为在UI中显示遮罩
// 关闭弹框并确认关闭
const closeDialog = useCallback(() => {
confirm({
- title: t('confirmClose.title'),
+ title: t("confirmClose.title"),
icon: <ExclamationCircleFilled />,
- content: t('confirmClose.content'),
- okType: 'destructive',
+ content: t("confirmClose.content"),
+ okType: "destructive",
centered: true,
- cancelText: t('buttons.cancel'),
+ cancelText: t("buttons.cancel"),
onOk() {
- onClose()
+ onClose();
},
- })
- }, [onClose, t])
+ });
+ }, [onClose, t]);
// 是否打开右侧预览
const openRight = useMemo(() => {
if (step === 0) {
- return pubListChoosed.length !== 0
- }
- else {
- return expandedPubItem !== undefined
+ return pubListChoosed.length !== 0;
+ } else {
+ return expandedPubItem !== undefined;
}
- }, [pubListChoosed, expandedPubItem, step])
+ }, [pubListChoosed, expandedPubItem, step]);
// 是否打开左侧
const openLeftSide = useMemo(() => {
- if (!openLeft)
- return false
+ if (!openLeft) return false;
// 如果用户主动打开了AI助手(openLeft=true),就保持打开状态
// 不再依赖于 pubListChoosed 或 expandedPubItem 的状态
- return true
- }, [openLeft])
+ return true;
+ }, [openLeft]);
useEffect(() => {
- setErrParamsMap(errParamsMap)
- }, [errParamsMap])
+ setErrParamsMap(errParamsMap);
+ }, [errParamsMap]);
useEffect(() => {
- setWarningParamsMap(warningParamsMap)
- }, [warningParamsMap])
+ setWarningParamsMap(warningParamsMap);
+ }, [warningParamsMap]);
/**
* 检查平台是否由插件支持
* @param platType 平台类型
* @returns 是否由插件支持
*/
- const isPluginSupportedPlatform = useCallback((platType: PlatType): boolean => {
- return PLUGIN_SUPPORTED_PLATFORMS.includes(platType as PluginPlatformType)
- }, [])
-
+ const isPluginSupportedPlatform = useCallback(
+ (platType: PlatType): boolean => {
+ return PLUGIN_SUPPORTED_PLATFORMS.includes(
+ platType as PluginPlatformType
+ );
+ },
+ []
+ );
/**
* Publish content with scheduled time (from calendar picker)
@@ -609,68 +609,77 @@ const PublishDialog = memo(
* 3. 显示发布详情弹框
*/
const pubClick = useCallback(async () => {
- setCreateLoading(true)
+ setCreateLoading(true);
const publishTime = getUtcDays(
- pubTime || getDays().add(5, 'second'),
- ).format()
+ pubTime || getDays().add(5, "second")
+ ).format();
// 分离 API 发布列表和插件发布列表
const apiPublishItems = pubListChoosed.filter(
- item => !isPluginSupportedPlatform(item.account.type),
- )
- const pluginPublishItems = pubListChoosed.filter(
- item => isPluginSupportedPlatform(item.account.type),
- )
+ (item) => !isPluginSupportedPlatform(item.account.type)
+ );
+ const pluginPublishItems = pubListChoosed.filter((item) =>
+ isPluginSupportedPlatform(item.account.type)
+ );
// 如果有插件发布项,创建发布任务并显示详情弹框
- let taskId: string | null = null
+ let taskId: string | null = null;
// 存储每个发布项对应的平台任务ID,用于后续精确更新
- const platformTaskIdMap = new Map<string, string>()
+ const platformTaskIdMap = new Map<string, string>();
if (pluginPublishItems.length > 0) {
- const { addPublishTask, getPublishTask } = usePluginStore.getState()
+ const { addPublishTask, getPublishTask } = usePluginStore.getState();
// 创建平台任务列表,为每个任务生成唯一ID和requestId
- const platformTasks: PlatformPublishTask[] = pluginPublishItems.map((item) => {
- // 使用账号ID生成唯一的平台任务ID
- const platformTaskId = `${item.account.type}-${item.account.id}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
- // 生成唯一的 requestId,用于插件回调匹配
- const requestId = `req-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`
- // 保存映射关系,用于后续更新(保存 requestId 而非 platformTaskId)
- platformTaskIdMap.set(item.account.id, requestId)
-
- return {
- id: platformTaskId,
- requestId, // 创建时就指定,传给插件后回调时匹配
- platform: item.account.type as PluginPlatformType,
- accountId: item.account.id,
- params: {
+ const platformTasks: PlatformPublishTask[] = pluginPublishItems.map(
+ (item) => {
+ // 使用账号ID生成唯一的平台任务ID
+ const platformTaskId = `${item.account.type}-${
+ item.account.id
+ }-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
+ // 生成唯一的 requestId,用于插件回调匹配
+ const requestId = `req-${Date.now()}-${Math.random()
+ .toString(36)
+ .slice(2, 10)}`;
+ // 保存映射关系,用于后续更新(保存 requestId 而非 platformTaskId)
+ platformTaskIdMap.set(item.account.id, requestId);
+
+ return {
+ id: platformTaskId,
+ requestId, // 创建时就指定,传给插件后回调时匹配
platform: item.account.type as PluginPlatformType,
- type: item.params.video?.ossUrl ? 'video' : 'image',
- title: item.params.title || '',
- desc: item.params.des || '',
- topics: item.params.topics || [],
- } as PluginPublishParams,
- status: PlatformTaskStatus.PENDING,
- progress: null,
- result: null,
- startTime: null,
- endTime: null,
- error: null,
+ accountId: item.account.id,
+ params: {
+ platform: item.account.type as PluginPlatformType,
+ type: item.params.video?.ossUrl ? "video" : "image",
+ title: item.params.title || "",
+ desc: item.params.des || "",
+ topics: item.params.topics || [],
+ } as PluginPublishParams,
+ status: PlatformTaskStatus.PENDING,
+ progress: null,
+ result: null,
+ startTime: null,
+ endTime: null,
+ error: null,
+ };
}
- })
+ );
// 添加发布任务
taskId = addPublishTask({
- title: pubListChoosed[0]?.params.title || pubListChoosed[0]?.params.des?.slice(0, 20) || t('title'),
+ title:
+ pubListChoosed[0]?.params.title ||
+ pubListChoosed[0]?.params.des?.slice(0, 20) ||
+ t("title"),
description: pubListChoosed[0]?.params.des?.slice(0, 100),
platformTasks,
- })
+ });
// 设置任务ID并显示弹框
- setCurrentPublishTaskId(taskId)
- setPublishDetailVisible(true)
+ setCurrentPublishTaskId(taskId);
+ setPublishDetailVisible(true);
}
// 1. 先执行 API 发布(非插件支持平台)
@@ -681,26 +690,26 @@ const PublishDialog = memo(
type: item.params.video?.cover.ossUrl
? PubType.VIDEO
: PubType.ImageText,
- title: item.params.title || '',
+ title: item.params.title || "",
desc: item.params.des,
accountId: item.account.id,
accountType: item.account.type,
videoUrl: item.params.video?.ossUrl,
coverUrl:
- item.params.video?.cover.ossUrl
- || (item.params.images && item.params.images.length > 0
+ item.params.video?.cover.ossUrl ||
+ (item.params.images && item.params.images.length > 0
? item.params.images[0].ossUrl
: undefined),
imgUrlList:
item.params.images
- ?.map(v => v.ossUrl)
+ ?.map((v) => v.ossUrl)
.filter((url): url is string => url !== undefined) || [],
publishTime,
option: item.params.option,
- })
+ });
if (res?.code !== 0) {
- setCreateLoading(false)
- return
+ setCreateLoading(false);
+ return;
}
}
@@ -714,9 +723,9 @@ const PublishDialog = memo(
publishTime,
onComplete: () => {
// 发布完成后刷新发布记录
- useCalendarTiming.getState().getPubRecord()
+ useCalendarTiming.getState().getPubRecord();
},
- })
+ });
}
// 如果抑制自动发布,跳过自动发布流程
@@ -724,6 +733,12 @@ const PublishDialog = memo(
setCreateLoading(false)
return
}
+
+ // 给用户提示:发布已提交,可能需要一些时间处理(符合 TikTok API 客户端要求)
+ toast.success(t("messages.publishSubmitted" as any), {
+ key: "publish_submitted",
+ duration: 3,
+ });
// 关闭发布弹框
onClose()
@@ -741,177 +756,202 @@ const PublishDialog = memo(
}, [pubListChoosed, pubTime, isPluginSupportedPlatform, t])
// 处理划词操作
- const handleTextSelection = useCallback((action: AIAction, selectedText: string) => {
- // 只有当面板未打开时才设置,避免重复触发导致状态混乱
- if (!openLeft) {
- setOpenLeft(true)
- }
- // 等待面板打开动画完成后调用AI处理并自动发送
- setTimeout(() => {
- aiAssistantRef.current?.processText(selectedText, action)
- }, openLeft ? 100 : 500) // 如果已打开,减少延迟
- }, [openLeft, setOpenLeft])
+ const handleTextSelection = useCallback(
+ (action: AIAction, selectedText: string) => {
+ // 只有当面板未打开时才设置,避免重复触发导致状态混乱
+ if (!openLeft) {
+ setOpenLeft(true);
+ }
+ // 等待面板打开动画完成后调用AI处理并自动发送
+ setTimeout(
+ () => {
+ aiAssistantRef.current?.processText(selectedText, action);
+ },
+ openLeft ? 100 : 500
+ ); // 如果已打开,减少延迟
+ },
+ [openLeft, setOpenLeft]
+ );
// 处理图生图
- const handleImageToImage = useCallback((imageFile: IImgFile) => {
- // 打开AI面板
- if (!openLeft) {
- setOpenLeft(true)
- }
- // 等待面板打开动画完成后调用图生图功能
- setTimeout(() => {
- aiAssistantRef.current?.processImageToImage(imageFile.file, '')
- }, openLeft ? 100 : 500)
- }, [openLeft, setOpenLeft])
+ const handleImageToImage = useCallback(
+ (imageFile: IImgFile) => {
+ // 打开AI面板
+ if (!openLeft) {
+ setOpenLeft(true);
+ }
+ // 等待面板打开动画完成后调用图生图功能
+ setTimeout(
+ () => {
+ aiAssistantRef.current?.processImageToImage(imageFile.file, "");
+ },
+ openLeft ? 100 : 500
+ );
+ },
+ [openLeft, setOpenLeft]
+ );
// Sync AI content to editor
- const handleSyncToEditor = useCallback(async (content: string, images?: IImgFile[], video?: IVideoFile, append?: boolean) => {
- // Handle image upload
- if (images && images.length > 0) {
- const uploadsWithImages: Array<{ image: IImgFile, promise: Promise<any>, cancel: () => void }> = []
-
- for (const image of images) {
- const handle = enqueueUpload({
- file: image.file,
- fileName: image.filename,
- type: UploadTaskTypeEnum.Image,
- })
-
- const imageWithTask: IImgFile = {
- ...image,
- uploadTaskId: handle.taskId,
+ const handleSyncToEditor = useCallback(
+ async (
+ content: string,
+ images?: IImgFile[],
+ video?: IVideoFile,
+ append?: boolean
+ ) => {
+ // Handle image upload
+ if (images && images.length > 0) {
+ const uploadsWithImages: Array<{
+ image: IImgFile;
+ promise: Promise<any>;
+ cancel: () => void;
+ }> = [];
+
+ for (const image of images) {
+ const handle = enqueueUpload({
+ file: image.file,
+ fileName: image.filename,
+ type: UploadTaskTypeEnum.Image,
+ });
+
+ const imageWithTask: IImgFile = {
+ ...image,
+ uploadTaskId: handle.taskId,
+ };
+
+ uploadsWithImages.push({
+ image: imageWithTask,
+ promise: handle.promise,
+ cancel: handle.cancel,
+ });
}
- uploadsWithImages.push({
- image: imageWithTask,
- promise: handle.promise,
- cancel: handle.cancel,
- })
+ // Use images with uploadTaskId
+ images = uploadsWithImages.map((item) => item.image);
}
- // Use images with uploadTaskId
- images = uploadsWithImages.map(item => item.image)
- }
-
- // Handle video upload (AI-generated videos already have ossUrl, only need to upload cover)
- if (video) {
- // If video already has ossUrl (AI-generated), only upload cover
- if (video.ossUrl && !video.cover.ossUrl) {
- const coverHandle = enqueueUpload({
- file: video.cover.file,
- fileName: video.cover.filename,
- type: UploadTaskTypeEnum.Image,
- })
-
- video = {
- ...video,
- uploadTaskIds: {
- cover: coverHandle.taskId,
- },
+ // Handle video upload (AI-generated videos already have ossUrl, only need to upload cover)
+ if (video) {
+ // If video already has ossUrl (AI-generated), only upload cover
+ if (video.ossUrl && !video.cover.ossUrl) {
+ const coverHandle = enqueueUpload({
+ file: video.cover.file,
+ fileName: video.cover.filename,
+ type: UploadTaskTypeEnum.Image,
+ });
+
+ video = {
+ ...video,
+ uploadTaskIds: {
+ cover: coverHandle.taskId,
+ },
+ };
}
- }
- // If video doesn't have ossUrl (user uploaded), need to upload both video and cover
- else if (!video.ossUrl) {
- const videoHandle = enqueueUpload({
- file: video.file,
- fileName: video.filename,
- type: UploadTaskTypeEnum.Video,
- })
-
- const coverHandle = enqueueUpload({
- file: video.cover.file,
- fileName: video.cover.filename,
- type: UploadTaskTypeEnum.Image,
- })
-
- video = {
- ...video,
- uploadTaskIds: {
- video: videoHandle.taskId,
- cover: coverHandle.taskId,
- },
+ // If video doesn't have ossUrl (user uploaded), need to upload both video and cover
+ else if (!video.ossUrl) {
+ const videoHandle = enqueueUpload({
+ file: video.file,
+ fileName: video.filename,
+ type: UploadTaskTypeEnum.Video,
+ });
+
+ const coverHandle = enqueueUpload({
+ file: video.cover.file,
+ fileName: video.cover.filename,
+ type: UploadTaskTypeEnum.Image,
+ });
+
+ video = {
+ ...video,
+ uploadTaskIds: {
+ video: videoHandle.taskId,
+ cover: coverHandle.taskId,
+ },
+ };
}
}
- }
- // If only one account, update directly
- if (pubListChoosed.length === 1) {
- const params: any = {}
- // Only update content if not empty string
- if (content) {
- // If append mode, append content to existing text
- if (append && pubListChoosed[0].params.des) {
- params.des = `${pubListChoosed[0].params.des}\n${content}`
+ // If only one account, update directly
+ if (pubListChoosed.length === 1) {
+ const params: any = {};
+ // Only update content if not empty string
+ if (content) {
+ // If append mode, append content to existing text
+ if (append && pubListChoosed[0].params.des) {
+ params.des = `${pubListChoosed[0].params.des}\n${content}`;
+ } else {
+ params.des = content;
+ }
}
- else {
- params.des = content
+ // Video and images cannot exist simultaneously
+ if (video) {
+ params.video = video;
+ // If has video, clear images
+ params.images = [];
+ } else if (images && images.length > 0) {
+ params.images = images;
}
+ setOnePubParams(params, pubListChoosed[0].account.id);
}
- // Video and images cannot exist simultaneously
- if (video) {
- params.video = video
- // If has video, clear images
- params.images = []
- }
- else if (images && images.length > 0) {
- params.images = images
- }
- setOnePubParams(params, pubListChoosed[0].account.id)
- }
- // If multiple accounts and in step 0, update common params
- else if (pubListChoosed.length >= 2 && step === 0) {
- const params: any = {}
- // Only update content if not empty string
- if (content) {
- // If append mode, append content to existing text
- if (append && commonPubParams.des) {
- params.des = `${commonPubParams.des}\n${content}`
+ // If multiple accounts and in step 0, update common params
+ else if (pubListChoosed.length >= 2 && step === 0) {
+ const params: any = {};
+ // Only update content if not empty string
+ if (content) {
+ // If append mode, append content to existing text
+ if (append && commonPubParams.des) {
+ params.des = `${commonPubParams.des}\n${content}`;
+ } else {
+ params.des = content;
+ }
}
- else {
- params.des = content
+ // Video and images cannot exist simultaneously
+ if (video) {
+ params.video = video;
+ // If has video, clear images
+ params.images = [];
+ } else if (images && images.length > 0) {
+ params.images = images;
}
+ setAccountAllParams(params);
}
- // Video and images cannot exist simultaneously
- if (video) {
- params.video = video
- // If has video, clear images
- params.images = []
- }
- else if (images && images.length > 0) {
- params.images = images
- }
- setAccountAllParams(params)
- }
- // If in step 1 and has expanded item, update that item
- else if (step === 1 && expandedPubItem) {
- const params: any = {}
- // Only update content if not empty string
- if (content) {
- // If append mode, append content to existing text
- if (append && expandedPubItem.params.des) {
- params.des = `${expandedPubItem.params.des}\n${content}`
+ // If in step 1 and has expanded item, update that item
+ else if (step === 1 && expandedPubItem) {
+ const params: any = {};
+ // Only update content if not empty string
+ if (content) {
+ // If append mode, append content to existing text
+ if (append && expandedPubItem.params.des) {
+ params.des = `${expandedPubItem.params.des}\n${content}`;
+ } else {
+ params.des = content;
+ }
}
- else {
- params.des = content
+ // Video and images cannot exist simultaneously
+ if (video) {
+ params.video = video;
+ // If has video, clear images
+ params.images = [];
+ } else if (images && images.length > 0) {
+ params.images = images;
}
+ setOnePubParams(params, expandedPubItem.account.id);
}
- // Video and images cannot exist simultaneously
- if (video) {
- params.video = video
- // If has video, clear images
- params.images = []
- }
- else if (images && images.length > 0) {
- params.images = images
- }
- setOnePubParams(params, expandedPubItem.account.id)
- }
- }, [pubListChoosed, step, expandedPubItem, setOnePubParams, setAccountAllParams, enqueueUpload])
+ },
+ [
+ pubListChoosed,
+ step,
+ expandedPubItem,
+ setOnePubParams,
+ setAccountAllParams,
+ enqueueUpload,
+ ]
+ );
const imperativeHandle: IPublishDialogRef = {
setPubTime,
- }
- useImperativeHandle(ref, () => imperativeHandle)
+ };
+ useImperativeHandle(ref, () => imperativeHandle);
return (
<>
@@ -923,435 +963,450 @@ const PublishDialog = memo(
footer={null}
width="auto"
>
- {width >= 1400 && (
- <CSSTransition
- in={openLeftSide}
- timeout={300}
- classNames="left"
- unmountOnExit
+ <div className="flex-1 flex">
+ {width >= 1400 && (
+ <CSSTransition
+ in={openLeftSide}
+ timeout={300}
+ classNames="left"
+ unmountOnExit
+ >
+ <PublishDialogAi
+ ref={aiAssistantRef}
+ onClose={() => setOpenLeft(false)}
+ onSyncToEditor={handleSyncToEditor}
+ chatModels={chatModels}
+ />
+ </CSSTransition>
+ )}
+
+ <div
+ className="publishDialog-wrapper"
+ onClick={() => {
+ if (step === 1) {
+ setExpandedPubItem(undefined);
+ }
+ }}
>
- <PublishDialogAi
- ref={aiAssistantRef}
- onClose={() => setOpenLeft(false)}
- onSyncToEditor={handleSyncToEditor}
- chatModels={chatModels}
+ {/* 划词工具栏 */}
+ <TextSelectionToolbar
+ containerRef={contentAreaRef}
+ onAction={handleTextSelection}
/>
- </CSSTransition>
- )}
-
- <div
- className="publishDialog-wrapper"
- onClick={() => {
- if (step === 1) {
- setExpandedPubItem(undefined)
- }
- }}
- >
- {/* 划词工具栏 */}
- <TextSelectionToolbar
- containerRef={contentAreaRef}
- onAction={handleTextSelection}
- />
-
- <div className="publishDialog-con" ref={contentAreaRef}>
- <div className="publishDialog-con-head">
- <span className="publishDialog-con-head-title">
- {t('title')}
- </span>
- <CloseOutlined
- onClick={closeDialog}
- style={{
- fontSize: '16px',
- cursor: 'pointer',
- color: '#999',
- }}
- />
- </div>
- <div className="publishDialog-con-acconts">
- {pubList.map((pubItem) => {
- const platConfig = AccountPlatInfoMap.get(
- pubItem.account.type,
- )!
- const isChoosed = pubListChoosed.find(
- v => v.account.id === pubItem.account.id,
- )
- const isOffline = pubItem.account.status === 0
- const isPcNotSupported
- = platConfig && platConfig.pcNoThis === true
-
- return (
- <Tooltip
- title={
- isPcNotSupported
- ? t('tips.pcNotSupported' as any)
- : isOffline
- ? t('tips.accountOffline' as any)
+
+ <div className="publishDialog-con" ref={contentAreaRef}>
+ <div className="publishDialog-con-head">
+ <span className="publishDialog-con-head-title">
+ {t("title")}
+ </span>
+ <CloseOutlined
+ onClick={closeDialog}
+ style={{
+ fontSize: "16px",
+ cursor: "pointer",
+ color: "#999",
+ }}
+ />
+ </div>
+ <div className="publishDialog-con-acconts">
+ {pubList.map((pubItem) => {
+ const platConfig = AccountPlatInfoMap.get(
+ pubItem.account.type
+ )!;
+ const isChoosed = pubListChoosed.find(
+ (v) => v.account.id === pubItem.account.id
+ );
+ const isOffline = pubItem.account.status === 0;
+ const isPcNotSupported =
+ platConfig && platConfig.pcNoThis === true;
+
+ return (
+ <Tooltip
+ title={
+ isPcNotSupported
+ ? t("tips.pcNotSupported" as any)
+ : isOffline
+ ? t("tips.accountOffline" as any)
: undefined
- }
- key={pubItem.account.id}
- >
- <div
- className={[
- 'publishDialog-con-acconts-item',
- isChoosed
- ? 'publishDialog-con-acconts-item--active'
- : '',
- ].join(' ')}
- style={{
- borderColor: isChoosed
- ? platConfig.themeColor
- : 'transparent',
- }}
- onClick={(e) => {
- e.stopPropagation()
- // 离线账户的点击由头像容器处理,这里不处理
- if (isOffline) {
- return
- }
- if (isPcNotSupported) {
- setCurrentPlatform(platConfig?.name || '')
- setDownloadModalVisible(true)
- return
- }
- const newPubListChoosed = [...pubListChoosed]
- // 查找当前账户是否已被选择
- const index = newPubListChoosed.findIndex(
- v => v.account.id === pubItem.account.id,
- )
- if (index !== -1) {
- newPubListChoosed.splice(index, 1)
- }
- else {
- newPubListChoosed.push(pubItem)
- }
- // 是否自动回到第一步
- if (newPubListChoosed.length === 0 && step === 1) {
- const isBack = newPubListChoosed.every(
- v =>
- !v.params.des
- && !v.params.video
- && !v.params.images?.length,
- )
- if (isBack) {
- setStep(0)
+ }
+ key={pubItem.account.id}
+ >
+ <div
+ className={[
+ "publishDialog-con-acconts-item",
+ isChoosed
+ ? "publishDialog-con-acconts-item--active"
+ : "",
+ ].join(" ")}
+ style={{
+ borderColor: isChoosed
+ ? platConfig.themeColor
+ : "transparent",
+ }}
+ onClick={(e) => {
+ e.stopPropagation();
+ // 离线账户的点击由头像容器处理,这里不处理
+ if (isOffline) {
+ return;
}
- }
- // 是否自动前往第二步
- if (step === 0 && newPubListChoosed.length !== 0) {
- const isFront = newPubListChoosed.every(
- v =>
- v.params.des
- || v.params.video
- || v.params.images?.length !== 0,
- )
- if (isFront) {
- setStep(1)
+ if (isPcNotSupported) {
+ setCurrentPlatform(platConfig?.name || "");
+ setDownloadModalVisible(true);
+ return;
}
- }
- if (newPubListChoosed.length === 1) {
- setExpandedPubItem(newPubListChoosed[0])
- }
- setPubListChoosed(newPubListChoosed)
- }}
- >
- {/* 账号头像:离线或PC不支持显示遮罩并禁用 */}
- <div style={{ position: 'relative' }}>
- <AvatarPlat
- className={`publishDialog-con-acconts-item-avatar ${!isChoosed || isOffline || isPcNotSupported ? 'disabled' : ''}`}
- account={pubItem.account}
- size="large"
- disabled={
- isOffline || !isChoosed || isPcNotSupported
+ const newPubListChoosed = [...pubListChoosed];
+ // 查找当前账户是否已被选择
+ const index = newPubListChoosed.findIndex(
+ (v) => v.account.id === pubItem.account.id
+ );
+ if (index !== -1) {
+ newPubListChoosed.splice(index, 1);
+ } else {
+ newPubListChoosed.push(pubItem);
}
- />
- {isOffline && (
- <div
- onClick={(e) => {
- // 小红书平台即使是掉线状态也显示下载App弹窗
- if (pubItem.account.type === PlatType.Xhs) {
- setCurrentPlatform(t('rednote' as any))
- setDownloadModalVisible(true)
- return
- }
- // 其他平台的离线账户触发授权跳转
- if (isOffline) {
- handleOfflineAvatarClick(pubItem.account)
- }
- // 正常账户的点击事件由父容器处理,这里不需要额外处理
- }}
- style={{
- position: 'absolute',
- inset: 0,
- background: 'rgba(0,0,0,0.45)',
- borderRadius: '50%',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- color: '#fff',
- fontSize: 12,
- fontWeight: 600,
- pointerEvents: 'auto',
- cursor: 'pointer',
- }}
- >
- {t('badges.offline' as any)}
- </div>
- )}
- {isPcNotSupported && !isOffline && (
- <div
- style={{
- position: 'absolute',
- inset: 0,
- background: 'rgba(0,0,0,0.6)',
- borderRadius: '50%',
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- color: '#fff',
- fontSize: 10,
- fontWeight: 600,
- pointerEvents: 'none',
- textAlign: 'center',
- lineHeight: 1.2,
- }}
- >
- APP
- </div>
- )}
+ // 是否自动回到第一步
+ if (
+ newPubListChoosed.length === 0 &&
+ step === 1
+ ) {
+ const isBack = newPubListChoosed.every(
+ (v) =>
+ !v.params.des &&
+ !v.params.video &&
+ !v.params.images?.length
+ );
+ if (isBack) {
+ setStep(0);
+ }
+ }
+ // 是否自动前往第二步
+ if (
+ step === 0 &&
+ newPubListChoosed.length !== 0
+ ) {
+ const isFront = newPubListChoosed.every(
+ (v) =>
+ v.params.des ||
+ v.params.video ||
+ v.params.images?.length !== 0
+ );
+ if (isFront) {
+ setStep(1);
+ }
+ }
+ if (newPubListChoosed.length === 1) {
+ setExpandedPubItem(newPubListChoosed[0]);
+ }
+ setPubListChoosed(newPubListChoosed);
+ }}
+ >
+ {/* 账号头像:离线或PC不支持显示遮罩并禁用 */}
+ <div style={{ position: "relative" }}>
+ <AvatarPlat
+ className={`publishDialog-con-acconts-item-avatar ${
+ !isChoosed || isOffline || isPcNotSupported
+ ? "disabled"
+ : ""
+ }`}
+ account={pubItem.account}
+ size="large"
+ disabled={
+ isOffline || !isChoosed || isPcNotSupported
+ }
+ />
+ {isOffline && (
+ <div
+ onClick={(e) => {
+ // 小红书平台即使是掉线状态也显示下载App弹窗
+ if (pubItem.account.type === PlatType.Xhs) {
+ setCurrentPlatform(t("rednote" as any));
+ setDownloadModalVisible(true);
+ return;
+ }
+ // 其他平台的离线账户触发授权跳转
+ if (isOffline) {
+ handleOfflineAvatarClick(pubItem.account);
+ }
+ // 正常账户的点击事件由父容器处理,这里不需要额外处理
+ }}
+ style={{
+ position: "absolute",
+ inset: 0,
+ background: "rgba(0,0,0,0.45)",
+ borderRadius: "50%",
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ color: "#fff",
+ fontSize: 12,
+ fontWeight: 600,
+ pointerEvents: "auto",
+ cursor: "pointer",
+ }}
+ >
+ {t("badges.offline" as any)}
+ </div>
+ )}
+ {isPcNotSupported && !isOffline && (
+ <div
+ style={{
+ position: "absolute",
+ inset: 0,
+ background: "rgba(0,0,0,0.6)",
+ borderRadius: "50%",
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ color: "#fff",
+ fontSize: 10,
+ fontWeight: 600,
+ pointerEvents: "none",
+ textAlign: "center",
+ lineHeight: 1.2,
+ }}
+ >
+ APP
+ </div>
+ )}
+ </div>
</div>
- </div>
- </Tooltip>
- )
- })}
- </div>
-
- <div className="publishDialog-paramsSet">
- {step === 0
- ? (
- <>
- {pubListChoosed.length == 1 && (
- <PlatParamsSetting pubItem={pubListChoosed[0]} onImageToImage={handleImageToImage} />
- )}
- {pubListChoosed.length >= 2 && (
- <PubParmasTextarea
- key={`${commonPubParams.images?.length || 0}-${commonPubParams.video ? 'video' : 'no-video'}`}
- platType={PlatType.Instagram}
- rows={16}
- desValue={commonPubParams.des}
- videoFileValue={commonPubParams.video}
- imageFileListValue={commonPubParams.images}
- onChange={(values) => {
- setAccountAllParams({
- des: values.value,
- images: values.imgs,
- video: values.video,
- })
- }}
+ </Tooltip>
+ );
+ })}
+ </div>
+
+ <div className="publishDialog-paramsSet">
+ {step === 0 ? (
+ <>
+ {pubListChoosed.length == 1 && (
+ <PlatParamsSetting
+ pubItem={pubListChoosed[0]}
+ onImageToImage={handleImageToImage}
+ />
+ )}
+ {pubListChoosed.length >= 2 && (
+ <PubParmasTextarea
+ key={`${commonPubParams.images?.length || 0}-${
+ commonPubParams.video ? "video" : "no-video"
+ }`}
+ platType={PlatType.Instagram}
+ rows={16}
+ desValue={commonPubParams.des}
+ videoFileValue={commonPubParams.video}
+ imageFileListValue={commonPubParams.images}
+ onChange={(values) => {
+ setAccountAllParams({
+ des: values.value,
+ images: values.imgs,
+ video: values.video,
+ });
+ }}
+ onImageToImage={handleImageToImage}
+ />
+ )}
+ </>
+ ) : (
+ <>
+ {pubListChoosed.map((v) => {
+ return (
+ <PlatParamsSetting
+ key={v.account.id}
+ pubItem={v}
+ style={{ marginBottom: "12px" }}
onImageToImage={handleImageToImage}
/>
- )}
- </>
- )
- : (
- <>
- {pubListChoosed.map((v) => {
- return (
- <PlatParamsSetting
- key={v.account.id}
- pubItem={v}
- style={{ marginBottom: '12px' }}
- onImageToImage={handleImageToImage}
- />
- )
- })}
- </>
- )}
-
- {pubListChoosed.length === 0
- && pubList.some(
- v =>
- v.params.des
- || v.params.video
- || (v.params.images && v.params.images.length > 0),
- )
- ? (
- <div
- className="publishDialog-con-tips"
- style={{ height: '400px' }}
- >
- {t('tips.workSaved')}
- </div>
- )
- : (
- <>
- {pubListChoosed.length === 0 && (
- <div className="publishDialog-con-tips">
- {t('tips.selectAccount')}
- </div>
- )}
- </>
- )}
+ );
+ })}
+ </>
+ )}
+
+ {pubListChoosed.length === 0 &&
+ pubList.some(
+ (v) =>
+ v.params.des ||
+ v.params.video ||
+ (v.params.images && v.params.images.length > 0)
+ ) ? (
+ <div
+ className="publishDialog-con-tips"
+ style={{ height: "400px" }}
+ >
+ {t("tips.workSaved")}
+ </div>
+ ) : (
+ <>
+ {pubListChoosed.length === 0 && (
+ <div className="publishDialog-con-tips">
+ {t("tips.selectAccount")}
+ </div>
+ )}
+ </>
+ )}
+ </div>
</div>
- </div>
- <div
- className="publishDialog-footer"
- onClick={e => e.stopPropagation()}
- >
<div
- className="publishDialog-footer-btns"
+ className="publishDialog-footer"
+ onClick={(e) => e.stopPropagation()}
>
- {step === 0 && pubListChoosed.length >= 2
- ? (
- <Button
- size="large"
- onClick={() => {
- setExpandedPubItem(undefined)
- setStep(1)
+ <div className="publishDialog-footer-btns">
+ {step === 0 && pubListChoosed.length >= 2 ? (
+ <Button
+ size="large"
+ onClick={() => {
+ setExpandedPubItem(undefined);
+ setStep(1);
+ }}
+ >
+ {t("buttons.customizePerAccount")}
+ <ArrowRightOutlined />
+ </Button>
+ ) : (
+ <>
+ <div
+ style={{
+ display: "flex",
+ alignItems: "center",
+ gap: 12,
}}
>
- {t('buttons.customizePerAccount')}
- <ArrowRightOutlined />
- </Button>
- )
- : (
- <>
- <div
- style={{
- display: 'flex',
- alignItems: 'center',
- gap: 12,
- }}
- >
- {moderationResult !== null && (
- <div
- style={{ display: 'flex', flexDirection: 'column' }}
+ {moderationResult !== null && (
+ <div
+ style={{
+ display: "flex",
+ flexDirection: "column",
+ }}
+ >
+ <span
+ style={{
+ fontSize: 14,
+ color: moderationResult
+ ? "#52c41a"
+ : "#ff4d4f",
+ fontWeight: 500,
+ }}
>
+ {moderationResult
+ ? t("actions.contentSafe" as any)
+ : moderationLevel?.riskLevel
+ ? `${t("actions.riskLevel" as any)} ${
+ moderationLevel.riskLevel
+ }`
+ : t("actions.contentUnsafe" as any)}
+ </span>
+ {!moderationResult && !!moderationDesc && (
<span
style={{
- fontSize: 14,
- color: moderationResult ? '#52c41a' : '#ff4d4f',
- fontWeight: 500,
+ fontSize: 12,
+ color: "#ff4d4f",
+ maxWidth: 360,
+ whiteSpace: "pre-wrap",
+ display: "inline-flex",
+ alignItems: "center",
+ gap: 6,
}}
>
- {moderationResult
- ? t('actions.contentSafe' as any)
- : moderationLevel?.riskLevel
- ? `${t('actions.riskLevel' as any)} ${moderationLevel.riskLevel}`
- : t('actions.contentUnsafe' as any)}
- </span>
- {!moderationResult && !!moderationDesc && (
- <span
- style={{
- fontSize: 12,
- color: '#ff4d4f',
- maxWidth: 360,
- whiteSpace: 'pre-wrap',
- display: 'inline-flex',
- alignItems: 'center',
- gap: 6,
- }}
+ {moderationDesc}
+ <Tooltip
+ title={moderationLevel?.riskTips || ""}
+ placement="top"
>
- {moderationDesc}
- <Tooltip
- title={moderationLevel?.riskTips || ''}
- placement="top"
- >
- <InfoCircleOutlined
- style={{ color: '#ff4d4f' }}
- />
- </Tooltip>
- </span>
- )}
- </div>
- )}
-
- {hasDescription && needsContentModeration && (
- <Button
- size="large"
- loading={moderationLoading}
- onClick={handleContentModeration}
- type={
- moderationResult === true
- ? 'primary'
- : moderationResult === false
- ? 'default'
- : 'default'
- }
- style={{
- backgroundColor:
+ <InfoCircleOutlined
+ style={{ color: "#ff4d4f" }}
+ />
+ </Tooltip>
+ </span>
+ )}
+ </div>
+ )}
+
+ {hasDescription && needsContentModeration && (
+ <Button
+ size="large"
+ loading={moderationLoading}
+ onClick={handleContentModeration}
+ type={
moderationResult === true
- ? '#52c41a'
+ ? "primary"
: moderationResult === false
- ? '#ff4d4f'
+ ? "default"
+ : "default"
+ }
+ style={{
+ backgroundColor:
+ moderationResult === true
+ ? "#52c41a"
+ : moderationResult === false
+ ? "#ff4d4f"
: undefined,
- borderColor:
- moderationResult === true
- ? '#52c41a'
- : moderationResult === false
- ? '#ff4d4f'
+ borderColor:
+ moderationResult === true
+ ? "#52c41a"
+ : moderationResult === false
+ ? "#ff4d4f"
: undefined,
- color:
- moderationResult === true
- || moderationResult === false
- ? '#fff'
- : undefined,
- }}
- >
- {moderationLoading
- ? t('actions.checkingContent' as any)
- : t('actions.contentModeration' as any)}
- </Button>
- )}
- </div>
+ color:
+ moderationResult === true ||
+ moderationResult === false
+ ? "#fff"
+ : undefined,
+ }}
+ >
+ {moderationLoading
+ ? t("actions.checkingContent" as any)
+ : t("actions.contentModeration" as any)}
+ </Button>
+ )}
+ </div>
- <PublishDatePicker
- loading={createLoading}
- onClick={() => {
- for (const [key, errVideoItem] of errParamsMap) {
- if (errVideoItem) {
- const pubItem = pubListChoosed.find(
- v => v.account.id === key,
- )!
- if (step === 1) {
- setExpandedPubItem(pubItem)
- }
- toast.warning(errVideoItem.parErrMsg)
- return
+ <PublishDatePicker
+ loading={createLoading}
+ onClick={() => {
+ for (const [key, errVideoItem] of errParamsMap) {
+ if (errVideoItem) {
+ const pubItem = pubListChoosed.find(
+ (v) => v.account.id === key
+ )!;
+ if (step === 1) {
+ setExpandedPubItem(pubItem);
}
+ toast.warning(errVideoItem.parErrMsg);
+ return;
}
- pubClick()
- }}
- />
- </>
- )}
+ }
+ pubClick();
+ }}
+ />
+ </>
+ )}
+ </div>
</div>
</div>
- </div>
- <div className="publishDialog-right">
- {width < 1400 && (
+ <div className="publishDialog-right">
+ {width < 1400 && (
+ <CSSTransition
+ in={openLeftSide}
+ timeout={300}
+ classNames="left"
+ unmountOnExit
+ >
+ <PublishDialogAi
+ ref={aiAssistantRef}
+ onClose={() => setOpenLeft(false)}
+ onSyncToEditor={handleSyncToEditor}
+ chatModels={chatModels}
+ />
+ </CSSTransition>
+ )}
<CSSTransition
- in={openLeftSide}
+ in={openRight}
timeout={300}
- classNames="left"
+ classNames="right"
unmountOnExit
>
- <PublishDialogAi
- ref={aiAssistantRef}
- onClose={() => setOpenLeft(false)}
- onSyncToEditor={handleSyncToEditor}
- chatModels={chatModels}
- />
+ <PublishDialogPreview />
</CSSTransition>
- )}
- <CSSTransition
- in={openRight}
- timeout={300}
- classNames="right"
- unmountOnExit
- >
- <PublishDialogPreview />
- </CSSTransition>
+ </div>
</div>
</Modal>
@@ -1374,15 +1429,15 @@ const PublishDialog = memo(
<PublishDetailModal
visible={publishDetailVisible}
onClose={() => {
- setPublishDetailVisible(false)
- setCurrentPublishTaskId(undefined)
+ setPublishDetailVisible(false);
+ setCurrentPublishTaskId(undefined);
}}
taskId={currentPublishTaskId}
/>
</>
- )
- },
- ),
-)
+ );
+ }
+ )
+);
-export default PublishDialog
+export default PublishDialog;
diff --git a/project/web/src/components/ui/modal.tsx b/project/web/src/components/ui/modal.tsx
index bc5e26df..25bf865a 100644
--- a/project/web/src/components/ui/modal.tsx
+++ b/project/web/src/components/ui/modal.tsx
@@ -166,7 +166,7 @@ export const Modal: React.FC<ModalProps> = ({
)}
{shouldRenderContent && (
- <div className={cn('flex-1 py-2 w-full flex', bodyClassName)}>
+ <div className={cn('flex-1 py-2 w-full flex flex-col overflow-auto', bodyClassName)}>
{children}
</div>
)}