Skip to content

Let's use AI to Earn!

feat(发布弹框): 添加选择账户一系列逻辑: 1. 选择账户时,开启发布弹框会默认选择,右侧选择的账户。 2. 添加日历header选择用户展示的样式。

gaoSir2b0868457897
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index b0ae2f7a..49e55d5e 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,10 +4,17 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
- <list default="true" id="8ce961ad-7c9e-494c-bc53-9ecde4358af8" name="更改" comment="feat(日历):细节调整,1. 发布记录查看,添加图片、视频分别处理。 2. 发布API添加图片处理">
+ <list default="true" id="8ce961ad-7c9e-494c-bc53-9ecde4358af8" name="更改" comment="feat(日历):日历在同一个单元格发布记录太多会自动隐藏,并且显示按钮让用户点击查看更多">
+ <change afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/AllPlatIcon.tsx" 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/[lng]/accounts/accountCore.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/accountCore.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/calendarTimingItem.module.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/calendarTimingItem.module.scss" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.module.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.module.scss" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/[lng]/accounts/components/CalendarTiming/index.tsx" 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/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/PublishDialog/index.tsx" 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/store/account.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/store/account.ts" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -93,7 +100,7 @@
<workItem from="1752118620733" duration="566000" />
<workItem from="1752130881346" duration="11774000" />
<workItem from="1752200550278" duration="253000" />
- <workItem from="1752200816463" duration="12806000" />
+ <workItem from="1752200816463" duration="15533000" />
</task>
<task id="LOCAL-00001" summary="feat(CalendarTiming): 优化发布记录列表展示&#10;- 调整日历记录项的样式和布局&#10;- 优化 RecordCore组件,添加平台图标和时间显示&#10;- 修改 CalendarTimingItem 组件,移除不必要的 Fragment&#10;-调整 index.tsx 中的日期格式化逻辑">
<option name="closed" value="true" />
@@ -199,7 +206,15 @@
<option name="project" value="LOCAL" />
<updated>1752229429479</updated>
</task>
- <option name="localTasksCounter" value="14" />
+ <task id="LOCAL-00014" summary="feat(日历):日历在同一个单元格发布记录太多会自动隐藏,并且显示按钮让用户点击查看更多">
+ <option name="closed" value="true" />
+ <created>1752236562804</created>
+ <option name="number" value="00014" />
+ <option name="presentableId" value="LOCAL-00014" />
+ <option name="project" value="LOCAL" />
+ <updated>1752236562804</updated>
+ </task>
+ <option name="localTasksCounter" value="15" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -232,6 +247,7 @@
<MESSAGE value="feat(日历): 删除任务、修改任务时间接入API,删除任务完成" />
<MESSAGE value="fix(发布): 默认返回快手参数" />
<MESSAGE value="feat(日历):细节调整,1. 发布记录查看,添加图片、视频分别处理。 2. 发布API添加图片处理" />
- <option name="LAST_COMMIT_MESSAGE" value="feat(日历):细节调整,1. 发布记录查看,添加图片、视频分别处理。 2. 发布API添加图片处理" />
+ <MESSAGE value="feat(日历):日历在同一个单元格发布记录太多会自动隐藏,并且显示按钮让用户点击查看更多" />
+ <option name="LAST_COMMIT_MESSAGE" value="feat(日历):日历在同一个单元格发布记录太多会自动隐藏,并且显示按钮让用户点击查看更多" />
</component>
</project>
\ No newline at end of file
diff --git a/src/app/[lng]/accounts/accountCore.tsx b/src/app/[lng]/accounts/accountCore.tsx
index 4a606530..689f61f2 100644
--- a/src/app/[lng]/accounts/accountCore.tsx
+++ b/src/app/[lng]/accounts/accountCore.tsx
@@ -3,18 +3,19 @@
import styles from "./accounts.module.scss";
import { useAccountStore } from "@/store/account";
import { useShallow } from "zustand/react/shallow";
-import { useEffect, useState } from "react";
+import { useEffect } from "react";
import { NoSSR } from "@kwooshung/react-no-ssr";
import AccountSidebar from "@/app/[lng]/accounts/components/AccountSidebar/AccountSidebar";
import CalendarTiming from "@/app/[lng]/accounts/components/CalendarTiming";
export default function AccountPageCore() {
- const { accountInit } = useAccountStore(
+ const { accountInit, accountActive, setAccountActive } = useAccountStore(
useShallow((state) => ({
accountInit: state.accountInit,
+ setAccountActive: state.setAccountActive,
+ accountActive: state.accountActive,
})),
);
- const [activeAccountId, setActiveAccountId] = useState("");
useEffect(() => {
accountInit();
@@ -24,10 +25,13 @@ export default function AccountPageCore() {
<NoSSR>
<div className={styles.accounts}>
<AccountSidebar
- activeAccountId={activeAccountId}
+ activeAccountId={accountActive?.id || ""}
onAccountChange={(account) => {
- console.log("change", account);
- setActiveAccountId(account.id);
+ if (account.id === accountActive?.id) {
+ setAccountActive(undefined);
+ } else {
+ setAccountActive(account);
+ }
}}
/>
<CalendarTiming />
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/AllPlatIcon.tsx b/src/app/[lng]/accounts/components/CalendarTiming/AllPlatIcon.tsx
new file mode 100644
index 00000000..f7bf1feb
--- /dev/null
+++ b/src/app/[lng]/accounts/components/CalendarTiming/AllPlatIcon.tsx
@@ -0,0 +1,43 @@
+import { ForwardedRef, forwardRef, memo, useMemo } from "react";
+import styles from "./calendarTiming.module.scss";
+
+export interface IAllPlatIconRef {}
+
+export interface IAllPlatIconProps {
+ width?: number;
+}
+
+const AllPlatIcon = memo(
+ forwardRef(
+ ({ width = 50 }: IAllPlatIconProps, ref: ForwardedRef<IAllPlatIconRef>) => {
+ const widthChild = useMemo(() => {
+ return width / 5;
+ }, [width]);
+
+ const childStyle = useMemo(() => {
+ return {
+ width: widthChild + "px",
+ height: widthChild + "px",
+ };
+ }, [widthChild]);
+
+ return (
+ <div
+ className={styles.allPlatIcon}
+ style={{ width: width + "px", height: width + "px" }}
+ >
+ <ul>
+ <li style={childStyle}></li>
+ <li style={childStyle}></li>
+ </ul>
+ <ul>
+ <li style={childStyle}></li>
+ <li style={childStyle}></li>
+ </ul>
+ </div>
+ );
+ },
+ ),
+);
+
+export default AllPlatIcon;
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx
index e3f5ab62..021420a3 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx
+++ b/src/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem.tsx
@@ -163,7 +163,7 @@ const CalendarTimingItem = memo(
) : (
<>
<DownOutlined style={{ marginRight: "8px" }} />
- 显示更多
+ {records.length - recordsLast?.length} 更多
</>
)}
</Button>
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.module.scss b/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.module.scss
index 1a546a4d..7a21a811 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.module.scss
+++ b/src/app/[lng]/accounts/components/CalendarTiming/calendarTiming.module.scss
@@ -4,10 +4,31 @@
display: flex;
flex-direction: column;
overflow: hidden;
- padding: 15px;
+ padding: 10px 15px 15px 15px;
box-sizing: border-box;
:global {
+ .calendarTiming-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: 15px;
+ &-user {
+ display: flex;
+ align-items: center;
+ &-details {
+ margin-left: 15px;
+ &-name {
+ font-size: var(--fs-xl);
+ font-weight: 700;
+ }
+ }
+ }
+ &-options {
+
+ }
+ }
+
.calendarTiming-toolbar {
display: flex;
justify-content: space-between;
@@ -123,4 +144,25 @@
.fadeExitActive {
opacity: 0;
transition: opacity 300ms;
+}
+
+.allPlatIcon {
+ width: 50px;
+ height: 50px;
+ border: 1px solid var(--grayColor8);
+ border-radius: 50%;
+ box-sizing: border-box;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ ul {
+ display: flex;
+ li {
+ border: 2px solid #333;
+ border-radius: 50%;
+ flex-shrink: 0;
+ margin: 0.5px;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/app/[lng]/accounts/components/CalendarTiming/index.tsx b/src/app/[lng]/accounts/components/CalendarTiming/index.tsx
index 1ba60841..105b0ba0 100644
--- a/src/app/[lng]/accounts/components/CalendarTiming/index.tsx
+++ b/src/app/[lng]/accounts/components/CalendarTiming/index.tsx
@@ -17,7 +17,7 @@ import {
import { CSSTransition } from "react-transition-group";
import { DatesSetArg } from "@fullcalendar/core";
import { Button } from "antd";
-import { LeftOutlined, RightOutlined } from "@ant-design/icons";
+import { LeftOutlined, PlusOutlined, RightOutlined } from "@ant-design/icons";
import { useTransClient } from "@/app/i18n/client";
import CalendarTimingItem from "@/app/[lng]/accounts/components/CalendarTiming/CalendarTimingItem/CalendarTimingItem";
import PublishDialog, { IPublishDialogRef } from "@/components/PublishDialog";
@@ -28,6 +28,8 @@ import { DndProvider } from "react-dnd";
import { useCalendarTiming } from "@/app/[lng]/accounts/components/CalendarTiming/useCalendarTiming";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
+import AvatarPlat from "@/components/AvatarPlat";
+import AllPlatIcon from "@/app/[lng]/accounts/components/CalendarTiming/AllPlatIcon";
dayjs.extend(utc);
@@ -54,9 +56,10 @@ const CalendarTiming = memo(
};
const calendarTimingCalendarRef = useRef<HTMLDivElement>(null);
const [publishDialogOpen, setPublishDialogOpen] = useState(false);
- const { accountList } = useAccountStore(
+ const { accountList, accountActive } = useAccountStore(
useShallow((state) => ({
accountList: state.accountList,
+ accountActive: state.accountActive,
})),
);
const {
@@ -142,6 +145,7 @@ const CalendarTiming = memo(
return (
<div className={styles.calendarTiming}>
<PublishDialog
+ defaultAccountId={accountActive?.id}
ref={publishDialogRef}
open={publishDialogOpen}
onClose={() => setPublishDialogOpen(false)}
@@ -151,6 +155,44 @@ const CalendarTiming = memo(
accounts={accountList}
/>
+ <div className="calendarTiming-header">
+ <div className="calendarTiming-header-user">
+ {!accountActive ? (
+ <>
+ <AllPlatIcon />
+ <div className="calendarTiming-header-user-details">
+ <div className="calendarTiming-header-user-details-name">
+ 所有平台
+ </div>
+ </div>
+ </>
+ ) : (
+ <>
+ <AvatarPlat
+ account={accountActive!}
+ avatarWidth={50}
+ width={18}
+ />
+ <div className="calendarTiming-header-user-details">
+ <div className="calendarTiming-header-user-details-name">
+ {accountActive.nickname}
+ </div>
+ </div>
+ </>
+ )}
+ </div>
+ <div className="calendarTiming-header-options">
+ <Button
+ size="large"
+ icon={<PlusOutlined />}
+ onClick={() => {
+ setPublishDialogOpen(true);
+ }}
+ >
+ 新建作品
+ </Button>
+ </div>
+ </div>
<div className="calendarTiming-toolbar">
<div className="calendarTiming-toolbar-left">
<Button
@@ -168,7 +210,7 @@ const CalendarTiming = memo(
</h1>
<Button onClick={handleToday}>{t("today")}</Button>
</div>
- <div className="calendarTiming-toolbar-right">1</div>
+ <div className="calendarTiming-toolbar-right"></div>
</div>
<CSSTransition
in={!animating}
diff --git a/src/components/AvatarPlat/index.tsx b/src/components/AvatarPlat/index.tsx
index 2292434a..690134fc 100644
--- a/src/components/AvatarPlat/index.tsx
+++ b/src/components/AvatarPlat/index.tsx
@@ -12,6 +12,8 @@ export interface IAvatarPlatProps {
account: SocialAccount;
size?: AvatarSize;
className?: string;
+ width?: number;
+ avatarWidth?: number;
}
const getAvatar = (url: string) => {
@@ -25,19 +27,35 @@ const getAvatar = (url: string) => {
const AvatarPlat = memo(
forwardRef(
(
- { account, size = "default", className }: IAvatarPlatProps,
+ {
+ account,
+ size = "default",
+ className,
+ width,
+ avatarWidth,
+ }: IAvatarPlatProps,
ref: ForwardedRef<IAvatarPlatRef>,
) => {
const plat = AccountPlatInfoMap.get(account.type)!;
return (
<>
<div className={`${styles.avatarPlat} ${className}`}>
- <Avatar src={getAvatar(account.avatar)} size={size} />
+ <Avatar
+ src={getAvatar(account.avatar)}
+ size={avatarWidth ? avatarWidth : size}
+ />
<img
src={plat?.icon}
- style={{
- width: size === "large" ? 16 : size === "default" ? 12.5 : 10,
- }}
+ style={
+ !width
+ ? {
+ width:
+ size === "large" ? 16 : size === "default" ? 12.5 : 10,
+ }
+ : {
+ width,
+ }
+ }
/>
</div>
</>
diff --git a/src/components/PublishDialog/index.tsx b/src/components/PublishDialog/index.tsx
index e550a9c0..29bb3cf5 100644
--- a/src/components/PublishDialog/index.tsx
+++ b/src/components/PublishDialog/index.tsx
@@ -41,6 +41,8 @@ export interface IPublishDialogProps {
accounts: SocialAccount[];
// 发布成功事件
onPubSuccess?: () => void;
+ // 默认选中的账户Id
+ defaultAccountId?: string;
}
const { confirm } = Modal;
@@ -49,7 +51,13 @@ const { confirm } = Modal;
const PublishDialog = memo(
forwardRef(
(
- { open, onClose, accounts, onPubSuccess }: IPublishDialogProps,
+ {
+ open,
+ onClose,
+ accounts,
+ onPubSuccess,
+ defaultAccountId,
+ }: IPublishDialogProps,
ref: ForwardedRef<IPublishDialogRef>,
) => {
const [openLeft, setOpenLeft] = useState(false);
@@ -91,7 +99,7 @@ const PublishDialog = memo(
useEffect(() => {
if (open) {
- init(accounts);
+ init(accounts, defaultAccountId);
} else {
setPubListChoosed([]);
clear();
diff --git a/src/components/PublishDialog/usePublishDialog.ts b/src/components/PublishDialog/usePublishDialog.ts
index 64a5f9e5..98213587 100644
--- a/src/components/PublishDialog/usePublishDialog.ts
+++ b/src/components/PublishDialog/usePublishDialog.ts
@@ -84,8 +84,12 @@ export const usePublishDialog = create(
return lodash.cloneDeep(get().commonPubParams);
},
- // 初始化
- init(account: SocialAccount[]) {
+ /**
+ * 初始化
+ * @param account
+ * @param defaultAccountId 默认选中的账户Id
+ */
+ init(account: SocialAccount[], defaultAccountId?: string) {
const pubList: PubItem[] = [];
account.map((v) => {
@@ -95,6 +99,12 @@ export const usePublishDialog = create(
});
});
+ if (defaultAccountId) {
+ methods.setPubListChoosed([
+ pubList.find((v) => v.account.id === defaultAccountId)!,
+ ]);
+ }
+
set({
pubList,
});
diff --git a/src/store/account.ts b/src/store/account.ts
index 7247c1e6..7d8550bd 100644
--- a/src/store/account.ts
+++ b/src/store/account.ts
@@ -16,6 +16,8 @@ export interface IAccountStore {
accountGroupList: AccountGroup[];
accountGroupMap: Map<string, AccountGroup>;
accountLoading: boolean;
+ // 当前选择的账户
+ accountActive?: SocialAccount;
}
const store: IAccountStore = {
@@ -27,6 +29,7 @@ const store: IAccountStore = {
accountMap: new Map([]),
accountUidMap: new Map([]),
accountLoading: false,
+ accountActive: undefined,
};
const getStore = () => {
@@ -46,6 +49,12 @@ export const useAccountStore = create(
...getStore(),
});
},
+ // 设置选择账户ID
+ setAccountActive(accountActive?: SocialAccount) {
+ set({
+ accountActive,
+ });
+ },
setAccountGroupList(accountGroupList: AccountGroup[]) {
set({ accountGroupList });