Skip to content

Let's use AI to Earn!

feat: 1. token过期跳转到login。 2. 将账户组件整体搬到项目。 3. 对接账户组接口。

gaoSir354e9db0cb3e
diff --git a/package-lock.json b/package-lock.json
index 2a6239a3..7fb2579d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -26,6 +26,7 @@
"react-dom": "^18",
"react-i18next": "15.4.1",
"react-icons": "^5.5.0",
+ "react-sortablejs": "^6.1.4",
"sass": "^1.59.2",
"zustand": "^5.0.4"
},
@@ -1275,6 +1276,13 @@
"@types/react": "^18.0.0"
}
},
+ "node_modules/@types/sortablejs": {
+ "version": "1.15.8",
+ "resolved": "https://registry.npmmirror.com/@types/sortablejs/-/sortablejs-1.15.8.tgz",
+ "integrity": "sha512-b79830lW+RZfwaztgs1aVPgbasJ8e7AXtZYHTELNXZPsERt4ymJdjV4OccDbHQAvHrCcFpbF78jkm0R6h/pZVg==",
+ "license": "MIT",
+ "peer": true
+ },
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "8.32.1",
"resolved": "https://registry.npmmirror.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.32.1.tgz",
@@ -6259,6 +6267,28 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/react-sortablejs": {
+ "version": "6.1.4",
+ "resolved": "https://registry.npmmirror.com/react-sortablejs/-/react-sortablejs-6.1.4.tgz",
+ "integrity": "sha512-fc7cBosfhnbh53Mbm6a45W+F735jwZ1UFIYSrIqcO/gRIFoDyZeMtgKlpV4DdyQfbCzdh5LoALLTDRxhMpTyXQ==",
+ "license": "MIT",
+ "dependencies": {
+ "classnames": "2.3.1",
+ "tiny-invariant": "1.2.0"
+ },
+ "peerDependencies": {
+ "@types/sortablejs": "1",
+ "react": ">=16.9.0",
+ "react-dom": ">=16.9.0",
+ "sortablejs": "1"
+ }
+ },
+ "node_modules/react-sortablejs/node_modules/classnames": {
+ "version": "2.3.1",
+ "resolved": "https://registry.npmmirror.com/classnames/-/classnames-2.3.1.tgz",
+ "integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA==",
+ "license": "MIT"
+ },
"node_modules/readdirp": {
"version": "4.1.2",
"resolved": "https://registry.npmmirror.com/readdirp/-/readdirp-4.1.2.tgz",
@@ -6693,6 +6723,13 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/sortablejs": {
+ "version": "1.15.6",
+ "resolved": "https://registry.npmmirror.com/sortablejs/-/sortablejs-1.15.6.tgz",
+ "integrity": "sha512-aNfiuwMEpfBM/CN6LY0ibyhxPfPbyFeBTYJKCvzkJ2GkUpazIt3H+QIPAMHwqQ7tMKaHz1Qj+rJJCqljnf4p3A==",
+ "license": "MIT",
+ "peer": true
+ },
"node_modules/source-map-js": {
"version": "1.2.1",
"resolved": "https://registry.npmmirror.com/source-map-js/-/source-map-js-1.2.1.tgz",
@@ -6962,6 +6999,12 @@
"node": ">=12.22"
}
},
+ "node_modules/tiny-invariant": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmmirror.com/tiny-invariant/-/tiny-invariant-1.2.0.tgz",
+ "integrity": "sha512-1Uhn/aqw5C6RI4KejVeTg6mIS7IqxnLJ8Mv2tV5rTc0qWobay7pDUz6Wi392Cnc8ak1H0F2cjoRzb2/AW4+Fvg==",
+ "license": "MIT"
+ },
"node_modules/tinyglobby": {
"version": "0.2.13",
"resolved": "https://registry.npmmirror.com/tinyglobby/-/tinyglobby-0.2.13.tgz",
diff --git a/package.json b/package.json
index f60d5f47..17a42eba 100644
--- a/package.json
+++ b/package.json
@@ -32,6 +32,7 @@
"react-dom": "^18",
"react-i18next": "15.4.1",
"react-icons": "^5.5.0",
+ "react-sortablejs": "^6.1.4",
"sass": "^1.59.2",
"zustand": "^5.0.4"
},
diff --git a/src/api/account.ts b/src/api/account.ts
new file mode 100644
index 00000000..66e212b0
--- /dev/null
+++ b/src/api/account.ts
@@ -0,0 +1,62 @@
+// 创建或更新账户
+import sxRequest from "@/utils/request";
+import {
+ AccountGroupItem,
+ SocialAccount,
+ UpdateAccountStatisticsParams,
+} from "@/api/types/account.type";
+
+export const createOrUpdateAccountApi = (data: Omit<SocialAccount, "id">) => {
+ return sxRequest.post<SocialAccount>("account/login", data);
+};
+
+// 更新账户状态
+export const updateAccountStatusApi = (data: {
+ id: number;
+ status: number;
+}) => {
+ return sxRequest.post<SocialAccount>("account/status", data);
+};
+
+// 获取账户列表
+export const getAccountListApi = () => {
+ return sxRequest.get<SocialAccount[]>("account/list/all");
+};
+
+// 获取账户详情
+export const getAccountDetailApi = (id: number) => {
+ return sxRequest.get<SocialAccount>(`account/${id}`);
+};
+
+export const updateAccountStatisticsApi = (
+ data: UpdateAccountStatisticsParams,
+) => {
+ return sxRequest.post<SocialAccount>("account/statistics/update", data);
+};
+
+// 删除账户
+export const deleteAccountApi = (id: number) => {
+ return sxRequest.post<SocialAccount>(`account/delete/${id}`);
+};
+
+// 创建账户组
+export const createAccountGroupApi = (data: Partial<AccountGroupItem>) => {
+ return sxRequest.post("accountGroup/create", data);
+};
+
+// 更新账户组
+export const updateAccountGroupApi = (data: AccountGroupItem) => {
+ return sxRequest.post("accountGroup/update", data);
+};
+
+// 删除账户组
+export const deleteAccountGroupApi = (ids: number[]) => {
+ return sxRequest.post("accountGroup/update", {
+ ids,
+ });
+};
+
+// 获取所有账户组
+export const getAccountGroupApi = () => {
+ return sxRequest.get<AccountGroupItem[]>("accountGroup/getList");
+};
diff --git a/src/api/apiReq.ts b/src/api/apiReq.ts
index cb9be562..9bf5efa8 100644
--- a/src/api/apiReq.ts
+++ b/src/api/apiReq.ts
@@ -1,19 +1,12 @@
import sxRequest from "@/utils/request";
import { UserInfo } from "@/store/user";
-export interface ResponseType<T> {
- code: string | number;
- data: T;
- msg: string;
- url: string;
-}
-
export interface LoginResponse {
- type: 'regist' | 'login'; // 登录类型:regist-需要注册,login-直接登录
+ type: "regist" | "login"; // 登录类型:regist-需要注册,login-直接登录
token?: string;
registUrl?: string;
- code?: string; // 注册码
- userInfo?: UserInfo; // 用户信息
+ code?: string; // 注册码
+ userInfo?: UserInfo; // 用户信息
}
export interface RegistCheckParams {
@@ -48,7 +41,9 @@ export const loginWithMailApi = (data: { mail: string; password: string }) => {
// 获取注册链接
export const getRegistUrlApi = (mail: string) => {
- return sxRequest.get<LoginResponse>(`user/login/mail/regist/url?mail=${mail}`);
+ return sxRequest.get<LoginResponse>(
+ `user/login/mail/regist/url?mail=${mail}`,
+ );
};
// 检查注册状态 post!!
@@ -62,71 +57,10 @@ export const sendResetPasswordMailApi = (data: { mail: string }) => {
};
// 重置密码
-export const resetPasswordApi = (data: { code: string; mail: string; password: string }) => {
+export const resetPasswordApi = (data: {
+ code: string;
+ mail: string;
+ password: string;
+}) => {
return sxRequest.post<LoginResponse>("user/login/repassword/mail/back", data);
};
-
-// 三方账户类型定义
-export interface SocialAccount {
- id: number;
- type: string;
- loginCookie: string;
- loginTime: string;
- uid: string;
- account: string;
- avatar: string;
- nickname: string;
- fansCount: number;
- readCount: number;
- likeCount: number;
- collectCount: number;
- forwardCount: number;
- commentCount: number;
- lastStatsTime: string;
- workCount: number;
- income: number;
- status: number;
- createTime: string;
- updateTime: string;
-}
-
-// 创建或更新账户
-export const createOrUpdateAccountApi = (data: Omit<SocialAccount, 'id'>) => {
- return sxRequest.post<SocialAccount>("account/login", data);
-};
-
-// 更新账户状态
-export const updateAccountStatusApi = (data: { id: number; status: number }) => {
- return sxRequest.post<SocialAccount>("account/status", data);
-};
-
-// 获取账户列表
-export const getAccountListApi = () => {
- return sxRequest.get<SocialAccount[]>("account/list/all");
-};
-
-// 获取账户详情
-export const getAccountDetailApi = (id: number) => {
- return sxRequest.get<SocialAccount>(`account/${id}`);
-};
-
-// 更新账户统计数据
-export interface UpdateAccountStatisticsParams {
- id: number;
- fansCount: number;
- readCount: number;
- likeCount: number;
- collectCount: number;
- commentCount: number;
- income: number;
- workCount: number;
-}
-
-export const updateAccountStatisticsApi = (data: UpdateAccountStatisticsParams) => {
- return sxRequest.post<SocialAccount>("account/statistics/update", data);
-};
-
-// 删除账户
-export const deleteAccountApi = (id: number) => {
- return sxRequest.post<SocialAccount>(`account/delete/${id}`);
-};
diff --git a/src/api/types/account.type.ts b/src/api/types/account.type.ts
new file mode 100644
index 00000000..06d31030
--- /dev/null
+++ b/src/api/types/account.type.ts
@@ -0,0 +1,46 @@
+import { PlatType } from "@/app/config/platConfig";
+
+// 三方账户类型定义
+export interface SocialAccount {
+ id: number;
+ type: PlatType;
+ loginCookie: string;
+ loginTime: string;
+ uid: string;
+ account: string;
+ avatar: string;
+ nickname: string;
+ fansCount: number;
+ readCount: number;
+ likeCount: number;
+ collectCount: number;
+ forwardCount: number;
+ commentCount: number;
+ lastStatsTime: string;
+ workCount: number;
+ income: number;
+ status: number;
+ createTime: string;
+ updateTime: string;
+ rank: number;
+ groupId: number;
+}
+
+// 更新账户统计数据
+export interface UpdateAccountStatisticsParams {
+ id: number;
+ fansCount: number;
+ readCount: number;
+ likeCount: number;
+ collectCount: number;
+ commentCount: number;
+ income: number;
+ workCount: number;
+}
+
+// 账户组 item 数据
+export interface AccountGroupItem {
+ id: number;
+ name: number;
+ rank: number;
+}
diff --git a/src/app/[lng]/accounts/accountCore.tsx b/src/app/[lng]/accounts/accountCore.tsx
new file mode 100644
index 00000000..180efef4
--- /dev/null
+++ b/src/app/[lng]/accounts/accountCore.tsx
@@ -0,0 +1,34 @@
+"use client";
+
+import styles from "./accounts.module.scss";
+import { useAccountStore } from "@/store/account";
+import { useShallow } from "zustand/react/shallow";
+import { useEffect, useState } from "react";
+import { NoSSR } from "@kwooshung/react-no-ssr";
+import AccountSidebar from "@/app/[lng]/accounts/components/AccountSidebar/AccountSidebar";
+
+export default function AccountPageCore() {
+ const { init } = useAccountStore(
+ useShallow((state) => ({
+ init: state.init,
+ })),
+ );
+ const [activeAccountId, setActiveAccountId] = useState(-1);
+
+ useEffect(() => {
+ init();
+ }, []);
+
+ return (
+ <NoSSR>
+ <div className={styles.accounts}>
+ <AccountSidebar
+ activeAccountId={activeAccountId}
+ onAccountChange={() => {
+ console.log("change");
+ }}
+ />
+ </div>
+ </NoSSR>
+ );
+}
diff --git a/src/app/[lng]/accounts/accounts.module.css b/src/app/[lng]/accounts/accounts.module.css
deleted file mode 100644
index 41b4040f..00000000
--- a/src/app/[lng]/accounts/accounts.module.css
+++ /dev/null
@@ -1,21 +0,0 @@
-.container {
- min-height: 100vh;
- padding: 24px;
- background-color: var(--background-color);
-}
-
-.card {
- margin: 0 auto;
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
- border-radius: 8px;
-}
-
-@media (max-width: 768px) {
- .container {
- padding: 16px;
- }
-
- .card {
- margin: 0;
- }
-}
\ No newline at end of file
diff --git a/src/app/[lng]/accounts/accounts.module.scss b/src/app/[lng]/accounts/accounts.module.scss
new file mode 100644
index 00000000..0a3e6115
--- /dev/null
+++ b/src/app/[lng]/accounts/accounts.module.scss
@@ -0,0 +1,6 @@
+.accounts {
+ @include height_100vh;
+ display: flex;
+
+ height: 100vh !important;
+}
\ No newline at end of file
diff --git a/src/app/[lng]/accounts/components/AccountSidebar/AccountSidebar.module.scss b/src/app/[lng]/accounts/components/AccountSidebar/AccountSidebar.module.scss
new file mode 100644
index 00000000..0c64d2c6
--- /dev/null
+++ b/src/app/[lng]/accounts/components/AccountSidebar/AccountSidebar.module.scss
@@ -0,0 +1,381 @@
+.accountSidebar {
+ border-right: 1px solid var(--grayColor3);
+ width: 200px;
+ height: 100%;
+ min-height: 0;
+ flex-shrink: 0;
+ display: flex;
+ flex-direction: column;
+
+ p {
+ margin: 0;
+ }
+
+ :global {
+ .accountSidebar-userCount {
+ display: inline-block;
+ margin-left: 10px;
+ color: var(--grayColor6);
+ }
+
+ .accountSidebar-top {
+ flex-shrink: 0;
+ padding: 0 10px;
+ button {
+ width: 100%;
+ }
+ &-box {
+ display: flex;
+ margin: 10px 0;
+ }
+ &-addUser {
+ margin-left: 10px;
+ width: 60px !important;
+ }
+ }
+
+ .accountSidebar-footer {
+ padding: 5px 0;
+ border-top: 1px solid var(--grayColor3);
+ text-align: center;
+ }
+
+ .accountList {
+ width: 100%;
+ height: 100%;
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ overflow: auto;
+ &-item {
+ width: 100%;
+ min-width: 0;
+ display: flex;
+ align-items: center;
+ padding: 10px 15px;
+ box-sizing: border-box;
+ cursor: pointer;
+ background: #fff;
+ transition: 0.3s;
+ color: #333;
+ .ant-avatar {
+ flex-shrink: 0;
+ }
+ &-right {
+ margin-left: 10px;
+ box-sizing: border-box;
+ width: 100%;
+ overflow: hidden;
+ &-name {
+ text-align: left;
+ margin-bottom: 5px;
+ font-size: var(--fs-sm);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ &-footer {
+ display: flex;
+ justify-content: space-between;
+ font-size: var(--fs-sm);
+ }
+ &-plat {
+ display: flex;
+ align-items: center;
+ img {
+ width: 15px;
+ margin-right: 5px;
+ }
+ span {
+ font-size: var(--fs-xs);
+ }
+ }
+ }
+
+ &:hover {
+ color: var(--colorPrimary5);
+ background: var(--colorPrimary1);
+ }
+
+ &--active {
+ background: var(--colorPrimary1);
+ }
+
+ &--abnormal {
+ color: red !important;
+ }
+
+ &--disable {
+ filter: grayscale(100%) !important;
+ opacity: 0.5 !important;
+ }
+ }
+ }
+
+ .ant-collapse {
+ overflow: auto;
+ height: 100%;
+ border: none;
+ background: transparent;
+ .ant-collapse-content-box {
+ padding: 0;
+ }
+ .ant-collapse-header {
+ background: transparent;
+ padding: 10px;
+ }
+ }
+ }
+}
+
+.accountPopoverInfo {
+ padding: 10px;
+ width: 250px;
+ :global {
+ .accountPopoverInfo_top {
+ display: flex;
+ font-size: var(--fs-sm);
+ padding: 5px 0 10px 0;
+ border-bottom: 1px solid #dedede;
+ margin-bottom: 15px;
+ color: var(--grayColor7);
+ &-right {
+ margin-left: 10px;
+ }
+ }
+ .accountPopoverInfo-item {
+ display: flex;
+ align-items: center;
+ margin-bottom: 5px;
+ p {
+ display: flex;
+ align-items: center;
+ &:nth-of-type(1) {
+ color: var(--grayColor7);
+ }
+ img {
+ width: 15px;
+ margin-right: 5px;
+ }
+
+ .anticon {
+ margin-right: 3px;
+ }
+ }
+ }
+ }
+}
+
+.userManageDeleteHitModal {
+ .userManageDeleteHitModal-users {
+ display: grid;
+ gap: 15px;
+ grid-template-columns: repeat(6, 1fr);
+ margin-top: 10px;
+ li {
+ display: flex;
+ justify-content: center;
+ flex-direction: column;
+ white-space: nowrap;
+ overflow: hidden;
+ & > span {
+ text-overflow: ellipsis;
+ display: block;
+ margin-top: 5px;
+ overflow: hidden;
+ width: 100%;
+ text-align: center;
+ font-size: var(--fs-xs);
+ color: var(--grayColor9);
+ }
+ }
+ }
+}
+.userManageModal {
+ :global {
+ .ant-modal-header {
+ margin-bottom: 0;
+ }
+ .ant-modal-content {
+ padding: 0 !important;
+ .ant-modal-title {
+ padding: 15px;
+ border-bottom: 1px solid var(--grayColor3);
+ }
+ }
+ }
+}
+.userManage {
+ display: flex;
+ min-width: 0;
+ height: 500px;
+ :global {
+ @include table-flex-container-with-selectors;
+
+ .ant-table-cell {
+ padding: 10px !important;
+ }
+
+ .userManage-sidebar {
+ width: 200px;
+ height: 100%;
+ border-right: 1px solid var(--grayColor3);
+ flex-shrink: 0;
+ display: flex;
+ flex-direction: column;
+ justify-content: space-between;
+ box-sizing: border-box;
+ padding-top: 10px;
+ &-top {
+ display: flex;
+ flex-direction: column;
+ min-height: 0;
+ }
+ &-bottom {
+ padding: 0 12px;
+ margin-bottom: 15px;
+ button {
+ width: 100%;
+ }
+ }
+ &-allUser, .userManage-sidebar-list-item {
+ display: flex;
+ justify-content: space-between;
+ padding-right: 10px;
+ padding-left: 10px;
+ background: transparent;
+ &:hover {
+ background: var(--colorPrimary3);
+ cursor: pointer;
+ }
+ }
+ &-allUser {
+ padding-top: 5px;
+ padding-bottom: 5px;
+ }
+ &-sortHandle {
+ cursor: move;
+ margin-right: 10px;
+ }
+ &-left {
+ display: flex;
+ }
+ &-name {
+ }
+ &-count {
+ color: var(--grayColor8);
+ }
+ &-list {
+ display: flex;
+ flex-direction: column;
+ min-height: 0;
+ height: 100%;
+
+ &-title {
+ margin: 10px 0 10px 10px;
+ font-size: var(--fs-xs);
+ color: var(--grayColor8);
+ }
+
+ &-item {
+ padding-top: 10px;
+ padding-bottom: 10px;
+ }
+
+ &-sortable {
+ height: 100%;
+ overflow: auto;
+ padding-bottom: 15px;
+ }
+ }
+ &--active {
+ background: var(--colorPrimary3) !important;
+ }
+ }
+
+ .userManage-content {
+ width: 100%;
+ overflow: hidden;
+ position: relative;
+ padding: 10px;
+
+ &-head {
+ display: flex;
+ justify-content: space-between;
+ margin-bottom: 10px;
+ &-proxy {
+
+ }
+ }
+
+ .ant-drawer-header {
+ height: 40px;
+ .ant-drawer-close {
+ position: absolute;
+ right: 10px;
+ }
+ }
+
+ .ant-drawer-content-wrapper {
+ border: 1px solid var(--grayColor3);
+ border-radius: 20px 20px 0 0;
+ overflow: hidden;
+ .ant-drawer-content {
+ }
+ .ant-drawer-body {
+ overflow: hidden;
+ }
+ }
+
+ &-multiple {
+ display: flex;
+ gap: 40px;
+ justify-content: center;
+ &-item {
+ cursor: pointer;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ &-icon {
+ background: var(--grayColor1);
+ width: 36px;
+ height: 36px;
+ font-size: var(--fs-md);
+ border-radius: 50%;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ margin-bottom: 5px;
+ }
+ &:hover {
+ opacity: 0.6;
+ }
+ }
+ }
+
+ &-user {
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ &--disable {
+ filter: grayscale(100%);
+ opacity: 0.5;
+ }
+ .ant-avatar {
+ margin-right: 5px;
+ }
+ }
+ }
+ }
+}
+
+.createGroup {
+ display: flex;
+ align-items: center;
+ margin: 30px 0 50px 0;
+ label {
+ white-space: nowrap;
+ margin-right: 10px;
+ }
+}
\ No newline at end of file
diff --git a/src/app/[lng]/accounts/components/AccountSidebar/AccountSidebar.tsx b/src/app/[lng]/accounts/components/AccountSidebar/AccountSidebar.tsx
new file mode 100644
index 00000000..2e306a25
--- /dev/null
+++ b/src/app/[lng]/accounts/components/AccountSidebar/AccountSidebar.tsx
@@ -0,0 +1,293 @@
+import {
+ ForwardedRef,
+ forwardRef,
+ memo,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
+import styles from "./AccountSidebar.module.scss";
+import { Avatar, Button, Collapse, Popover, Tooltip } from "antd";
+// import { accountLogin, acpAccountLoginCheck } from "@/icp/account";
+import AddAccountModal from "../AddAccountModal";
+import {
+ CheckCircleOutlined,
+ PlusOutlined,
+ UserOutlined,
+ WarningOutlined,
+} from "@ant-design/icons";
+import { useShallow } from "zustand/react/shallow";
+import { useAccountStore } from "@/store/account";
+import UserManageModal, { IUserManageModalRef } from "./UserManageModal";
+import { AccountPlatInfoMap, PlatType } from "@/app/config/platConfig";
+import { AccountStatus } from "@/app/config/accountConfig";
+import { SocialAccount } from "@/api/types/account.type";
+
+export interface IAccountSidebarRef {}
+
+export interface IAccountSidebarProps {
+ // 选择的账户id
+ activeAccountId: number;
+ // 切换选择的账户
+ onAccountChange: (info: SocialAccount) => void;
+ // 排除的平台类型
+ excludePlatforms?: PlatType[];
+}
+
+const AccountStatusView = ({ account }: { account: SocialAccount }) => {
+ if (account.status === AccountStatus.USABLE) {
+ return (
+ <>
+ <CheckCircleOutlined style={{ color: "var(--successColor)" }} />
+ 在线
+ </>
+ );
+ }
+
+ return (
+ <>
+ <WarningOutlined style={{ color: "var(--warningColor)" }} />
+ 离线
+ </>
+ );
+};
+
+const AccountPopoverInfo = ({
+ accountInfo,
+}: {
+ accountInfo: SocialAccount;
+}) => {
+ const platInfo = AccountPlatInfoMap.get(accountInfo.type)!;
+ const [detLoading, setDetLoading] = useState(false);
+
+ return (
+ <div
+ className={styles.accountPopoverInfo}
+ onClick={(e) => e.stopPropagation()}
+ >
+ <div className="accountPopoverInfo_top">
+ <Avatar src={accountInfo.avatar} size="large" />
+ <div className="accountPopoverInfo_top-right">
+ <div className="accountPopoverInfo-item">
+ <p>昵称:</p>
+ <p>{accountInfo.nickname}</p>
+ </div>
+ <div className="accountPopoverInfo-item">
+ <p>平台:</p>
+ <p>
+ <img src={platInfo.icon} />
+ {platInfo.name}
+ </p>
+ </div>
+ </div>
+ </div>
+
+ <div className="accountPopoverInfo-item">
+ <p>登录状态:</p>
+ <p>
+ <AccountStatusView account={accountInfo} />
+ <Button
+ type="link"
+ style={{ padding: "0 0 0 5px" }}
+ loading={detLoading}
+ onClick={async () => {
+ // TODO 登录状态检测
+ // setDetLoading(true);
+ // const res = await acpAccountLoginCheck(
+ // accountInfo!.type,
+ // accountInfo!.uid,
+ // );
+ // message.success(
+ // `登录状态检测完成:${res.status === AccountStatus.USABLE ? "在线" : "离线,请重新登录"}`,
+ // );
+ // setTimeout(async () => {
+ // setDetLoading(false);
+ // if (res.status === AccountStatus.DISABLE) {
+ // const res = await accountLogin(accountInfo.type);
+ // if (!res) return;
+ // message.success("账号更新成功!");
+ // }
+ // }, 500);
+ }}
+ >
+ 登录状态检测
+ </Button>
+ </p>
+ </div>
+ </div>
+ );
+};
+
+const AccountSidebar = memo(
+ forwardRef(
+ (
+ {
+ activeAccountId,
+ onAccountChange,
+ excludePlatforms = [],
+ }: IAccountSidebarProps,
+ ref: ForwardedRef<IAccountSidebarRef>,
+ ) => {
+ const [isAccountModalOpen, setIsAccountModalOpen] = useState(false);
+ const pubAccountDetModuleRef = useRef<any>(null);
+ const {
+ accountList: fullAccountList,
+ getAccountList,
+ accountGroupList,
+ } = useAccountStore(
+ useShallow((state) => ({
+ accountList: state.accountList,
+ getAccountList: state.getAccountList,
+ accountGroupList: state.accountGroupList,
+ })),
+ );
+ const [userManageModalOpen, setUserManageModalOpen] = useState(false);
+ const userManageModalRef = useRef<IUserManageModalRef>(null);
+
+ // 在组件内部过滤账号列表,而不是在 useAccountStore 中过滤
+ const accountList = useMemo(() => {
+ return fullAccountList.filter(
+ (account) => !excludePlatforms.includes(account.type),
+ );
+ }, [fullAccountList, excludePlatforms]);
+
+ return (
+ <>
+ <UserManageModal
+ ref={userManageModalRef}
+ open={userManageModalOpen}
+ onCancel={() => setUserManageModalOpen(false)}
+ />
+ {/*TODO 在线状态检测 */}
+ {/*<PubAccountDetModule*/}
+ {/* title="账号检测"*/}
+ {/* tips="所有平台在线"*/}
+ {/* ref={pubAccountDetModuleRef}*/}
+ {/* accounts={accountList}*/}
+ {/* isFooter={false}*/}
+ {/*/>*/}
+ <AddAccountModal
+ open={isAccountModalOpen}
+ onClose={() => setIsAccountModalOpen(false)}
+ onAddSuccess={getAccountList}
+ />
+ <div className={styles.accountSidebar}>
+ <div className="accountSidebar-top">
+ <div className="accountSidebar-top-box">
+ <Button
+ onClick={() => {
+ setUserManageModalOpen(true);
+ }}
+ >
+ <UserOutlined />
+ 账号管理器
+ </Button>
+ <Tooltip title="添加账号">
+ <Button
+ type="primary"
+ className="accountSidebar-top-addUser"
+ icon={<PlusOutlined />}
+ onClick={() => {
+ setIsAccountModalOpen(true);
+ }}
+ ></Button>
+ </Tooltip>
+ </div>
+ </div>
+
+ <Collapse
+ items={accountGroupList.map((v) => {
+ return {
+ key: v.id,
+ label: (
+ <>
+ {v.name}
+ <span className="accountSidebar-userCount">
+ {v.children?.length}/
+ {
+ v.children?.map(
+ (v) => v.status === AccountStatus.USABLE,
+ ).length
+ }
+ </span>
+ </>
+ ),
+ children: (
+ <ul key={v.id} className="accountList">
+ {v.children?.map((account) => {
+ if (excludePlatforms.includes(account.type)) return "";
+ const platInfo = AccountPlatInfoMap.get(account.type)!;
+ return (
+ <li
+ className={[
+ "accountList-item",
+ `${activeAccountId === account.id ? "accountList-item--active" : ""}`,
+ // 失效状态
+ account.status === AccountStatus.DISABLE &&
+ "accountList-item--disable",
+ ].join(" ")}
+ key={account.id}
+ onClick={async () => {
+ if (account.status === AccountStatus.DISABLE) {
+ // TODO 账户登录
+ // const res = await accountLogin(account.type);
+ // if (!res) return;
+ // message.success("账号登录成功!");
+ // return;
+ }
+ onAccountChange(account);
+ }}
+ >
+ <Avatar src={account.avatar} size="large" />
+ <div className="accountList-item-right">
+ <div
+ className="accountList-item-right-name"
+ title={account.nickname}
+ >
+ <Tooltip title={undefined}>
+ {account.nickname}
+ </Tooltip>
+ </div>
+ <div className="accountList-item-right-footer">
+ <p className="accountList-item-right-plat">
+ <img src={platInfo.icon} />
+ <span>{platInfo.name}</span>
+ </p>
+ <Popover
+ content={
+ <AccountPopoverInfo accountInfo={account} />
+ }
+ placement="right"
+ >
+ ...
+ </Popover>
+ </div>
+ </div>
+ </li>
+ );
+ })}
+ </ul>
+ ),
+ };
+ })}
+ />
+
+ <div className="accountSidebar-footer">
+ <Button
+ type="link"
+ onClick={() => {
+ pubAccountDetModuleRef.current?.startDet();
+ }}
+ >
+ 一键检测登录状态
+ </Button>
+ </div>
+ </div>
+ </>
+ );
+ },
+ ),
+);
+AccountSidebar.displayName = "AccountSidebar";
+
+export default AccountSidebar;
diff --git a/src/app/[lng]/accounts/components/AccountSidebar/UserManageModal.tsx b/src/app/[lng]/accounts/components/AccountSidebar/UserManageModal.tsx
new file mode 100644
index 00000000..3aa15046
--- /dev/null
+++ b/src/app/[lng]/accounts/components/AccountSidebar/UserManageModal.tsx
@@ -0,0 +1,346 @@
+import {
+ ForwardedRef,
+ forwardRef,
+ memo,
+ useImperativeHandle,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
+import {
+ Avatar,
+ Drawer,
+ message,
+ Modal,
+ Select,
+ Table,
+ TableProps,
+ Tooltip,
+} from "antd";
+import styles from "./AccountSidebar.module.scss";
+import { useAccountStore } from "@/store/account";
+import { useShallow } from "zustand/react/shallow";
+import {
+ CheckCircleOutlined,
+ DeleteOutlined,
+ WarningOutlined,
+} from "@ant-design/icons";
+import UserManageSidebar from "./UserManageSidebar";
+import { SocialAccount } from "@/api/types/account.type";
+import { AccountPlatInfoMap } from "@/app/config/platConfig";
+import { AccountStatus } from "@/app/config/accountConfig";
+import AvatarPlat from "@/components/AvatarPlat";
+
+export interface IUserManageModalRef {
+ setActiveGroup: (groupId: number) => void;
+}
+
+export interface IUserManageModalProps {
+ open: boolean;
+ onCancel: () => void;
+}
+
+const UserGroupSelect = ({
+ account,
+ onChange,
+}: {
+ account: SocialAccount;
+ onChange: (groupId: number) => void;
+}) => {
+ const { accountGroupList } = useAccountStore(
+ useShallow((state) => ({
+ accountGroupList: state.accountGroupList,
+ })),
+ );
+
+ return (
+ <Select
+ value={account.groupId}
+ style={{ width: "160px" }}
+ fieldNames={{
+ value: "id",
+ label: "name",
+ }}
+ options={accountGroupList}
+ onChange={onChange}
+ />
+ );
+};
+
+const UserManageModal = memo(
+ forwardRef(
+ (
+ { open, onCancel }: IUserManageModalProps,
+ ref: ForwardedRef<IUserManageModalRef>,
+ ) => {
+ const { accountList, getAccountList, accountGroupList, accountMap } =
+ useAccountStore(
+ useShallow((state) => ({
+ accountList: state.accountList,
+ getAccountList: state.getAccountList,
+ accountGroupList: state.accountGroupList,
+ accountMap: state.accountMap,
+ })),
+ );
+ const [deleteHitOpen, setDeleteHitOpen] = useState(false);
+ const [selectedRows, setSelectedRows] = useState<SocialAccount[]>([]);
+ // 全部账号
+ const allUser = useRef(-1);
+ // -1=全部账号,不然为对应分组 ID
+ const [activeGroup, setActiveGroup] = useState(allUser.current);
+ // 是否改变了顺序
+ const isUpdateRank = useRef(false);
+
+ const columns = useMemo(() => {
+ const columns: TableProps<SocialAccount>["columns"] = [
+ {
+ title: "账号",
+ render: (text, am) => {
+ return (
+ <div
+ className={`userManage-content-user ${am.status === AccountStatus.DISABLE ? "userManage-content-user--disable" : ""}`}
+ >
+ <Avatar src={am.avatar} />
+ <span
+ className="userManage-content-user-name"
+ title={am.nickname}
+ >
+ {am.nickname}
+ </span>
+ </div>
+ );
+ },
+ width: 200,
+ key: "nickname",
+ },
+ {
+ title: "平台",
+ render: (text, am) => {
+ const platInfo = AccountPlatInfoMap.get(am.type)!;
+ return (
+ <div className="userManage-content-plat">
+ <Tooltip title={platInfo.name}>
+ <img src={platInfo.icon} />
+ </Tooltip>
+ </div>
+ );
+ },
+ width: 80,
+ key: "nickname",
+ },
+ {
+ title: "账号状态",
+ render: (text, am) => {
+ return (
+ <>
+ {am.status === AccountStatus.USABLE ? (
+ <>
+ <CheckCircleOutlined
+ style={{
+ color: "var(--successColor)",
+ marginRight: "3px",
+ }}
+ />
+ 在线
+ </>
+ ) : (
+ <>
+ <WarningOutlined
+ style={{
+ color: "var(--warningColor)",
+ marginRight: "3px",
+ }}
+ />
+ 离线
+ </>
+ )}
+ </>
+ );
+ },
+ width: 100,
+ key: "nickname",
+ },
+ {
+ title: "所属列表",
+ render: (text, am) => {
+ return (
+ <UserGroupSelect
+ account={am}
+ onChange={async (groupId) => {
+ await updateAccountGroupRank();
+ // TODO 编辑
+ // await icpAccountEditGroup(am.id, groupId);
+ await getAccountList();
+ }}
+ />
+ );
+ },
+ width: 200,
+ key: "groupId",
+ },
+ ];
+ return columns;
+ }, []);
+
+ const rowSelection: TableProps<SocialAccount>["rowSelection"] = {
+ onChange: (
+ selectedRowKeys: React.Key[],
+ selectedRows: SocialAccount[],
+ ) => {
+ setSelectedRows(selectedRows);
+ },
+ getCheckboxProps: (record: SocialAccount) => ({
+ name: record.nickname,
+ }),
+ selectedRowKeys: selectedRows.map((v) => v.id),
+ };
+
+ const close = () => {
+ onCancel();
+ setSelectedRows([]);
+ updateAccountGroupRank();
+ };
+
+ // 更新账户组顺序
+ const updateAccountGroupRank = async () => {
+ if (isUpdateRank.current) {
+ const accountGroupList = useAccountStore.getState().accountGroupList;
+ for (let i = 0; i < accountGroupList.length; i++) {
+ const v = accountGroupList[i];
+ // 这里不需要更新数据,因为在排序完成后已经更新了全局的sotre,引用sotre的所有位置都会发生更改
+ // TODO 排序更新
+ // await icpEditDeleteAccountGroup({
+ // id: v.id,
+ // rank: i,
+ // });
+ }
+ isUpdateRank.current = false;
+ }
+ };
+
+ const accountListLast = useMemo(() => {
+ if (activeGroup === allUser.current) {
+ return accountList;
+ }
+ return accountGroupList.find((v) => v.id === activeGroup)?.children;
+ }, [accountMap, activeGroup, accountGroupList]);
+
+ const imperativeHandle: IUserManageModalRef = {
+ setActiveGroup,
+ };
+ useImperativeHandle(ref, () => imperativeHandle);
+
+ return (
+ <>
+ <Modal
+ centered
+ open={deleteHitOpen}
+ title="删除提示"
+ width={500}
+ zIndex={1002}
+ onCancel={() => setDeleteHitOpen(false)}
+ rootClassName={styles.userManageDeleteHitModal}
+ onOk={async () => {
+ // TODO 删除
+ // await icpDeleteAccounts(selectedRows.map((v) => v.id));
+ // await getAccountList();
+ // setDeleteHitOpen(false);
+ // setSelectedRows([]);
+ // message.success("删除成功");
+ }}
+ >
+ <p>
+ 是否删除以下
+ <span style={{ color: "var(--errerColor)" }}>
+ {selectedRows.length}
+ </span>
+ 个账号?
+ </p>
+ <div className={styles["userManageDeleteHitModal-users"]}>
+ {selectedRows.map((v) => {
+ return (
+ <li key={v.id}>
+ <AvatarPlat account={v} size="large" />
+ <span>{v.nickname}</span>
+ </li>
+ );
+ })}
+ </div>
+ </Modal>
+
+ <Modal
+ open={open}
+ title="账号管理器"
+ zIndex={1001}
+ footer={null}
+ width={1000}
+ onCancel={close}
+ rootClassName={styles.userManageModal}
+ >
+ <div className={styles.userManage}>
+ <UserManageSidebar
+ allUser={allUser.current}
+ activeGroup={activeGroup}
+ onChange={setActiveGroup}
+ onSortEnd={() => {
+ isUpdateRank.current = true;
+ }}
+ />
+
+ <div className="userManage-content">
+ {/*<div className="userManage-content-head">*/}
+ {/* <div></div>*/}
+ {/*</div>*/}
+ <Table<SocialAccount>
+ columns={columns}
+ dataSource={accountListLast}
+ rowKey="id"
+ scroll={{ y: "100%" }}
+ rowSelection={{ type: "checkbox", ...rowSelection }}
+ />
+
+ <Drawer
+ title={
+ <>
+ 已选择
+ <span style={{ color: "var(--successColor)" }}>
+ {selectedRows.length}
+ </span>
+ 个账号
+ </>
+ }
+ placement="bottom"
+ mask={false}
+ height={150}
+ closable={true}
+ onClose={() => {
+ setSelectedRows([]);
+ }}
+ open={selectedRows.length !== 0}
+ getContainer={false}
+ >
+ <div className="userManage-content-multiple">
+ <div
+ className="userManage-content-multiple-item"
+ onClick={() => {
+ setDeleteHitOpen(true);
+ }}
+ >
+ <div className="userManage-content-multiple-item-icon">
+ <DeleteOutlined />
+ </div>
+ <span>删除账号</span>
+ </div>
+ </div>
+ </Drawer>
+ </div>
+ </div>
+ </Modal>
+ </>
+ );
+ },
+ ),
+);
+UserManageModal.displayName = "UserManageModal";
+
+export default UserManageModal;
diff --git a/src/app/[lng]/accounts/components/AccountSidebar/UserManageSidebar.tsx b/src/app/[lng]/accounts/components/AccountSidebar/UserManageSidebar.tsx
new file mode 100644
index 00000000..52a26fdf
--- /dev/null
+++ b/src/app/[lng]/accounts/components/AccountSidebar/UserManageSidebar.tsx
@@ -0,0 +1,189 @@
+import { ForwardedRef, forwardRef, memo, useRef, useState } from "react";
+import { Button, Input, message, Modal } from "antd";
+import {
+ ExclamationCircleFilled,
+ PlusOutlined,
+ UnorderedListOutlined,
+} from "@ant-design/icons";
+import { useAccountStore } from "@/store/account";
+import { useShallow } from "zustand/react/shallow";
+import styles from "./AccountSidebar.module.scss";
+import { ReactSortable } from "react-sortablejs";
+
+export interface IUserManageSidebarRef {}
+
+export interface IUserManageSidebarProps {
+ activeGroup: number;
+ allUser: number;
+ onChange: (id: number) => void;
+ onSortEnd: () => void;
+}
+
+const { confirm } = Modal;
+
+const UserManageSidebar = memo(
+ forwardRef(
+ (
+ { activeGroup, allUser, onChange, onSortEnd }: IUserManageSidebarProps,
+ ref: ForwardedRef<IUserManageSidebarRef>,
+ ) => {
+ const {
+ accountGroupList,
+ accountList,
+ setAccountGroupList,
+ getAccountGroup,
+ getAccountList,
+ } = useAccountStore(
+ useShallow((state) => ({
+ accountGroupList: state.accountGroupList,
+ accountList: state.accountList,
+ getAccountGroup: state.getAccountGroup,
+ getAccountList: state.getAccountList,
+ setAccountGroupList: state.setAccountGroupList,
+ })),
+ );
+ const [openCreateGroup, setOpenCreateGroup] = useState(false);
+ const [groupName, setGroupName] = useState("");
+ const [createGroupLoading, setCreateGroupLoading] = useState(false);
+ // -1=新建 不然为重命名,值为要重命名的id
+ const [createGroupId, setCreateGroupId] = useState(0);
+ const srcollEl = useRef<HTMLElement>(undefined);
+
+ const createGroupCancel = () => {
+ setOpenCreateGroup(false);
+ setGroupName("");
+ };
+
+ return (
+ <>
+ <Modal
+ title={createGroupId === -1 ? "新建列表" : "重命名列表"}
+ open={openCreateGroup}
+ onCancel={createGroupCancel}
+ footer={
+ <>
+ <Button onClick={createGroupCancel}>取消</Button>
+ <Button
+ type="primary"
+ disabled={groupName.length === 0}
+ onClick={async () => {
+ setCreateGroupLoading(true);
+ // TODO 用户组新增和编辑
+ // if (createGroupId === -1) {
+ // await icpAddAccountGroup({
+ // name: groupName,
+ // });
+ // } else {
+ // await icpEditDeleteAccountGroup({
+ // name: groupName,
+ // id: createGroupId,
+ // });
+ // }
+
+ await getAccountGroup();
+ setCreateGroupLoading(false);
+ createGroupCancel();
+ }}
+ loading={createGroupLoading}
+ >
+ 保存
+ </Button>
+ </>
+ }
+ >
+ <div className={styles.createGroup}>
+ <label>列表名</label>
+ <Input
+ value={groupName}
+ placeholder="请输入列表名称"
+ onChange={(e) => setGroupName(e.target.value)}
+ />
+ </div>
+ </Modal>
+
+ <div className="userManage-sidebar">
+ <div className="userManage-sidebar-top">
+ <div
+ className={[
+ "userManage-sidebar-allUser",
+ activeGroup === allUser && "userManage-sidebar--active",
+ ].join(" ")}
+ onClick={() => {
+ onChange(allUser);
+ }}
+ >
+ <span className="userManage-sidebar-name">全部账号</span>
+ <span className="userManage-sidebar-count">
+ {accountList.length}
+ </span>
+ </div>
+ <div className="userManage-sidebar-list">
+ <p className="userManage-sidebar-list-title">列表</p>
+
+ <ReactSortable
+ className="userManage-sidebar-list-sortable"
+ list={accountGroupList}
+ animation={250}
+ onEnd={async () => {
+ onSortEnd();
+ }}
+ setList={setAccountGroupList}
+ scrollSensitivity={100}
+ scroll={srcollEl.current}
+ scrollSpeed={15}
+ handle=".userManage-sidebar-sortHandle"
+ id="id"
+ >
+ {accountGroupList.map((v) => {
+ return (
+ <div
+ className={[
+ "userManage-sidebar-list-item",
+ activeGroup === v.id && "userManage-sidebar--active",
+ ].join(" ")}
+ key={v.id}
+ onClick={() => {
+ onChange(v.id);
+ }}
+ onContextMenu={(e) => {
+ // TODO 用户组操作
+ }}
+ >
+ <div className="userManage-sidebar-left">
+ <div className="userManage-sidebar-sortHandle">
+ <UnorderedListOutlined />
+ </div>
+ <span className="userManage-sidebar-name">
+ {v.name}
+ </span>
+ </div>
+ <span className="userManage-sidebar-count">
+ {v.children.length}
+ </span>
+ </div>
+ );
+ })}
+ </ReactSortable>
+ </div>
+ </div>
+ <div className="userManage-sidebar-bottom">
+ <Button
+ type="primary"
+ icon={<PlusOutlined />}
+ onClick={() => {
+ setCreateGroupId(-1);
+ setOpenCreateGroup(true);
+ }}
+ >
+ 新建列表
+ </Button>
+ </div>
+ </div>
+ </>
+ );
+ },
+ ),
+);
+UserManageSidebar.displayName = "UserManageSidebar";
+
+export default UserManageSidebar;
diff --git a/src/app/[lng]/accounts/components/AddAccountModal.module.scss b/src/app/[lng]/accounts/components/AddAccountModal.module.scss
new file mode 100644
index 00000000..98980748
--- /dev/null
+++ b/src/app/[lng]/accounts/components/AddAccountModal.module.scss
@@ -0,0 +1,33 @@
+.addAccountModal {
+ :global {
+ h1 {
+ font-size: var(--fs-sm);
+ margin-bottom: 15px;
+ }
+ .addAccountModal_plats {
+ display: grid;
+ grid-template-columns: repeat(8, 1fr);
+ max-height: 400px;
+ overflow-y: auto;
+ &-item {
+ padding: 13px 0;
+ border-radius: 8px;
+ height: auto;
+ white-space: nowrap;
+ &-con {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ width: 100%;
+ img {
+ width: 35px;
+ margin-bottom: 4px;
+ }
+ }
+ span {
+ font-size: var(--fs-xs);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/app/[lng]/accounts/components/AddAccountModal.tsx b/src/app/[lng]/accounts/components/AddAccountModal.tsx
new file mode 100644
index 00000000..ad7eb709
--- /dev/null
+++ b/src/app/[lng]/accounts/components/AddAccountModal.tsx
@@ -0,0 +1,74 @@
+import { ForwardedRef, forwardRef, memo } from "react";
+import styles from "./AddAccountModal.module.scss";
+import { Button, Modal, Tooltip } from "antd";
+// import { accountLogin } from "@/icp/account";
+import { AccountPlatInfoArr } from "@/app/config/platConfig";
+import { SocialAccount } from "@/api/types/account.type";
+
+export interface IAddAccountModalRef {}
+
+export interface IAddAccountModalProps {
+ open: boolean;
+ onClose: () => void;
+ onAddSuccess: (accountInfo: SocialAccount) => void;
+}
+
+const AddAccountModal = memo(
+ forwardRef(
+ (
+ { open, onClose, onAddSuccess }: IAddAccountModalProps,
+ ref: ForwardedRef<IAddAccountModalRef>,
+ ) => {
+ const handleOk = () => {
+ onClose();
+ };
+
+ const handleCancel = () => {
+ onClose();
+ };
+
+ return (
+ <Modal
+ title="账号添加"
+ open={open}
+ onOk={handleOk}
+ onCancel={handleCancel}
+ footer={null}
+ width={650}
+ >
+ <div className={styles.addAccountModal}>
+ <h1>选择平台添加账号</h1>
+ <div className="addAccountModal_plats">
+ {AccountPlatInfoArr.map(([key, value]) => {
+ return (
+ <Tooltip title={value.tips?.account} key={key}>
+ <Button
+ type="text"
+ className="addAccountModal_plats-item"
+ onClick={async () => {
+ // TODO 账号登录逻辑
+ // const res = await accountLogin(key);
+ // if (!res) return;
+ // message.success("账号添加成功");
+ // onAddSuccess(res);
+ }}
+ >
+ <div className="addAccountModal_plats-item-con">
+ {/*<LoadingOutlined style={{ fontSize: '20px' }} />*/}
+ <img src={value.icon} />
+ <span>{value.name}</span>
+ </div>
+ </Button>
+ </Tooltip>
+ );
+ })}
+ </div>
+ </div>
+ </Modal>
+ );
+ },
+ ),
+);
+AddAccountModal.displayName = "AddAccountModal";
+
+export default AddAccountModal;
diff --git a/src/app/[lng]/accounts/page.tsx b/src/app/[lng]/accounts/page.tsx
index cfd4ea76..4c34cb8a 100644
--- a/src/app/[lng]/accounts/page.tsx
+++ b/src/app/[lng]/accounts/page.tsx
@@ -1,406 +1,5 @@
-"use client";
+import AccountPageCore from "@/app/[lng]/accounts/accountCore";
-import { useEffect, useState } from "react";
-import { Card, Table, Button, message, Modal, Form, Input, Select, InputNumber, Space, Tag, Descriptions } from "antd";
-import { useRouter } from "next/navigation";
-import { useUserStore } from "@/store/user";
-import {
- SocialAccount,
- createOrUpdateAccountApi,
- updateAccountStatusApi,
- getAccountListApi,
- updateAccountStatisticsApi,
- UpdateAccountStatisticsParams,
- deleteAccountApi
-} from "@/api/apiReq";
-import styles from "./accounts.module.css";
-
-const { Option } = Select;
-
-const PLATFORM_TYPES = [
- { value: 'douyin', label: '抖音', color: '#000000' },
- { value: 'xhs', label: '小红书', color: '#FF2442' },
- { value: 'bilibili', label: 'Bilibili', color: '#FB7299' },
- { value: 'KWAI', label: '快手', color: '#FFC300' },
- { value: 'facebook', label: 'Facebook', color: '#1877F2' },
- { value: 'twitter', label: 'Twitter', color: '#1DA1F2' },
-];
-
-export default function AccountsPage() {
- const router = useRouter();
- const { token } = useUserStore();
- const [loading, setLoading] = useState(true);
- const [accounts, setAccounts] = useState<SocialAccount[]>([]);
- const [isModalOpen, setIsModalOpen] = useState(false);
- const [isDetailModalOpen, setIsDetailModalOpen] = useState(false);
- const [currentAccount, setCurrentAccount] = useState<SocialAccount | null>(null);
- const [form] = Form.useForm();
-
- // 获取账户列表
- const fetchAccounts = async () => {
- try {
- const response: any = await getAccountListApi();
- if (!response) {
- message.error('获取账户列表失败');
- return;
- }
-
- if (response.code === 0 && response.data) {
- setAccounts(response.data);
- } else {
- message.error(response.msg || '获取账户列表失败');
- }
- } catch (error) {
- message.error('获取账户列表失败');
- } finally {
- setLoading(false);
- }
- };
-
- useEffect(() => {
- if (!token) {
- message.error('请先登录');
- router.push('/login');
- return;
- }
- fetchAccounts();
- }, [token, router]);
-
- // 处理账户状态更新
- const handleStatusChange = async (id: number, status: number) => {
- try {
- const response: any = await updateAccountStatusApi({ id, status });
- if (!response) {
- message.error('更新状态失败');
- return;
- }
-
- if (response.code === 0) {
- message.success('更新状态成功');
- fetchAccounts();
- } else {
- message.error(response.msg || '更新状态失败');
- }
- } catch (error) {
- message.error('更新状态失败');
- }
- };
-
- // 处理账户创建/更新
- const handleSubmit = async (values: any) => {
- try {
- const response: any = await createOrUpdateAccountApi(values);
- if (!response) {
- message.error('操作失败');
- return;
- }
-
- if (response.code === 0) {
- message.success('操作成功');
- setIsModalOpen(false);
- form.resetFields();
- fetchAccounts();
- } else {
- message.error(response.msg || '操作失败');
- }
- } catch (error) {
- message.error('操作失败');
- }
- };
-
- // 处理统计数据更新
- const handleStatisticsUpdate = async (record: SocialAccount) => {
- try {
- const params: UpdateAccountStatisticsParams = {
- id: record.id,
- fansCount: record.fansCount+1,
- readCount: record.readCount+1,
- workCount: record.workCount+1,
- likeCount: record.likeCount+1,
- collectCount: record.collectCount+1,
- commentCount: record.commentCount+1,
- income: record.income+1
- };
-
- const response: any = await updateAccountStatisticsApi(params);
- if (!response) {
- message.error('更新统计数据失败');
- return;
- }
-
- if (response.code === 0) {
- message.success('更新统计数据成功');
- fetchAccounts();
- } else {
- message.error(response.msg || '更新统计数据失败');
- }
- } catch (error) {
- message.error('更新统计数据失败');
- }
- };
-
- // 处理账户删除
- const handleDelete = async (id: number) => {
- try {
- const response: any = await deleteAccountApi(id);
- if (!response) {
- message.error('删除账户失败');
- return;
- }
-
- if (response.code === 0) {
- message.success('删除账户成功');
- fetchAccounts();
- } else {
- message.error(response.msg || '删除账户失败');
- }
- } catch (error) {
- message.error('删除账户失败');
- }
- };
-
- const columns = [
- {
- title: '平台',
- dataIndex: 'type',
- key: 'type',
- render: (type: string) => {
- const platform = PLATFORM_TYPES.find(p => p.value === type);
- return platform ? (
- <Tag color={platform.color}>{platform.label}</Tag>
- ) : type;
- }
- },
- {
- title: '账号',
- dataIndex: 'account',
- key: 'account',
- },
- {
- title: '昵称',
- dataIndex: 'nickname',
- key: 'nickname',
- },
- {
- title: '用户id',
- dataIndex: 'uid',
- key: 'uid',
- },
- {
- title: '粉丝数',
- dataIndex: 'fansCount',
- key: 'fansCount',
- },
- {
- title: '作品数',
- dataIndex: 'workCount',
- key: 'workCount',
- },
- {
- title: '收入',
- dataIndex: 'income',
- key: 'income',
- render: (income: number) => `¥${income.toFixed(2)}`,
- },
- {
- title: '状态',
- dataIndex: 'status',
- key: 'status',
- render: (status: number) => (
- <Tag color={status === 1 ? 'error' : 'success'}>
- {status === 1 ? '失效' : '在线'}
- </Tag>
- ),
- },
- {
- title: '操作',
- key: 'action',
- render: (_: any, record: SocialAccount) => (
- <Space>
- <Button
- type="link"
- onClick={() => {
- setCurrentAccount(record);
- setIsDetailModalOpen(true);
- }}
- >
- 详情
- </Button>
- <Button
- type="link"
- onClick={() => handleStatusChange(record.id, record.status === 1 ? 0 : 1)}
- >
- {record.status === 1 ? '登录' : '下线'}
- </Button>
- <Button
- type="link"
- onClick={() => handleStatisticsUpdate(record)}
- >
- 更新统计
- </Button>
- <Button
- type="link"
- danger
- onClick={() => {
- Modal.confirm({
- title: '确认删除',
- content: `确定要删除账号 ${record.account} 吗?`,
- okText: '确认',
- cancelText: '取消',
- onOk: () => handleDelete(record.id)
- });
- }}
- >
- 删除
- </Button>
- </Space>
- ),
- },
- ];
-
- return (
- <div className={styles.container}>
- <Card
- title="三方账户管理"
- className={styles.card}
- extra={
- <Button type="primary" onClick={() => setIsModalOpen(true)}>
- 添加账户
- </Button>
- }
- >
- <Table
- columns={columns}
- dataSource={accounts}
- rowKey="id"
- loading={loading}
- />
- </Card>
-
- <Modal
- title="添加账户"
- open={isModalOpen}
- onCancel={() => {
- setIsModalOpen(false);
- form.resetFields();
- }}
- footer={null}
- >
- <Form
- form={form}
- onFinish={handleSubmit}
- layout="vertical"
- >
- <Form.Item
- name="type"
- label="平台"
- rules={[{ required: true, message: '请选择平台' }]}
- >
- <Select placeholder="请选择平台">
- {PLATFORM_TYPES.map(platform => (
- <Option key={platform.value} value={platform.value}>
- {platform.label}
- </Option>
- ))}
- </Select>
- </Form.Item>
-
- <Form.Item
- name="account"
- label="账号"
- rules={[{ required: true, message: '请输入账号' }]}
- >
- <Input placeholder="请输入账号" />
- </Form.Item>
-
- <Form.Item
- name="nickname"
- label="昵称"
- rules={[{ required: true, message: '请输入昵称' }]}
- >
- <Input placeholder="请输入昵称" />
- </Form.Item>
-
- <Form.Item
- name="loginCookie"
- label="登录Cookie"
- rules={[{ required: true, message: '请输入登录Cookie' }]}
- >
- <Input.TextArea rows={4} placeholder="请输入登录Cookie" />
- </Form.Item>
-
- <Form.Item
- name="uid"
- label="用户ID"
- rules={[{ required: true, message: '请输入用户ID' }]}
- >
- <Input placeholder="请输入用户ID" />
- </Form.Item>
-
- <Form.Item
- name="avatar"
- label="头像URL"
- rules={[{ required: true, message: '请输入头像URL' }]}
- >
- <Input placeholder="请输入头像URL" />
- </Form.Item>
-
- <Form.Item>
- <Button type="primary" htmlType="submit" block>
- 确认添加
- </Button>
- </Form.Item>
- </Form>
- </Modal>
-
- <Modal
- title="账户详情"
- open={isDetailModalOpen}
- onCancel={() => {
- setIsDetailModalOpen(false);
- setCurrentAccount(null);
- }}
- footer={null}
- width={600}
- >
- {currentAccount && (
- <Descriptions bordered column={1}>
- <Descriptions.Item label="平台">
- {PLATFORM_TYPES.find(p => p.value === currentAccount.type)?.label}
- </Descriptions.Item>
- <Descriptions.Item label="账号">{currentAccount.account}</Descriptions.Item>
- <Descriptions.Item label="昵称">{currentAccount.nickname}</Descriptions.Item>
- <Descriptions.Item label="用户ID">{currentAccount.uid}</Descriptions.Item>
- <Descriptions.Item label="头像URL">
- <a href={currentAccount.avatar} target="_blank" rel="noopener noreferrer">
- {currentAccount.avatar}
- </a>
- </Descriptions.Item>
- <Descriptions.Item label="登录Cookie">
- <div style={{ wordBreak: 'break-all' }}>{currentAccount.loginCookie}</div>
- </Descriptions.Item>
- <Descriptions.Item label="粉丝数">{currentAccount.fansCount}</Descriptions.Item>
- <Descriptions.Item label="作品数">{currentAccount.workCount}</Descriptions.Item>
- <Descriptions.Item label="点赞数">{currentAccount.likeCount}</Descriptions.Item>
- <Descriptions.Item label="评论数">{currentAccount.commentCount}</Descriptions.Item>
- <Descriptions.Item label="转发数">{currentAccount.forwardCount}</Descriptions.Item>
- <Descriptions.Item label="收藏数">{currentAccount.collectCount}</Descriptions.Item>
- <Descriptions.Item label="阅读数">{currentAccount.readCount}</Descriptions.Item>
- <Descriptions.Item label="收入">¥{currentAccount.income.toFixed(2)}</Descriptions.Item>
- <Descriptions.Item label="状态">
- <Tag color={currentAccount.status === 1 ? 'error' : 'success'}>
- {currentAccount.status === 1 ? '失效' : '在线'}
- </Tag>
- </Descriptions.Item>
- <Descriptions.Item label="创建时间">
- {new Date(currentAccount.createTime).toLocaleString()}
- </Descriptions.Item>
- <Descriptions.Item label="更新时间">
- {new Date(currentAccount.updateTime).toLocaleString()}
- </Descriptions.Item>
- </Descriptions>
- )}
- </Modal>
- </div>
- );
-}
\ No newline at end of file
+export default function Page() {
+ return <AccountPageCore />;
+}
diff --git a/src/app/config/accountConfig.ts b/src/app/config/accountConfig.ts
new file mode 100644
index 00000000..4df47c6d
--- /dev/null
+++ b/src/app/config/accountConfig.ts
@@ -0,0 +1,15 @@
+// 账号状态
+export enum AccountStatus {
+ // 未失效
+ USABLE = 0,
+ // 失效
+ DISABLE = 1,
+}
+
+// 小红书账号异常状态
+export enum XhsAccountAbnormal {
+ // 账号正常
+ Normal = 1,
+ // 账号异常(无法发布视频)
+ Abnormal = 2,
+}
diff --git a/src/app/config/platConfig.ts b/src/app/config/platConfig.ts
new file mode 100644
index 00000000..395123b4
--- /dev/null
+++ b/src/app/config/platConfig.ts
@@ -0,0 +1,138 @@
+import { PubType } from "@/app/config/publishConfig";
+import ksSvg from "@/assets/svgs/plat/ks.svg";
+import xhsSvg from "@/assets/svgs/plat/xhs.svg";
+import douyinSvg from "@/assets/svgs/plat/douyin.svg";
+import wxSphSvg from "@/assets/svgs/plat/wx-sph.svg";
+
+// 平台类型
+export enum PlatType {
+ Douyin = "douyin", // 抖音
+ Xhs = "xhs", // 小红书
+ WxSph = "wxSph", // 微信视频号
+ KWAI = "KWAI", // 快手
+}
+
+export interface IAccountPlatInfo {
+ // 显示的icon
+ icon: string;
+ // 平台中文名称
+ name: string;
+ // 平台url
+ url: string;
+ // 支持的发布类型
+ pubTypes: Set<PubType>;
+ /**
+ * 通用发布参数配置,有两个地方用到
+ * 1. 在设置通用发布参数的时候会根据当前选择的账户中的最小参数为基准设置参数限制
+ * 2. 规定每个平台通用参数的限制
+ */
+ commonPubParamsConfig: {
+ // title限制字数,可以不填,不填表示该平台无标题参数
+ titleMax?: number;
+ // 定时发布,可以不填,不填表示该平台无定时发布参数
+ timingMax?: {
+ // 同 VideoPubSetModalCommon.maxDate
+ maxDate: number;
+ // 同 VideoPubSetModalCommon.timeOffset
+ timeOffset: number;
+ };
+ // 话题数量限制
+ topicMax: number;
+ // 仅图文发布的限制参数
+ imgTextConfig?: {
+ imagesMax: number;
+ };
+ };
+ // 平台提示
+ tips?: {
+ // 添加账号时候的提示
+ account: string;
+ // 在发布时添加账号时候的提示
+ publish: string;
+ };
+}
+
+const PubTypeAll = new Set([PubType.ARTICLE, PubType.VIDEO, PubType.ImageText]);
+// 各个平台的信息
+export const AccountPlatInfoMap = new Map<PlatType, IAccountPlatInfo>([
+ [
+ PlatType.KWAI,
+ {
+ name: "快手",
+ icon: ksSvg.src,
+ url: "https://cp.kuaishou.com/profile",
+ pubTypes: new Set([PubType.VIDEO]),
+ commonPubParamsConfig: {
+ timingMax: {
+ maxDate: 13,
+ timeOffset: 60,
+ },
+ topicMax: 4,
+ },
+ },
+ ],
+ [
+ PlatType.Xhs,
+ {
+ name: "小红书",
+ icon: xhsSvg.src,
+ url: "https://creator.xiaohongshu.com/login?source=official",
+ // url: 'https://www.xiaohongshu.com/explore',
+ pubTypes: PubTypeAll,
+ commonPubParamsConfig: {
+ timingMax: {
+ maxDate: 14,
+ timeOffset: 60,
+ },
+ topicMax: 20,
+ titleMax: 20,
+ imgTextConfig: {
+ imagesMax: 18,
+ },
+ },
+ },
+ ],
+ [
+ PlatType.Douyin,
+ {
+ name: "抖音",
+ icon: douyinSvg.src,
+ url: "https://creator.douyin.com/creator-micro/content/upload?enter_from=dou_web",
+ pubTypes: PubTypeAll,
+ commonPubParamsConfig: {
+ timingMax: {
+ maxDate: 14,
+ timeOffset: 120,
+ },
+ titleMax: 30,
+ topicMax: 5,
+ imgTextConfig: {
+ imagesMax: 35,
+ },
+ },
+ // tips: {
+ // account: '首次登录的抖音号可能会频繁掉线,通常将在重登2-3次后趋于稳定',
+ // publish:
+ // '首次登录的抖音账号请先在账户单独完成一次内容发布后再做一键发布',
+ // },
+ },
+ ],
+ [
+ PlatType.WxSph,
+ {
+ name: "微信视频号",
+ icon: wxSphSvg.src,
+ url: "https://channels.weixin.qq.com/cgi-bin/mmfinderassistant-bin/helper/hepler_merlin_mmdata?_rid=67b30b55-6e3ea588",
+ pubTypes: new Set([PubType.VIDEO]),
+ commonPubParamsConfig: {
+ timingMax: {
+ maxDate: 30,
+ timeOffset: 60,
+ },
+ titleMax: 16,
+ topicMax: 10,
+ },
+ },
+ ],
+]);
+export const AccountPlatInfoArr = Array.from(AccountPlatInfoMap);
diff --git a/src/app/config/publishConfig.ts b/src/app/config/publishConfig.ts
new file mode 100644
index 00000000..5b46a5fb
--- /dev/null
+++ b/src/app/config/publishConfig.ts
@@ -0,0 +1,24 @@
+// 发布类型
+export enum PubType {
+ VIDEO = "video", // 视频
+ ARTICLE = "article", // 文章
+ ImageText = "image-text", // 图文
+}
+
+// 可见性
+export enum VisibleTypeEnum {
+ // 所有人可见
+ Public = 1,
+ // 仅自己可见
+ Private = 2,
+ // 好友可见
+ Friend = 3,
+}
+
+export enum PubStatus {
+ UNPUBLISH = 0, // 未发布/草稿
+ RELEASED = 1, // 已发布
+ FAIL = 2, // 发布失败
+ PartSuccess = 3, // 部分成功
+ Audit = 4, // 审核中
+}
diff --git a/src/app/layout/LyaoutHeader.tsx b/src/app/layout/LyaoutHeader.tsx
index 6b606cdd..4746189b 100644
--- a/src/app/layout/LyaoutHeader.tsx
+++ b/src/app/layout/LyaoutHeader.tsx
@@ -78,8 +78,15 @@ const LyaoutHeader = memo(
useEffect(() => {
setTimeout(() => {
- document.body.style.paddingTop =
- layoutHeader.current!.offsetHeight + "px";
+ let layoutHeaderHegiht = "0px";
+ layoutHeaderHegiht = layoutHeader.current!.offsetHeight + "px";
+
+ document.body.style.paddingTop = layoutHeaderHegiht;
+
+ document.documentElement.style.setProperty(
+ `--layoutHeaderHegiht`,
+ layoutHeaderHegiht,
+ );
}, 2);
}, []);
diff --git a/src/app/layout/Providers.tsx b/src/app/layout/Providers.tsx
index 372beb88..a4b99437 100644
--- a/src/app/layout/Providers.tsx
+++ b/src/app/layout/Providers.tsx
@@ -9,6 +9,8 @@ import zh_CN from "antd/es/locale/zh_CN";
import en_US from "antd/es/locale/en_US";
import { fallbackLng } from "@/app/i18n/settings";
import useCssVariables from "@/app/hooks/useCssVariables";
+import { useAccountStore } from "@/store/account";
+import { useUserStore } from "@/store/user";
// antd 语言获取
const getAntdLang = (lang: string): Locale => {
@@ -30,6 +32,10 @@ export function Providers({
}) {
const cssVariables = useCssVariables();
+ if (useUserStore.getState().token) {
+ useAccountStore.getState().init();
+ }
+
return (
<GoogleOAuthProvider clientId="471394506793-t2g4mg90vr8qgpq5stbua0b22pofqrne.apps.googleusercontent.com">
<ConfigProvider
diff --git a/src/app/styles/mixin.scss b/src/app/styles/mixin.scss
index 689299ed..9ce4582f 100644
--- a/src/app/styles/mixin.scss
+++ b/src/app/styles/mixin.scss
@@ -27,6 +27,26 @@
}
}
+@mixin height_100vh() {
+ height: calc(100vh - var(--layoutHeaderHegiht));
+}
+
+// antd table 布局 100%
+@mixin table-flex-container-with-selectors() {
+ .ant-table-wrapper,
+ .ant-spin-nested-loading,
+ .ant-table,
+ .ant-table-container,
+ .ant-table-body,
+ .ant-spin-container {
+ display: flex;
+ flex-direction: column;
+ min-height: 0;
+ height: 100%;
+ max-height: none !important;
+ }
+}
+
// 溢出隐藏 @param $line 行数
@mixin omitText($line) {
display: -webkit-box;
diff --git a/src/assets/svgs/plat/douyin.svg b/src/assets/svgs/plat/douyin.svg
new file mode 100644
index 00000000..ae81b38a
--- /dev/null
+++ b/src/assets/svgs/plat/douyin.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><defs><style>.a{fill:#1b1e31;}.b{fill:#3fece0;}.c{fill:#fff;}.d{fill:#f12e62;}</style></defs><rect class="a" width="20" height="20" rx="4"/><g transform="translate(3.848 2.98)"><path class="b" d="M1063.114,549.871c.011-1.118,0-2.247.011-3.366h2.29a2.627,2.627,0,0,0,.053.586l-1.566.128.128,8.968a4.334,4.334,0,0,1-.457,1.576,2.733,2.733,0,0,1-1.8,1.033,1.657,1.657,0,0,1-.99-.245c-.256-.139-.394-.906-.469-1.108a1.877,1.877,0,0,0,1.917-.074,1.959,1.959,0,0,0,.906-1.63c-.022-1.96-.022-3.919-.022-5.868Zm3.771-.65a3.136,3.136,0,0,0,1.054.437,2.8,2.8,0,0,0,.66.075v.617C1067.939,550.2,1066.512,549.787,1066.885,549.222Z" transform="translate(-1056.957 -546.506)"/><path class="b" d="M1057.988,553.554a4.174,4.174,0,0,1,2.78-.586v.7a4.113,4.113,0,0,0-2.365.938,3.78,3.78,0,0,0-1.054,5.017c.16.288.468.725.393,1.044a4.129,4.129,0,0,1-1.193-1.31,4.258,4.258,0,0,1,.042-4.388A4.121,4.121,0,0,1,1057.988,553.554Z" transform="translate(-1055.963 -547.973)"/><path class="c" d="M1062.98,547.265h1.714a8.076,8.076,0,0,1,.394.917,3.963,3.963,0,0,0,.927,1.14.254.254,0,0,1,.075.074,3.234,3.234,0,0,0,1.714,1.022c.383.277.117,1.4.117,1.992a5.428,5.428,0,0,1-3.163-1.086c0,1.427,0,2.747.011,4.186,0,.191.011.373,0,.575a6.24,6.24,0,0,1-.724,2.3,4.388,4.388,0,0,1-1.193,1.353,3.818,3.818,0,0,1-2.173.746,4.89,4.89,0,0,1-1.182-.1,5.093,5.093,0,0,1-1.523-.98l-.032-.032a3.321,3.321,0,0,1-.575-.8,4.345,4.345,0,0,1,1.118-5.5,4.31,4.31,0,0,1,2.471-.863c.245.117.075,1.917.075,1.917a1.873,1.873,0,0,0-.97.011,1.818,1.818,0,0,0-.83.522,1.618,1.618,0,0,0-.416.511.973.973,0,0,0-.138.767,1.854,1.854,0,0,0,.351,1.033c.16.2.266.512.48.65a1.54,1.54,0,0,0,.639.6,1.984,1.984,0,0,0,1.1.224,1.851,1.851,0,0,0,1.448-.927,2.438,2.438,0,0,0,.277-1.15c0-3.142.011-9.107.011-9.107Z" transform="translate(-1056.162 -546.679)"/><path class="d" d="M1065.015,547.265c.2.011.393,0,.607,0a3.292,3.292,0,0,0,.6,1.875,1.444,1.444,0,0,0,.149.191,2.829,2.829,0,0,1-1.012-1.14,3.673,3.673,0,0,1-.34-.927Zm3.131,3.153a2.8,2.8,0,0,0,.661.075V552.8a5.4,5.4,0,0,1-3.184-1.033v4.59a4.211,4.211,0,0,1-.1,1.033,4.265,4.265,0,0,1-1.683,2.567,4.021,4.021,0,0,1-1.512.671,4.153,4.153,0,0,1-1.981-.033,4.209,4.209,0,0,1-2.023-1.214,4.019,4.019,0,0,0,1.533.66,4.892,4.892,0,0,0,1.183.1,3.819,3.819,0,0,0,2.173-.746,4.393,4.393,0,0,0,1.193-1.353,4.7,4.7,0,0,0,.617-1.98,5.2,5.2,0,0,0,0-.576c-.021-1.417-.021-2.843-.021-4.271a5.332,5.332,0,0,0,3.153,1c-.011-.6,0-1.2-.011-1.8Z" transform="translate(-1056.503 -546.679)"/><path class="d" d="M1061.456,553.671a4.569,4.569,0,0,1,.67.042v2.375a1.876,1.876,0,0,0-1-.042,1.963,1.963,0,0,0-1.139,3.035,2.147,2.147,0,0,1-1-1.5,1.9,1.9,0,0,1,.2-1.108,1.644,1.644,0,0,1,.416-.522,2.592,2.592,0,0,1,.969-.48,1.63,1.63,0,0,1,.873.022C1061.456,555.4,1061.456,553.9,1061.456,553.671Z" transform="translate(-1056.65 -548.143)"/></g></svg>
\ No newline at end of file
diff --git a/src/assets/svgs/plat/ks.svg b/src/assets/svgs/plat/ks.svg
new file mode 100644
index 00000000..2b30030e
--- /dev/null
+++ b/src/assets/svgs/plat/ks.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><defs><style>.a{fill:#ff5000;}.b,.c{fill:#fff;}.b{opacity:0;}</style></defs><g transform="translate(-886 -1347)"><rect class="a" width="20" height="20" rx="4" transform="translate(886 1347)"/><g transform="translate(887.902 1348.904)"><rect class="b" width="16" height="16" transform="translate(0.098 0.096)"/><path class="c" d="M6.828,15.486a2.7,2.7,0,0,1-2.566-1.859L1.9,14.813A1.309,1.309,0,0,1,0,13.641V9.8A1.311,1.311,0,0,1,1.9,8.626L4.256,9.818A2.7,2.7,0,0,1,6.828,7.941H10.8a2.7,2.7,0,0,1,2.7,2.7v2.144a2.7,2.7,0,0,1-2.7,2.7Zm.018-1.39H10.76a1.348,1.348,0,0,0,1.35-1.328V10.681a1.35,1.35,0,0,0-1.328-1.35H6.869a1.35,1.35,0,0,0-1.35,1.328v2.087A1.349,1.349,0,0,0,6.847,14.1ZM1.389,10.52v2.416a.373.373,0,0,0,.04.163.357.357,0,0,0,.475.158l.006,0,2.22-1.131v-.8L1.908,10.206a.382.382,0,0,0-.161-.037A.358.358,0,0,0,1.389,10.52Zm0-6.867A3.653,3.653,0,0,1,8.23,1.869a3.136,3.136,0,1,1-.4,4.148A3.653,3.653,0,0,1,1.389,3.653Zm1.469,0A2.184,2.184,0,1,0,5.042,1.47,2.183,2.183,0,0,0,2.858,3.653Zm5.836.515A1.668,1.668,0,1,0,10.363,2.5,1.668,1.668,0,0,0,8.695,4.169Z" transform="translate(1.348 0.177)"/></g></g></svg>
\ No newline at end of file
diff --git a/src/assets/svgs/plat/wx-sph.svg b/src/assets/svgs/plat/wx-sph.svg
new file mode 100644
index 00000000..bbd87add
--- /dev/null
+++ b/src/assets/svgs/plat/wx-sph.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><defs><style>.a{fill:#fa9a32;}.b{fill:#fff;}</style></defs><g transform="translate(-0.286)"><rect class="a" width="20" height="20" rx="4" transform="translate(0.286)"/><path class="b" d="M1065.375,228.99a1.658,1.658,0,0,1,.586.113,1.805,1.805,0,0,1,1.072,1.142,3.618,3.618,0,0,1,.228,1.557,24.782,24.782,0,0,1-.543,3.9,20.2,20.2,0,0,1-.857,3.385,4.361,4.361,0,0,1-.656,1.214,1.6,1.6,0,0,1-1.245.642,1.5,1.5,0,0,1-.641-.142c-.17-.087-.729-.33-1.829-2.129a17.589,17.589,0,0,1-1.042-1.929,17.355,17.355,0,0,1-1.042,1.929c-1.115,1.8-1.657,2.057-1.829,2.128a1.5,1.5,0,0,1-.643.143,1.6,1.6,0,0,1-1.243-.642,4.133,4.133,0,0,1-.656-1.216,20.13,20.13,0,0,1-.857-3.383,26.518,26.518,0,0,1-.543-3.9,4.412,4.412,0,0,1,.2-1.555,1.8,1.8,0,0,1,1.071-1.144,1.658,1.658,0,0,1,.586-.113,2.8,2.8,0,0,1,1.971,1.156,22.8,22.8,0,0,1,1.643,2.271l.424.63.433.627c.169.242.328.471.47.7.142-.23.3-.459.471-.7.043-.057.085-.128.129-.187q.386-.556.728-1.07a24.424,24.424,0,0,1,1.643-2.271A2.8,2.8,0,0,1,1065.375,228.99Zm-9.855,1.57a.05.05,0,0,0-.042.015c-.028.014-.085.028-.158.213a3.064,3.064,0,0,0-.114,1,24.278,24.278,0,0,0,.515,3.642,20.7,20.7,0,0,0,.684,2.842,2.848,2.848,0,0,0,.557,1.114,6.973,6.973,0,0,0,1.186-1.6,15.689,15.689,0,0,0,1.157-2.271,3.232,3.232,0,0,0-.157-.3,5.512,5.512,0,0,0-.428-.643,2.077,2.077,0,0,0-.129-.185c-.257-.372-.5-.744-.743-1.086a20.859,20.859,0,0,0-1.528-2.114C1055.791,230.589,1055.562,230.56,1055.52,230.56Zm9.887-.014c-.046,0-.275.028-.8.628a20.829,20.829,0,0,0-1.527,2.114c-.243.356-.486.714-.744,1.086l-.127.183a7.318,7.318,0,0,0-.414.615,1.525,1.525,0,0,0-.158.3,15.533,15.533,0,0,0,1.158,2.271,7.02,7.02,0,0,0,1.185,1.6,2.59,2.59,0,0,0,.557-1.114,21.382,21.382,0,0,0,.685-2.842,26.234,26.234,0,0,0,.514-3.642,2.728,2.728,0,0,0-.113-1c-.087-.157-.143-.171-.173-.185a.133.133,0,0,0-.038-.014Z" transform="translate(-1050.348 -224.99)"/></g></svg>
\ No newline at end of file
diff --git a/src/assets/svgs/plat/xhs.svg b/src/assets/svgs/plat/xhs.svg
new file mode 100644
index 00000000..0cee5d70
--- /dev/null
+++ b/src/assets/svgs/plat/xhs.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><defs><style>.a{fill:#ff2552;}.b{fill:none;}.c{fill:#fff;}</style></defs><g transform="translate(-1118.104 -1347.104)"><rect class="a" width="20" height="20" rx="4" transform="translate(1118.104 1347.104)"/><g transform="translate(1118.842 1347.842)"><rect class="b" width="18" height="18" transform="translate(0.262 0.262)"/><path class="c" d="M128.263,378.926a7.557,7.557,0,0,1-.132,2.374,1.542,1.542,0,0,1-.132.528s.2.4.659,1.121c.857-.724.792-4.022.792-4.022Zm5.276,2.44a9.917,9.917,0,0,1-.133-2.374H132.22s-.133,3.3.791,4.022a6.933,6.933,0,0,1,.659-1.121C133.6,381.761,133.6,381.564,133.539,381.366Zm-3.3,1.252h-.792l.4.924H130.9c.4,0,.528-.726.528-.726v-5.34h-1.187v5.143Zm5.34-1.517.99-1.978h-.99l.594-1.648h-1.121l-.859,2.176a.29.29,0,0,0,.263.4h.594l-.659,1.517a.29.29,0,0,0,.263.4h1.45l.33-.858h-.855Zm-1.384,1.385-.594,1.055h1.846l.462-1.055H134.2Zm4.747-3.495h.594v-1.187H136.9v1.122h.791v3.495h-1.055l-.528,1.121h3.824v-1.055h-.989Zm5.407,1.055h-.264v-1.055a1.056,1.056,0,0,0-1.054-1.121h-.792v-.528h-1.121v.528h-.791v1.054h.792v1.055H140v1.055h1.121v2.5h1.121V381.1h2.111v1.583h-1.121l.4.923h.923a.874.874,0,0,0,.856-.857v-1.582A.989.989,0,0,0,144.352,380.048Zm-1.319,0h-.792v-1.122h.792Zm2.439-1.648a.528.528,0,0,0-1.055,0v.527h.528A.567.567,0,0,0,145.473,378.4Z" transform="translate(-127.475 -371.26)"/></g></g></svg>
\ No newline at end of file
diff --git a/src/components/AvatarPlat/avatarPlat.module.scss b/src/components/AvatarPlat/avatarPlat.module.scss
new file mode 100644
index 00000000..e81f61d7
--- /dev/null
+++ b/src/components/AvatarPlat/avatarPlat.module.scss
@@ -0,0 +1,12 @@
+.avatarPlat {
+ position: relative;
+ display: flex;
+ justify-content: center;
+ & > img {
+ position: absolute;
+ bottom: 0;
+ right: 0;
+ transform: translate(-10%, 20%);
+ border-radius: 50%;
+ }
+}
\ No newline at end of file
diff --git a/src/components/AvatarPlat/index.tsx b/src/components/AvatarPlat/index.tsx
new file mode 100644
index 00000000..6ed096e3
--- /dev/null
+++ b/src/components/AvatarPlat/index.tsx
@@ -0,0 +1,39 @@
+import { ForwardedRef, forwardRef, memo } from "react";
+import styles from "./avatarPlat.module.scss";
+import { AvatarSize } from "antd/es/avatar/AvatarContext";
+import { SocialAccount } from "@/api/types/account.type";
+import { Avatar } from "antd";
+import { AccountPlatInfoMap } from "@/app/config/platConfig";
+
+export interface IAvatarPlatRef {}
+
+export interface IAvatarPlatProps {
+ account: SocialAccount;
+ size?: AvatarSize;
+}
+
+const AvatarPlat = memo(
+ forwardRef(
+ (
+ { account, size = "default" }: IAvatarPlatProps,
+ ref: ForwardedRef<IAvatarPlatRef>,
+ ) => {
+ const plat = AccountPlatInfoMap.get(account.type)!;
+ return (
+ <>
+ <div className={styles.avatarPlat}>
+ <Avatar src={account.avatar} size={size} />
+ <img
+ src={plat.icon}
+ style={{
+ width: size === "large" ? 15 : size === "default" ? 12.5 : 10,
+ }}
+ />
+ </div>
+ </>
+ );
+ },
+ ),
+);
+
+export default AvatarPlat;
diff --git a/src/store/account.ts b/src/store/account.ts
new file mode 100644
index 00000000..ec7af6ca
--- /dev/null
+++ b/src/store/account.ts
@@ -0,0 +1,113 @@
+import { create } from "zustand";
+import { combine } from "zustand/middleware";
+import lodash from "lodash";
+import { AccountGroupItem, SocialAccount } from "@/api/types/account.type";
+import { getAccountGroupApi, getAccountListApi } from "@/api/account";
+
+export interface AccountGroup extends AccountGroupItem {
+ children: SocialAccount[];
+}
+
+export interface IAccountStore {
+ accountList: SocialAccount[];
+ accountMap: Map<number, SocialAccount>;
+ accountGroupList: AccountGroup[];
+ accountGroupMap: Map<number, AccountGroup>;
+ accountLoading: boolean;
+}
+
+const store: IAccountStore = {
+ // 不分组的账户数据
+ accountList: [],
+ // 分组的账户数据
+ accountGroupList: [],
+ accountGroupMap: new Map([]),
+ accountMap: new Map([]),
+ accountLoading: false,
+};
+
+const getStore = () => {
+ return lodash.cloneDeep(store);
+};
+
+// 视频发布所有组件的共享状态和方法
+export const useAccountStore = create(
+ combine(
+ {
+ ...getStore(),
+ },
+ (set, get, storeApi) => {
+ const methods = {
+ clear() {
+ set({
+ ...getStore(),
+ });
+ },
+
+ setAccountGroupList(accountGroupList: AccountGroup[]) {
+ set({ accountGroupList });
+ },
+
+ async getAccountList() {
+ if (get().accountLoading) return;
+ set({ accountLoading: true });
+
+ const accountMap = new Map<number, SocialAccount>([]);
+ const result = await getAccountListApi();
+
+ if (result?.code !== 0) return;
+
+ for (const item of result.data) {
+ accountMap.set(item.id, item);
+ }
+
+ set({
+ accountList: result.data,
+ accountMap,
+ });
+ await methods.getAccountGroup();
+
+ set({ accountLoading: false });
+ },
+
+ // 获取用户组的数据并且将用户放到对应组下
+ async getAccountGroup() {
+ const res = await getAccountGroupApi();
+ const groupList = res?.data;
+ if (!groupList) return;
+
+ if (groupList.length === 0) return;
+ const accountGroupList: AccountGroup[] = [];
+ // key=组ID,val=账户ID
+ const accountGroupMap = new Map<number, AccountGroup>();
+ groupList.map((v) => {
+ const accountGroupItem = {
+ ...v,
+ children: [],
+ };
+ accountGroupList.push(accountGroupItem);
+ accountGroupMap.set(v.id, accountGroupItem);
+ });
+ get().accountList.map((v) => {
+ accountGroupMap.get(v.groupId!)!.children?.push(v);
+ });
+
+ accountGroupList.sort((a, b) => {
+ return a.rank - b.rank;
+ });
+
+ set({
+ accountGroupList,
+ accountGroupMap,
+ });
+ },
+
+ async init() {
+ if (get().accountList.length > 0) return;
+ await methods.getAccountList();
+ },
+ };
+ return methods;
+ },
+ ),
+);
diff --git a/src/store/user.ts b/src/store/user.ts
index 6032aae2..5151efed 100644
--- a/src/store/user.ts
+++ b/src/store/user.ts
@@ -43,6 +43,7 @@ export const useUserStore = createPersistStore(
// 登出
logout() {
methods.clearLoginStatus();
+ window.location.href = "/login";
},
};
diff --git a/src/utils/request.ts b/src/utils/request.ts
index 37bbaeaf..c59ef356 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -33,8 +33,13 @@ export async function request<T>(params: RequestParams) {
const res = await fetchService.request(params);
const data: ResponseType<T> = await res.json();
- if (data.code === "Unauthorized") {
- useUserStore.getState().clearLoginStatus();
+ // @ts-ignore
+ if (data.code === "1" && data.data.statusCode === 401) {
+ useUserStore.getState().logout();
+ message.error({
+ key: "NoPermission",
+ content: "登录状态过期,请重新登录",
+ });
return null;
}
diff --git a/src/var.css b/src/var.css
index c410e2bd..cec4e5ca 100644
--- a/src/var.css
+++ b/src/var.css
@@ -18,6 +18,9 @@
--grayColor13: #242424;
--grayColor14: #181818;
+ /* 头部高度 */
+ --layoutHeaderHegiht: 1px;
+
/* 超大号字 */
--fs-xl: 20px;
/* 大号字 */
@@ -50,6 +53,15 @@
--primary-color: var(--theColor5);
/* 原先为:#D7B4F5 */
--primary-hover: var(--theColor6);
+ --colorPrimary1: var(--theColor1);
+ --colorPrimary2: var(--theColor2);
+ --colorPrimary3: var(--theColor3);
+ --colorPrimary4: var(--theColor4);
+ --colorPrimary5: var(--theColor5);
+ --colorPrimary6: var(--theColor6);
+ --colorPrimary7: var(--theColor7);
+ --colorPrimary8: var(--theColor8);
+ --colorPrimary9: var(--theColor9);
/* 其它颜色 */
--text-color: #1f2937;