Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
fix: Fix the bug in the release editor (#308)
Gaoc649b0f516d8
diff --git a/project/web/src/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming.ts b/project/web/src/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming.tsindex 513feb40..df72758b 100644--- a/project/web/src/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming.ts+++ b/project/web/src/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming.ts@@ -192,7 +192,6 @@ export const useCalendarTiming = create(// 延迟 5 秒await new Promise(resolve => setTimeout(resolve, 5000))- console.log('轮询任务中:', pubRecord)try {const res = await getPublishRecordDetail(pubRecord.flowId!)if (!res || !res.data) {diff --git a/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsx b/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsxindex da21f5b1..6824bf3e 100644--- a/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsx+++ b/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon.tsx@@ -4,7 +4,7 @@ import type {} from '@/components/PublishDialog/compoents/PubParmasTextarea'import type { IImgFile, PubItem } from '@/components/PublishDialog/publishDialog.type'import { Alert } from 'antd'-import { useCallback, useMemo } from 'react'+import { useCallback, useEffect, useMemo } from 'react'import { useShallow } from 'zustand/react/shallow'import { PubParamsVerifyInfo } from '@/components/PublishDialog/hooks/usePubParamsVerify'import { usePublishDialog } from '@/components/PublishDialog/usePublishDialog'diff --git a/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx b/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsxindex 7a48449a..8deaa209 100644--- a/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx+++ b/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/index.tsx@@ -1,6 +1,7 @@import type { CSSProperties, ForwardedRef } from 'react'import type { IImgFile, PubItem } from '@/components/PublishDialog/publishDialog.type'-import { forwardRef, memo, useMemo } from 'react'+import { forwardRef, memo, useEffect, useMemo } from 'react'+import { useShallow } from 'zustand/react/shallow'import { AccountPlatInfoMap, PlatType } from '@/app/config/platConfig'import { useTransClient } from '@/app/i18n/client'@@ -68,6 +69,10 @@ const PlatParamsSetting = memo(}}, [pubItem, onImageToImage])+ useEffect(() => {+ console.log(pubItem, 1111)+ }, [pubItem])+// true=展开当前账号的参数设置 false=不展开const isExpand = useMemo(() => {if (step === 0)diff --git a/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/plats/InstagramParams.tsx b/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/plats/InstagramParams.tsxindex 58baf3ff..010e0fae 100644--- a/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/plats/InstagramParams.tsx+++ b/project/web/src/components/PublishDialog/compoents/PlatParamsSetting/plats/InstagramParams.tsx@@ -5,6 +5,7 @@ import type {} from '@/components/PublishDialog/compoents/PlatParamsSetting/plats/plats.type'import { Radio } from 'antd'import { forwardRef, memo, useEffect } from 'react'+import { useTransClient } from '@/app/i18n/client'import CommonTitleInput from '@/components/PublishDialog/compoents/PlatParamsSetting/common/CommonTitleInput'import usePlatParamsCommon from '@/components/PublishDialog/compoents/PlatParamsSetting/hooks/usePlatParamsCoomon'diff --git a/project/web/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasMentionInput/index.tsx b/project/web/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasMentionInput/index.tsxindex 6c80eecb..b3cad9ee 100644--- a/project/web/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasMentionInput/index.tsx+++ b/project/web/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasMentionInput/index.tsx@@ -4,8 +4,8 @@ import type {InitialConfigType,} from '@lexical/react/LexicalComposer'import type { EditorState, LexicalEditor } from 'lexical'-import type {- ForwardedRef,+import {+ ForwardedRef, useEffect,} from 'react'import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin'import {@@ -73,15 +73,24 @@ const PubParmasMentionInput = memo(ref: ForwardedRef<IPubParmasMentionInputRef>,) => {const comboboxAnchor = useRef<HTMLDivElement>(null)+ // 用于防止循环更新:当编辑器内容变化时,记录最新值+ const isInternalChangeRef = useRef(false)+const handleChange = useCallback((editorState: EditorState, editor: LexicalEditor) => {editorState.read(() => {const root = $getRoot()const text = root.getTextContent()+ // 标记这是内部变化,避免触发外部value同步回来+ isInternalChangeRef.current = trueonChange(text)+ // 使用 setTimeout 确保外部状态更新后再重置标记+ setTimeout(() => {+ isInternalChangeRef.current = false+ }, 0)})},- [],+ [onChange],)const handleSearch = useCallback(@@ -131,7 +140,7 @@ const PubParmasMentionInput = memo(<HistoryPlugin /><AutoFocusPlugin defaultSelection="rootStart" />- <InitialValuePlugin value={value} />+ <InitialValuePlugin value={value} isInternalChangeRef={isInternalChangeRef} /><PasteTopicsPlugin />diff --git a/project/web/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasMentionInput/utils/editor-utils.ts b/project/web/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasMentionInput/utils/editor-utils.tsindex 5767c0d8..b3bcb22a 100644--- a/project/web/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasMentionInput/utils/editor-utils.ts+++ b/project/web/src/components/PublishDialog/compoents/PubParmasTextarea/PubParmasMentionInput/utils/editor-utils.ts@@ -1,3 +1,4 @@+import type { MutableRefObject } from 'react'import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'import {$createParagraphNode,@@ -11,17 +12,36 @@ import {import { BeautifulMentionNode } from 'lexical-beautiful-mentions'import { useEffect, useRef } from 'react'-export function InitialValuePlugin({ value }: { value: string }) {+/**+ * 插件:根据外部 value 同步更新编辑器内容+ * @param value - 外部传入的文本值+ * @param isInternalChangeRef - 标记是否为内部变化,避免循环更新+ */+export function InitialValuePlugin({+ value,+ isInternalChangeRef,+}: {+ value: string+ isInternalChangeRef?: MutableRefObject<boolean>+}) {const [editor] = useLexicalComposerContext()const lastAppliedRef = useRef<string>('')useEffect(() => {+ // 如果是内部变化触发的,跳过同步,避免循环更新+ if (isInternalChangeRef?.current) {+ return+ }+editor.update(() => {const root = $getRoot()const currentText = root.getTextContent()- if (value === currentText || value === lastAppliedRef.current)++ // 只有当 value 真正不同时才更新+ if (value === currentText && value === lastAppliedRef.current)return+ // 清空并重建内容root.clear()const paragraph = $createParagraphNode()root.append(paragraph)@@ -52,7 +72,7 @@ export function InitialValuePlugin({ value }: { value: string }) {lastAppliedRef.current = value})- }, [editor, value])+ }, [editor, value, isInternalChangeRef])return null}diff --git a/project/web/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx b/project/web/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsxindex f727efd6..ed5219a5 100644--- a/project/web/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx+++ b/project/web/src/components/PublishDialog/compoents/PubParmasTextarea/index.tsx@@ -16,6 +16,7 @@ import { Button, Image, Input, message, Tooltip } from 'antd'import dynamic from 'next/dynamic'import React, {forwardRef,+memo,useCallback,useEffect,@@ -23,6 +24,7 @@ import React, {useRef,useState,} from 'react'+import { ReactSortable } from 'react-sortablejs'import { CSSTransition, TransitionGroup } from 'react-transition-group'diff --git a/project/web/src/components/PublishDialog/index.tsx b/project/web/src/components/PublishDialog/index.tsxindex 4b717fa2..3112e244 100644--- a/project/web/src/components/PublishDialog/index.tsx+++ b/project/web/src/components/PublishDialog/index.tsx@@ -1020,7 +1020,6 @@ const PublishDialog = memo(return (<PlatParamsSettingpubItem={v}- key={v.account.id}style={{ marginBottom: '12px' }}onImageToImage={handleImageToImage}/>