Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
feat: 发布弹框开发中...
gaoSir46620aa9cf5c
diff --git a/.idea/workspace.xml b/.idea/workspace.xmlindex 98bb7c26..87a260e2 100644--- a/.idea/workspace.xml+++ b/.idea/workspace.xml@@ -4,12 +4,20 @@<option name="autoReloadType" value="SELECTIVE" /></component><component name="ChangeListManager">- <list default="true" id="90ed3383-49aa-4e32-95a2-9f070c0da49b" name="更改" comment="feat: 日历样式调整">- <change afterPath="$PROJECT_DIR$/src/assets/svgs/plat/bilibili.svg" afterDir="false" />+ <list default="true" id="90ed3383-49aa-4e32-95a2-9f070c0da49b" name="更改" comment="feat: 添加b站icon">+ <change afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PubCommonParams.tsx" afterDir="false" />+ <change afterPath="$PROJECT_DIR$/src/components/PublishDialog/plats/BilibParams.tsx" afterDir="false" />+ <change afterPath="$PROJECT_DIR$/src/components/PublishDialog/plats/KwaiParams.tsx" afterDir="false" />+ <change afterPath="$PROJECT_DIR$/src/components/PublishDialog/plats/plats.type.ts" afterDir="false" /><change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /><change beforePath="$PROJECT_DIR$/src/app/config/platConfig.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/config/platConfig.ts" afterDir="false" />+ <change beforePath="$PROJECT_DIR$/src/components/AvatarPlat/avatarPlat.module.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/AvatarPlat/avatarPlat.module.scss" afterDir="false" />+ <change beforePath="$PROJECT_DIR$/src/components/AvatarPlat/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/AvatarPlat/index.tsx" afterDir="false" />+ <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PublishDialogPreview.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/compoents/PublishDialogPreview.tsx" afterDir="false" /><change beforePath="$PROJECT_DIR$/src/components/PublishDialog/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/index.tsx" afterDir="false" /><change beforePath="$PROJECT_DIR$/src/components/PublishDialog/publishDialog.module.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/publishDialog.module.scss" afterDir="false" />+ <change beforePath="$PROJECT_DIR$/src/components/PublishDialog/usePublishDialog.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/usePublishDialog.ts" afterDir="false" />+ <change beforePath="$PROJECT_DIR$/src/utils/oss.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/utils/oss.ts" afterDir="false" /></list><option name="SHOW_DIALOG" value="false" /><option name="HIGHLIGHT_CONFLICTS" value="true" />@@ -19,6 +27,7 @@<component name="FileTemplateManagerImpl"><option name="RECENT_TEMPLATES"><list>+ <option value="TypeScript JSX File" /><option value="tsx组件模板" /></list></option>@@ -42,26 +51,27 @@<option name="hideEmptyMiddlePackages" value="true" /><option name="showLibraryContents" value="true" /></component>- <component name="PropertiesComponent">{- "keyToString": {- "ASKED_ADD_EXTERNAL_FILES": "true",- "ASKED_MARK_IGNORED_FILES_AS_EXCLUDED": "true",- "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",- "RunOnceActivity.ShowReadmeOnStart": "true",- "SHARE_PROJECT_CONFIGURATION_FILES": "true",- "git-widget-placeholder": "master",- "ignore.virus.scanning.warn.message": "true",- "node.js.detected.package.eslint": "true",- "node.js.detected.package.tslint": "true",- "node.js.selected.package.eslint": "(autodetect)",- "node.js.selected.package.tslint": "(autodetect)",- "nodejs_package_manager_path": "npm",- "run.code.analysis.last.selected.profile": "pProject Default",- "settings.editor.selected.configurable": "editor.reader.mode",- "ts.external.directory.path": "E:\\project-dev\\web\\艺咖\\aitoearn-web\\node_modules\\typescript\\lib",- "vue.rearranger.settings.migration": "true"+ <component name="PropertiesComponent"><![CDATA[{+ "keyToString": {+ "ASKED_ADD_EXTERNAL_FILES": "true",+ "ASKED_MARK_IGNORED_FILES_AS_EXCLUDED": "true",+ "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",+ "RunOnceActivity.ShowReadmeOnStart": "true",+ "SHARE_PROJECT_CONFIGURATION_FILES": "true",+ "git-widget-placeholder": "master",+ "ignore.virus.scanning.warn.message": "true",+ "last_opened_file_path": "E:/project-dev/web/艺咖/aitoearn-web/src/components/PublishDialog/plats",+ "node.js.detected.package.eslint": "true",+ "node.js.detected.package.tslint": "true",+ "node.js.selected.package.eslint": "(autodetect)",+ "node.js.selected.package.tslint": "(autodetect)",+ "nodejs_package_manager_path": "npm",+ "run.code.analysis.last.selected.profile": "pProject Default",+ "settings.editor.selected.configurable": "editor.reader.mode",+ "ts.external.directory.path": "E:\\project-dev\\web\\艺咖\\aitoearn-web\\node_modules\\typescript\\lib",+ "vue.rearranger.settings.migration": "true"}-}</component>+}]]></component><component name="ReactBuddySettings"><option name="extensionsIgnore" value="true" /></component>@@ -75,6 +85,9 @@</option></component><component name="RecentsManager">+ <key name="CopyFile.RECENT_KEYS">+ <recent name="E:\project-dev\web\艺咖\aitoearn-web\src\components\PublishDialog\plats" />+ </key><key name="MoveFile.RECENT_KEYS"><recent name="E:\project-dev\web\艺咖\aitoearn-web\src\assets\svgs\plat" /></key>@@ -95,7 +108,7 @@<workItem from="1750763285511" duration="48000" /><workItem from="1750763342070" duration="32000" /><workItem from="1750763376065" duration="41000" />- <workItem from="1750763426455" duration="1460000" />+ <workItem from="1750763426455" duration="6246000" /></task><task id="LOCAL-00001" summary="feat: 日历完善"><option name="closed" value="true" />@@ -145,7 +158,15 @@<option name="project" value="LOCAL" /><updated>1750764427509</updated></task>- <option name="localTasksCounter" value="7" />+ <task id="LOCAL-00007" summary="feat: 添加b站icon">+ <option name="closed" value="true" />+ <created>1750764927677</created>+ <option name="number" value="00007" />+ <option name="presentableId" value="LOCAL-00007" />+ <option name="project" value="LOCAL" />+ <updated>1750764927677</updated>+ </task>+ <option name="localTasksCounter" value="8" /><servers /></component><component name="TypeScriptGeneratedFilesManager">@@ -171,6 +192,7 @@<MESSAGE value="feat: 发布大改" /><MESSAGE value="feat: 发布弹框左右两侧显示隐藏过渡动画完成" /><MESSAGE value="feat: 日历样式调整" />- <option name="LAST_COMMIT_MESSAGE" value="feat: 日历样式调整" />+ <MESSAGE value="feat: 添加b站icon" />+ <option name="LAST_COMMIT_MESSAGE" value="feat: 添加b站icon" /></component></project>\ No newline at end of filediff --git a/src/app/config/platConfig.ts b/src/app/config/platConfig.tsindex 99b9d4a9..48131a02 100644--- a/src/app/config/platConfig.ts+++ b/src/app/config/platConfig.ts@@ -14,6 +14,8 @@ export enum PlatType {}export interface IAccountPlatInfo {+ // 平台主题颜色+ themeColor: string;// 显示的iconicon: string;// 平台中文名称@@ -69,6 +71,7 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([},topicMax: 4,},+ themeColor: "#FF4D00",},],[@@ -85,6 +88,7 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([},topicMax: 4,},+ themeColor: "blue",},],[@@ -102,6 +106,7 @@ export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([titleMax: 16,topicMax: 10,},+ themeColor: "red",},],]);diff --git a/src/components/AvatarPlat/avatarPlat.module.scss b/src/components/AvatarPlat/avatarPlat.module.scssindex e81f61d7..6ac9cf41 100644--- a/src/components/AvatarPlat/avatarPlat.module.scss+++ b/src/components/AvatarPlat/avatarPlat.module.scss@@ -4,8 +4,8 @@justify-content: center;& > img {position: absolute;- bottom: 0;- right: 0;+ bottom: 10%;+ right: -10%;transform: translate(-10%, 20%);border-radius: 50%;}diff --git a/src/components/AvatarPlat/index.tsx b/src/components/AvatarPlat/index.tsxindex 6ed096e3..22227791 100644--- a/src/components/AvatarPlat/index.tsx+++ b/src/components/AvatarPlat/index.tsx@@ -4,29 +4,39 @@ import { AvatarSize } from "antd/es/avatar/AvatarContext";import { SocialAccount } from "@/api/types/account.type";import { Avatar } from "antd";import { AccountPlatInfoMap } from "@/app/config/platConfig";+import { OSS_DOMAIN } from "@/utils/oss";export interface IAvatarPlatRef {}export interface IAvatarPlatProps {account: SocialAccount;size?: AvatarSize;+ className?: string;}+const getAvatar = (url: string) => {+ if (url.includes("https://")) {+ return url;+ } else {+ return `${OSS_DOMAIN}/` + url;+ }+};+const AvatarPlat = memo(forwardRef((- { account, size = "default" }: IAvatarPlatProps,+ { account, size = "default", className }: IAvatarPlatProps,ref: ForwardedRef<IAvatarPlatRef>,) => {const plat = AccountPlatInfoMap.get(account.type)!;return (<>- <div className={styles.avatarPlat}>- <Avatar src={account.avatar} size={size} />+ <div className={`${styles.avatarPlat} ${className}`}>+ <Avatar src={getAvatar(account.avatar)} size={size} /><imgsrc={plat.icon}style={{- width: size === "large" ? 15 : size === "default" ? 12.5 : 10,+ width: size === "large" ? 16 : size === "default" ? 12.5 : 10,}}/></div>diff --git a/src/components/PublishDialog/compoents/PubCommonParams.tsx b/src/components/PublishDialog/compoents/PubCommonParams.tsxnew file mode 100644index 00000000..bb61f965--- /dev/null+++ b/src/components/PublishDialog/compoents/PubCommonParams.tsx@@ -0,0 +1,15 @@+import { ForwardedRef, forwardRef, memo } from "react";++export interface IPubCommonParamsRef {}++export interface IPubCommonParamsProps {}++const PubCommonParams = memo(+ forwardRef(+ ({}: IPubCommonParamsProps, ref: ForwardedRef<IPubCommonParamsRef>) => {+ return <div>发布通用参数</div>;+ },+ ),+);++export default PubCommonParams;diff --git a/src/components/PublishDialog/compoents/PublishDialogPreview.tsx b/src/components/PublishDialog/compoents/PublishDialogPreview.tsxindex aa2a8805..d4182c7a 100644--- a/src/components/PublishDialog/compoents/PublishDialogPreview.tsx+++ b/src/components/PublishDialog/compoents/PublishDialogPreview.tsx@@ -1,5 +1,6 @@import { ForwardedRef, forwardRef, memo } from "react";import styles from "../publishDialog.module.scss";+import { Empty } from "antd";export interface IPublishDialogPreviewRef {}@@ -13,7 +14,12 @@ const PublishDialogPreview = memo() => {return (<div className={styles.publishDialogPreview}>- <div className="publishDialogPreview-wrapper">预览</div>+ <div className="publishDialogPreview-wrapper">+ <div className="publishDialogPreview-title">预览</div>+ <div className="publishDialogPreview-empty">+ <Empty description="在这里看到你的作品预览" />+ </div>+ </div></div>);},diff --git a/src/components/PublishDialog/index.tsx b/src/components/PublishDialog/index.tsxindex 16c8388c..b4dd7157 100644--- a/src/components/PublishDialog/index.tsx+++ b/src/components/PublishDialog/index.tsx@@ -1,4 +1,11 @@-import { ForwardedRef, forwardRef, memo, useCallback, useState } from "react";+import {+ ForwardedRef,+ forwardRef,+ memo,+ useCallback,+ useMemo,+ useState,+} from "react";import styles from "./publishDialog.module.scss";import { Button, Modal } from "antd";import { ExclamationCircleFilled } from "@ant-design/icons";@@ -6,6 +13,10 @@ import PublishDialogAi from "@/components/PublishDialog/compoents/PublishDialogAimport PublishDialogPreview from "@/components/PublishDialog/compoents/PublishDialogPreview";import { CSSTransition } from "react-transition-group";import { SocialAccount } from "@/api/types/account.type";+import { AccountPlatInfoMap } from "@/app/config/platConfig";+import AvatarPlat from "@/components/AvatarPlat";+import { usePublishDialog } from "@/components/PublishDialog/usePublishDialog";+import { useShallow } from "zustand/react/shallow";export interface IPublishDialogRef {}@@ -25,7 +36,12 @@ const PublishDialog = memo(ref: ForwardedRef<IPublishDialogRef>,) => {const [openLeft, setOpenLeft] = useState(false);- const [openRight, setOpenRight] = useState(false);+ const { setAccountChoosed, accountChoosed } = usePublishDialog(+ useShallow((state) => ({+ accountChoosed: state.accountChoosed,+ setAccountChoosed: state.setAccountChoosed,+ })),+ );// 关闭弹框并确认关闭const closeDialog = useCallback(() => {@@ -47,6 +63,11 @@ const PublishDialog = memo(});}, [onClose]);+ // 是否打开右侧预览+ const openRight = useMemo(() => {+ return accountChoosed.length !== 0;+ }, [accountChoosed]);+return (<><Modal@@ -72,12 +93,44 @@ const PublishDialog = memo(</div><div className="publishDialog-con-acconts">{accounts.map((account) => {+ const platConfig = AccountPlatInfoMap.get(account.type)!;+ const isChoosed = accountChoosed.find(+ (v) => v.id === account.id,+ );+return (<div- className="publishDialog-con-acconts-item"+ className={[+ "publishDialog-con-acconts-item",+ isChoosed+ ? "publishDialog-con-acconts-item--active"+ : "",+ ].join(" ")}+ style={{+ borderColor: isChoosed+ ? platConfig.themeColor+ : "transparent",+ }}key={account.id}+ onClick={() => {+ const newAccountChoosed = [...accountChoosed];+ // 查找当前账户是否已被选择+ const index = newAccountChoosed.findIndex(+ (v) => v.id === account.id,+ );+ if (index !== -1) {+ newAccountChoosed.splice(index, 1);+ } else {+ newAccountChoosed.push(account);+ }+ setAccountChoosed(newAccountChoosed);+ }}>- 1+ <AvatarPlat+ className="publishDialog-con-acconts-item-avatar"+ account={account}+ size="large"+ /></div>);})}diff --git a/src/components/PublishDialog/plats/BilibParams.tsx b/src/components/PublishDialog/plats/BilibParams.tsxnew file mode 100644index 00000000..8b99fa32--- /dev/null+++ b/src/components/PublishDialog/plats/BilibParams.tsx@@ -0,0 +1,13 @@+import { ForwardedRef, forwardRef, memo } from "react";+import {+ IPlatsParamsProps,+ IPlatsParamsRef,+} from "@/components/PublishDialog/plats/plats.type";++const BilibParams = memo(+ forwardRef(({}: IPlatsParamsProps, ref: ForwardedRef<IPlatsParamsRef>) => {+ return <div>b站</div>;+ }),+);++export default BilibParams;diff --git a/src/components/PublishDialog/plats/KwaiParams.tsx b/src/components/PublishDialog/plats/KwaiParams.tsxnew file mode 100644index 00000000..78c0fe02--- /dev/null+++ b/src/components/PublishDialog/plats/KwaiParams.tsx@@ -0,0 +1,13 @@+import { ForwardedRef, forwardRef, memo } from "react";+import {+ IPlatsParamsProps,+ IPlatsParamsRef,+} from "@/components/PublishDialog/plats/plats.type";++const KwaiParams = memo(+ forwardRef(({}: IPlatsParamsProps, ref: ForwardedRef<IPlatsParamsRef>) => {+ return <div>快手</div>;+ }),+);++export default KwaiParams;diff --git a/src/components/PublishDialog/plats/plats.type.ts b/src/components/PublishDialog/plats/plats.type.tsnew file mode 100644index 00000000..21128e27--- /dev/null+++ b/src/components/PublishDialog/plats/plats.type.ts@@ -0,0 +1,3 @@+export interface IPlatsParamsRef {}++export interface IPlatsParamsProps {}diff --git a/src/components/PublishDialog/publishDialog.module.scss b/src/components/PublishDialog/publishDialog.module.scssindex 4372f123..7493290a 100644--- a/src/components/PublishDialog/publishDialog.module.scss+++ b/src/components/PublishDialog/publishDialog.module.scss@@ -1,4 +1,4 @@-$assistantWidth: 250px;+$assistantWidth: 300px;.publishDialog {width: auto !important;@@ -8,18 +8,17 @@ $assistantWidth: 250px;}.publishDialog-wrapper {background: #fff;- min-height: 500px;position: relative;z-index: 10;border-radius: 8px;- width: 700px;+ width: 720px;display: flex;flex-direction: column;justify-content: space-between;}.publishDialog-con {box-sizing: border-box;- padding: 30px;+ padding: 20px;flex: 1;&-head {display: flex;@@ -32,7 +31,34 @@ $assistantWidth: 250px;}}&-acconts {-+ display: flex;+ flex-wrap: nowrap;+ gap: 12px;+ &-item {+ border: 2px solid transparent;+ border-radius: 50%;+ &:active {+ border-color: var(--colorPrimary4);+ }+ &--active {+ img {+ filter: grayscale(0) !important;+ }+ }+ &-avatar {+ cursor: pointer;+ transition: 0.3s;+ padding: 1px;+ & > img {+ filter: grayscale(100%);+ }+ &:hover {+ img {+ filter: grayscale(0);+ }+ }+ }+ }}}.publishDialog-footer {@@ -41,7 +67,7 @@ $assistantWidth: 250px;border-top: 1px solid var(--grayColor4);justify-content: space-between;box-sizing: border-box;- padding: 20px 30px;+ padding: 20px;&-btns {button {margin-right: 10px;@@ -94,6 +120,21 @@ $assistantWidth: 250px;:global {.publishDialogPreview-wrapper {min-width: $assistantWidth;+ display: flex;+ flex-direction: column;+ height: 100%;+ min-height: 0;+ }+ .publishDialogPreview-title {+ font-weight: 600;+ font-size: var(--fs-md);+ padding: 20px 20px 0 20px;+ }+ .publishDialogPreview-empty {+ height: 100%;+ display: flex;+ align-items: center;+ justify-content: center;}}}diff --git a/src/components/PublishDialog/usePublishDialog.ts b/src/components/PublishDialog/usePublishDialog.tsindex d97fc562..2e167220 100644--- a/src/components/PublishDialog/usePublishDialog.ts+++ b/src/components/PublishDialog/usePublishDialog.ts@@ -1,10 +1,16 @@import { create } from "zustand";import { combine } from "zustand/middleware";import lodash from "lodash";+import { SocialAccount } from "@/api/types/account.type";-export interface IPublishDialogStore {}+export interface IPublishDialogStore {+ // 选择的账户+ accountChoosed: SocialAccount[];+}-const store: IPublishDialogStore = {};+const store: IPublishDialogStore = {+ accountChoosed: [],+};const getStore = () => {return lodash.cloneDeep(store);@@ -23,6 +29,12 @@ export const usePublishDialog = create(...getStore(),});},++ setAccountChoosed(accountChoosed: SocialAccount[]) {+ set({+ accountChoosed,+ });+ },};return methods;},diff --git a/src/utils/oss.ts b/src/utils/oss.tsindex b5c66974..cf6f03db 100644--- a/src/utils/oss.ts+++ b/src/utils/oss.ts@@ -1,5 +1,5 @@// 获取OSS域名-const OSS_DOMAIN = 'https://ai-to-earn.oss-cn-beijing.aliyuncs.com';+export const OSS_DOMAIN = 'https://ai-to-earn.oss-cn-beijing.aliyuncs.com';// 获取完整的OSS URLexport const getOssUrl = (path: string) => {