Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat: 在发布账号中添加账号完成,[ChooseAccountModule.tsx]组件添加修改选中平台的ref
gaoSirfd69db0ca5b8
diff --git a/src/layout/Navigation/navigation.module.scss b/src/layout/Navigation/navigation.module.scssindex 909cce17..8d26582c 100644--- a/src/layout/Navigation/navigation.module.scss+++ b/src/layout/Navigation/navigation.module.scss@@ -29,6 +29,8 @@align-items: center;margin-right: 20px;font-size: var(--fs-lg);+ user-select: none;+ -webkit-app-region: drag;img {margin-right: 4px;}diff --git a/src/views/publish/children/imagePage/components/ImageRightSetting/ImageRightSetting.tsx b/src/views/publish/children/imagePage/components/ImageRightSetting/ImageRightSetting.tsxindex 4038b84e..7f44cdc1 100644--- a/src/views/publish/children/imagePage/components/ImageRightSetting/ImageRightSetting.tsx+++ b/src/views/publish/children/imagePage/components/ImageRightSetting/ImageRightSetting.tsx@@ -1,10 +1,12 @@-import { ForwardedRef, forwardRef, memo, useState } from 'react';+import { ForwardedRef, forwardRef, memo, useRef, useState } from 'react';import styles from '../../image.module.scss';import { PubType } from '../../../../../../../commont/publish/PublishEnum';import SupportPlat from '../../../../components/SupportPlat/SupportPlat';import { ChooseAccountChunk } from '../../../../components/CommonComponents/CommonComponents';import { Steps } from 'antd';-import ChooseAccountModule from '../../../../components/ChooseAccountModule/ChooseAccountModule';+import ChooseAccountModule, {+ IChooseAccountModuleRef,+} from '../../../../components/ChooseAccountModule/ChooseAccountModule';import { useShallow } from 'zustand/react/shallow';import { useImagePageStore } from '../../useImagePageStore';import ImageParamsSet from './components/ImageParamsSet';@@ -17,16 +19,19 @@ const ImageRightSetting = memo(forwardRef(({}: IImageRightSettingProps, ref: ForwardedRef<IImageRightSettingRef>) => {const [chooseAccountOpen, setChooseAccountOpen] = useState(false);- const { imageAccounts, addAccount } = useImagePageStore(+ const { imageAccounts, addAccount, activePlat } = useImagePageStore(useShallow((state) => ({imageAccounts: state.imageAccounts,addAccount: state.addAccount,+ activePlat: state.activePlat,})),);+ const chooseAccountModuleRef = useRef<IChooseAccountModuleRef>(null);return (<><ChooseAccountModule+ ref={chooseAccountModuleRef}open={chooseAccountOpen}onClose={setChooseAccountOpen}platChooseProps={{@@ -70,7 +75,14 @@ const ImageRightSetting = memo(/></div>) : (- <ImageParamsSet />+ <ImageParamsSet+ openChooseAccount={() => {+ setChooseAccountOpen(true);+ chooseAccountModuleRef+ .current!.getPlatChooseRef()+ ?.setActivePlat(activePlat!);+ }}+ />)}</>);diff --git a/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx b/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsxindex 8da6e601..d781bb9e 100644--- a/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx+++ b/src/views/publish/children/imagePage/components/ImageRightSetting/components/ImageParamsSet.tsx@@ -10,12 +10,17 @@ import ParamsSettingDetails from './ParamsSettingDetails';export interface IImageParamsSetRef {}-export interface IImageParamsSetProps {}+export interface IImageParamsSetProps {+ openChooseAccount: () => void;+}// 图片发布右侧参数设置const ImageParamsSet = memo(forwardRef(- ({}: IImageParamsSetProps, ref: ForwardedRef<IImageParamsSetRef>) => {+ (+ { openChooseAccount }: IImageParamsSetProps,+ ref: ForwardedRef<IImageParamsSetRef>,+ ) => {const {imageAccounts,activePlat,@@ -129,6 +134,7 @@ const ImageParamsSet = memo(</div>{activePlat && platAccountImagesMap.get(activePlat) && (<ParamsSettingDetails+ openChooseAccount={openChooseAccount}imageAccountList={platAccountImagesMap.get(activePlat)!}/>)}diff --git a/src/views/publish/children/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx b/src/views/publish/children/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsxindex 5f27c9dd..64c756b3 100644--- a/src/views/publish/children/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx+++ b/src/views/publish/children/imagePage/components/ImageRightSetting/components/ParamsSettingDetails.tsx@@ -1,6 +1,6 @@import { ForwardedRef, forwardRef, memo, useMemo } from 'react';import styles from './imageParamsSet.module.scss';-import { CloseOutlined } from '@ant-design/icons';+import { CloseOutlined, PlusOutlined } from '@ant-design/icons';import { Avatar, Tooltip } from 'antd';import { AccountType } from '../../../../../../../../commont/AccountEnum';import ImageParamsSet_Douyin from './children/ImageParamsSet_Douyin';@@ -13,13 +13,14 @@ export interface IParamsSettingDetailsRef {}export interface IParamsSettingDetailsProps {imageAccountList: IImageAccountItem[];+ openChooseAccount: () => void;}// 图文发布右侧参数设置的具体参数设置,为了防止代码冗余拆分const ParamsSettingDetails = memo(forwardRef((- { imageAccountList }: IParamsSettingDetailsProps,+ { imageAccountList, openChooseAccount }: IParamsSettingDetailsProps,ref: ForwardedRef<IParamsSettingDetailsRef>,) => {const {@@ -48,6 +49,16 @@ const ParamsSettingDetails = memo(<i>*</i></h1><div className="paramsSettingItem-users">+ <div+ className="paramsSettingItem-users-item"+ onClick={openChooseAccount}+ >+ <div className="paramsSettingItem-users-item-img">+ <Avatar size="large" icon={<PlusOutlined />} />+ </div>+ <p className="paramsSettingItem-users-item-name">发布账号</p>+ </div>+{imageAccountList.map((v) => {return (<divdiff --git a/src/views/publish/children/imagePage/components/ImageRightSetting/components/imageParamsSet.module.scss b/src/views/publish/children/imagePage/components/ImageRightSetting/components/imageParamsSet.module.scssindex a0542fd5..1d5afd48 100644--- a/src/views/publish/children/imagePage/components/ImageRightSetting/components/imageParamsSet.module.scss+++ b/src/views/publish/children/imagePage/components/ImageRightSetting/components/imageParamsSet.module.scss@@ -79,7 +79,10 @@width: 70px;font-size: var(--fs-sm);cursor: pointer;- margin-right: 10px;+ display: flex;+ flex-direction: column;+ align-items: center;+ margin-right: 5px;&--active {.paramsSettingItem-users-item-img {border-color: var(--colorPrimary6);@@ -103,10 +106,12 @@&-close {}&-name {+ width: 100%;margin-top: 4px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;+ text-align: center;}}}diff --git a/src/views/publish/components/ChooseAccountModule/ChooseAccountModule.tsx b/src/views/publish/components/ChooseAccountModule/ChooseAccountModule.tsxindex 33551f91..8afba3af 100644--- a/src/views/publish/components/ChooseAccountModule/ChooseAccountModule.tsx+++ b/src/views/publish/components/ChooseAccountModule/ChooseAccountModule.tsx@@ -3,6 +3,7 @@ import {forwardRef,memo,useEffect,+ useImperativeHandle,useRef,useState,} from 'react';@@ -13,7 +14,9 @@ import PlatChoose, {IPlatChooseRef,} from '@/views/publish/components/ChooseAccountModule/components/PlatChoose';-export interface IChooseAccountModuleRef {}+export interface IChooseAccountModuleRef {+ getPlatChooseRef: () => IPlatChooseRef | null;+}export interface IChooseAccountModuleProps {open: boolean;@@ -66,6 +69,13 @@ const ChooseAccountModule = memo(platChooseRef.current?.init();}, [open]);+ const ImperativeHandle: IChooseAccountModuleRef = {+ getPlatChooseRef() {+ return platChooseRef.current;+ },+ };+ useImperativeHandle(ref, () => ImperativeHandle);+return (<Modalwidth={800}diff --git a/src/views/publish/components/ChooseAccountModule/components/PlatChoose.tsx b/src/views/publish/components/ChooseAccountModule/components/PlatChoose.tsxindex 72efebdc..17a6a7b3 100644--- a/src/views/publish/components/ChooseAccountModule/components/PlatChoose.tsx+++ b/src/views/publish/components/ChooseAccountModule/components/PlatChoose.tsx@@ -34,6 +34,8 @@ export interface IPlatChooseRef {recover: () => void;// 每次关闭弹框的时候需要初始化一些状态init: () => void;+ // 设置选中平台+ setActivePlat: (activePlat: AccountType) => void;}export interface IPlatChooseProps {@@ -183,6 +185,7 @@ const PlatChoose = memo(return newV;});},+ setActivePlat,init,}));