Skip to content

Let's use AI to Earn!

ke

I5bijibne191f8814e2f6
diff --git a/src/app/[lng]/accounts/components/AccountSidebar/AccountSidebar.tsx b/src/app/[lng]/accounts/components/AccountSidebar/AccountSidebar.tsx
index ec192484..c646d8c9 100644
--- a/src/app/[lng]/accounts/components/AccountSidebar/AccountSidebar.tsx
+++ b/src/app/[lng]/accounts/components/AccountSidebar/AccountSidebar.tsx
@@ -10,7 +10,6 @@ import {
import styles from "./AccountSidebar.module.scss";
import { Avatar, Button, Collapse, Popover, Skeleton, Tooltip } from "antd";
// import { accountLogin, acpAccountLoginCheck } from "@/icp/account";
-import AddAccountModal from "../AddAccountModal";
import {
CheckCircleOutlined,
PlusOutlined,
@@ -135,7 +134,6 @@ const AccountSidebar = memo(
ref: ForwardedRef<IAccountSidebarRef>,
) => {
const { t } = useTransClient("account");
- const [isAccountModalOpen, setIsAccountModalOpen] = useState(false);
const pubAccountDetModuleRef = useRef<any>(null);
const {
accountList: fullAccountList,
@@ -186,11 +184,7 @@ const AccountSidebar = memo(
{/* 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">
@@ -202,16 +196,7 @@ const AccountSidebar = memo(
<UserOutlined />
{t("accountManager")}
</Button>
- <Tooltip title={t("addAccount")}>
- <Button
- type="primary"
- className="accountSidebar-top-addUser"
- icon={<PlusOutlined />}
- onClick={() => {
- setIsAccountModalOpen(true);
- }}
- ></Button>
- </Tooltip>
+
</div>
{/* mcp 按钮 */}
<div className="accountSidebar-top-box">
diff --git a/src/app/[lng]/accounts/components/AccountSidebar/UserManageModal.tsx b/src/app/[lng]/accounts/components/AccountSidebar/UserManageModal.tsx
index fced6c1f..de89380c 100644
--- a/src/app/[lng]/accounts/components/AccountSidebar/UserManageModal.tsx
+++ b/src/app/[lng]/accounts/components/AccountSidebar/UserManageModal.tsx
@@ -33,6 +33,7 @@ import { AccountStatus } from "@/app/config/accountConfig";
import AvatarPlat from "@/components/AvatarPlat";
import { deleteAccountsApi, updateAccountApi } from "@/api/account";
import { useTransClient } from "@/app/i18n/client";
+import AddAccountModal from "../AddAccountModal";
export interface IUserManageModalRef {
setActiveGroup: (groupId: string) => void;
@@ -97,6 +98,11 @@ const UserManageModal = memo(
const isUpdateRank = useRef(false);
const [deleteLoading, setDeleteLoading] = useState(false);
const [cutLoading, setCutLoading] = useState(false);
+ const [isAddAccountOpen, setIsAddAccountOpen] = useState(false);
+ const [chooseGroupOpen, setChooseGroupOpen] = useState(false);
+ const [chosenGroupId, setChosenGroupId] = useState<string | undefined>(undefined);
+ const preAccountIds = useRef<Set<string>>(new Set());
+ const pendingGroupIdRef = useRef<string | null>(null);
const columns = useMemo(() => {
const columns: TableProps<SocialAccount>["columns"] = [
@@ -245,6 +251,48 @@ const UserManageModal = memo(
};
useImperativeHandle(ref, () => imperativeHandle);
+ const openAddAccountFlow = () => {
+ const currentGroupId = activeGroup;
+ close();
+ if (currentGroupId === allUser.current) {
+ setChosenGroupId(accountGroupList[0]?.id);
+ setChooseGroupOpen(true);
+ } else {
+ pendingGroupIdRef.current = currentGroupId;
+ preAccountIds.current = new Set(
+ (useAccountStore.getState().accountList || []).map((v) => v.id),
+ );
+ setIsAddAccountOpen(true);
+ }
+ };
+
+ const assignNewAccountsToGroup = async () => {
+ if (!pendingGroupIdRef.current) return;
+ const targetGroupId = pendingGroupIdRef.current;
+ for (let i = 0; i < 8; i++) {
+ await getAccountList();
+ const currList = useAccountStore.getState().accountList || [];
+ const newAccounts = currList.filter((a) => !preAccountIds.current.has(a.id));
+ if (newAccounts.length > 0) {
+ for (const acc of newAccounts) {
+ try {
+ await updateAccountApi({ id: acc.id, groupId: targetGroupId });
+ } catch (e) {
+ // ignore
+ }
+ }
+ await getAccountList();
+ message.success(t("accountAddedToSpace" as any));
+ pendingGroupIdRef.current = null;
+ preAccountIds.current = new Set();
+ return;
+ }
+ await new Promise((r) => setTimeout(r, 1500));
+ }
+ message.warning(t("noNewAccountDetected" as any));
+ pendingGroupIdRef.current = null;
+ };
+
return (
<>
<Modal
@@ -298,7 +346,7 @@ const UserManageModal = memo(
<Modal
open={open}
- title="账号管理器"
+ title={t("accountManager")}
zIndex={1001}
footer={null}
width={1000}
@@ -317,9 +365,9 @@ const UserManageModal = memo(
/>
<div className="userManage-content">
- {/*<div className="userManage-content-head">*/}
- {/* <div></div>*/}
- {/*</div>*/}
+ <div className="userManage-content-head" style={{ marginBottom: "8px", display: "flex", justifyContent: "flex-end" }}>
+ <Button type="primary" onClick={openAddAccountFlow}>{t("addAccount")}</Button>
+ </div>
<Table<SocialAccount>
columns={columns}
dataSource={accountListLast}
@@ -366,6 +414,48 @@ const UserManageModal = memo(
</div>
</Spin>
</Modal>
+ <Modal
+ open={chooseGroupOpen}
+ title={t("chooseSpace" as any)}
+ onCancel={() => setChooseGroupOpen(false)}
+ onOk={() => {
+ if (!chosenGroupId) return message.warning(t("pleaseChooseSpace" as any));
+ pendingGroupIdRef.current = chosenGroupId;
+ preAccountIds.current = new Set(
+ (useAccountStore.getState().accountList || []).map((v) => v.id),
+ );
+ setChooseGroupOpen(false);
+ setIsAddAccountOpen(true);
+ }}
+ width={420}
+ >
+ <Select
+ style={{ width: "100%" }}
+ placeholder={t("pleaseChooseSpace" as any)}
+ value={chosenGroupId}
+ onChange={setChosenGroupId}
+ options={accountGroupList.map((g) => ({ value: g.id, label: g.name }))}
+ />
+ </Modal>
+
+ <AddAccountModal
+ open={isAddAccountOpen}
+ onClose={async () => {
+ setIsAddAccountOpen(false);
+ await assignNewAccountsToGroup();
+ }}
+ onAddSuccess={async (acc) => {
+ try {
+ if (pendingGroupIdRef.current) {
+ await updateAccountApi({ id: acc.id, groupId: pendingGroupIdRef.current });
+ message.success(t("accountAddedToSpace" as any));
+ }
+ } finally {
+ pendingGroupIdRef.current = null;
+ await getAccountList();
+ }
+ }}
+ />
</>
);
},
diff --git a/src/app/[lng]/vip/page.tsx b/src/app/[lng]/vip/page.tsx
index bb81cff2..a6dca99c 100644
--- a/src/app/[lng]/vip/page.tsx
+++ b/src/app/[lng]/vip/page.tsx
@@ -202,7 +202,7 @@ export default function VipPage() {
onClick={handleActivate}
disabled={loading}
>
- {loading ? t('createPaymentOrderFailed') : t('activateNow')}
+ {t('activateNow')}
</button>
</div>
);
diff --git a/src/app/i18n/locales/en/account.json b/src/app/i18n/locales/en/account.json
index b99af09c..798e71be 100644
--- a/src/app/i18n/locales/en/account.json
+++ b/src/app/i18n/locales/en/account.json
@@ -44,5 +44,9 @@
"recordCount": "{{count}} plans total",
"newWork": "New Work",
"noRecords": "No publish plans"
- }
+ },
+ "chooseSpace": "Choose Space",
+ "pleaseChooseSpace": "Please choose a space",
+ "accountAddedToSpace": "Account has been added to the space",
+ "noNewAccountDetected": "No new account detected; you can adjust the space later in Account Manager"
}
\ No newline at end of file
diff --git a/src/app/i18n/locales/zh-CN/account.json b/src/app/i18n/locales/zh-CN/account.json
index f127f58a..83742caa 100644
--- a/src/app/i18n/locales/zh-CN/account.json
+++ b/src/app/i18n/locales/zh-CN/account.json
@@ -44,5 +44,9 @@
"recordCount": "共 {{count}} 条发布计划",
"newWork": "新建作品",
"noRecords": "暂无发布计划"
- }
+ },
+ "chooseSpace": "选择空间",
+ "pleaseChooseSpace": "请选择空间",
+ "accountAddedToSpace": "账号已添加到空间",
+ "noNewAccountDetected": "未检测到新账号,稍后可在账号管理器中手动调整空间"
}
\ No newline at end of file