Skip to content

Let's use AI to Earn!

fix: 将账户和账户组的数值类型改为字符串类型

gaoSir0a071121ef5a
diff --git a/src/api/account.ts b/src/api/account.ts
index 3821c141..4335dc6b 100644
--- a/src/api/account.ts
+++ b/src/api/account.ts
@@ -17,7 +17,7 @@ export const updateAccountApi = (data: Partial<SocialAccount>) => {
// 更新账户状态
export const updateAccountStatusApi = (data: {
- id: number;
+ id: string;
status: number;
}) => {
return sxRequest.post<SocialAccount>("account/status", data);
@@ -29,7 +29,7 @@ export const getAccountListApi = () => {
};
// 获取账户详情
-export const getAccountDetailApi = (id: number) => {
+export const getAccountDetailApi = (id: string) => {
return sxRequest.get<SocialAccount>(`account/${id}`);
};
@@ -40,12 +40,12 @@ export const updateAccountStatisticsApi = (
};
// 删除账户
-export const deleteAccountApi = (id: number) => {
+export const deleteAccountApi = (id: string) => {
return sxRequest.post<SocialAccount>(`account/delete/${id}`);
};
// 删除多个账户
-export const deleteAccountsApi = (ids: number[]) => {
+export const deleteAccountsApi = (ids: string[]) => {
return sxRequest.post<SocialAccount>("account/deletes", {
ids,
});
@@ -62,7 +62,7 @@ export const updateAccountGroupApi = (data: Partial<AccountGroupItem>) => {
};
// 删除账户组
-export const deleteAccountGroupApi = (ids: number[]) => {
+export const deleteAccountGroupApi = (ids: string[]) => {
return sxRequest.post("accountGroup/deletes", {
ids,
});
diff --git a/src/api/types/account.type.ts b/src/api/types/account.type.ts
index 4e1fc297..838f39d7 100644
--- a/src/api/types/account.type.ts
+++ b/src/api/types/account.type.ts
@@ -2,7 +2,7 @@ import { PlatType } from "@/app/config/platConfig";
// 三方账户类型定义
export interface SocialAccount {
- id: number;
+ id: string;
type: PlatType;
loginCookie?: string;
access_token?: string;
@@ -25,7 +25,7 @@ export interface SocialAccount {
createTime: string;
updateTime: string;
rank: number;
- groupId: number;
+ groupId: string;
}
// 更新账户统计数据
@@ -42,7 +42,7 @@ export interface UpdateAccountStatisticsParams {
// 账户组 item 数据
export interface AccountGroupItem {
- id: number;
+ id: string;
name: string;
rank: number;
isDefault: boolean;
diff --git a/src/app/[lng]/accounts/accountCore.tsx b/src/app/[lng]/accounts/accountCore.tsx
index e32e48c4..ba353411 100644
--- a/src/app/[lng]/accounts/accountCore.tsx
+++ b/src/app/[lng]/accounts/accountCore.tsx
@@ -13,7 +13,7 @@ export default function AccountPageCore() {
accountInit: state.accountInit,
})),
);
- const [activeAccountId, setActiveAccountId] = useState(-1);
+ const [activeAccountId, setActiveAccountId] = useState("");
useEffect(() => {
accountInit();
@@ -24,8 +24,9 @@ export default function AccountPageCore() {
<div className={styles.accounts}>
<AccountSidebar
activeAccountId={activeAccountId}
- onAccountChange={() => {
- console.log("change");
+ onAccountChange={(account) => {
+ console.log("change", account);
+ setActiveAccountId(account.id);
}}
/>
</div>
diff --git a/src/app/[lng]/accounts/add/page.tsx b/src/app/[lng]/accounts/add/page.tsx
index b5e74159..49c5b7e1 100644
--- a/src/app/[lng]/accounts/add/page.tsx
+++ b/src/app/[lng]/accounts/add/page.tsx
@@ -6,7 +6,7 @@ import { useRouter, useSearchParams } from "next/navigation";
import { PlatType } from "@/app/config/platConfig";
import { kwaiLogin } from "@/app/[lng]/accounts/plat/kwaiLogin";
import { Spin } from "antd";
-import {CheckCircleOutlined, CloseCircleOutlined} from "@ant-design/icons";
+import { CheckCircleOutlined, CloseCircleOutlined } from "@ant-design/icons";
enum LoginStatusEnum {
// 加载中
diff --git a/src/app/[lng]/accounts/components/AccountSidebar/AccountSidebar.tsx b/src/app/[lng]/accounts/components/AccountSidebar/AccountSidebar.tsx
index 33940763..dc5ab0aa 100644
--- a/src/app/[lng]/accounts/components/AccountSidebar/AccountSidebar.tsx
+++ b/src/app/[lng]/accounts/components/AccountSidebar/AccountSidebar.tsx
@@ -27,7 +27,7 @@ export interface IAccountSidebarRef {}
export interface IAccountSidebarProps {
// 选择的账户id
- activeAccountId: number;
+ activeAccountId: string;
// 切换选择的账户
onAccountChange: (info: SocialAccount) => void;
// 排除的平台类型
diff --git a/src/app/[lng]/accounts/components/AccountSidebar/UserManageModal.tsx b/src/app/[lng]/accounts/components/AccountSidebar/UserManageModal.tsx
index b3721336..e98e17e8 100644
--- a/src/app/[lng]/accounts/components/AccountSidebar/UserManageModal.tsx
+++ b/src/app/[lng]/accounts/components/AccountSidebar/UserManageModal.tsx
@@ -35,7 +35,7 @@ import AvatarPlat from "@/components/AvatarPlat";
import { deleteAccountsApi, updateAccountApi } from "@/api/account";
export interface IUserManageModalRef {
- setActiveGroup: (groupId: number) => void;
+ setActiveGroup: (groupId: string) => void;
}
export interface IUserManageModalProps {
@@ -48,7 +48,7 @@ const UserGroupSelect = ({
onChange,
}: {
account: SocialAccount;
- onChange: (groupId: number) => void;
+ onChange: (groupId: string) => void;
}) => {
const { accountGroupList } = useAccountStore(
useShallow((state) => ({
@@ -58,6 +58,7 @@ const UserGroupSelect = ({
return (
<Select
+ // @ts-ignore
value={account.groupId}
style={{ width: "160px" }}
fieldNames={{
@@ -88,7 +89,7 @@ const UserManageModal = memo(
const [deleteHitOpen, setDeleteHitOpen] = useState(false);
const [selectedRows, setSelectedRows] = useState<SocialAccount[]>([]);
// 全部账号
- const allUser = useRef(-1);
+ const allUser = useRef("-1");
// -1=全部账号,不然为对应分组 ID
const [activeGroup, setActiveGroup] = useState(allUser.current);
// 是否改变了顺序
diff --git a/src/app/[lng]/accounts/components/AccountSidebar/UserManageSidebar.tsx b/src/app/[lng]/accounts/components/AccountSidebar/UserManageSidebar.tsx
index 18359ffc..299acc97 100644
--- a/src/app/[lng]/accounts/components/AccountSidebar/UserManageSidebar.tsx
+++ b/src/app/[lng]/accounts/components/AccountSidebar/UserManageSidebar.tsx
@@ -21,9 +21,9 @@ import { AccountGroupItem } from "@/api/types/account.type";
export interface IUserManageSidebarRef {}
export interface IUserManageSidebarProps {
- activeGroup: number;
- allUser: number;
- onChange: (id: number) => void;
+ activeGroup: string;
+ allUser: string;
+ onChange: (id: string) => void;
onSortEnd: () => void;
}
@@ -56,7 +56,7 @@ const UserManageSidebar = memo(
const [groupName, setGroupName] = useState("");
const [createGroupLoading, setCreateGroupLoading] = useState(false);
// -1=新建 不然为重命名,值为要重命名的id
- const [createGroupId, setCreateGroupId] = useState(0);
+ const [createGroupId, setCreateGroupId] = useState("-1");
const srcollEl = useRef<HTMLElement>(undefined);
const [isOpen, setOpen] = useState(false);
const [anchorPoint, setAnchorPoint] = useState({ x: 0, y: 0 });
@@ -129,7 +129,7 @@ const UserManageSidebar = memo(
</ControlledMenu>
<Modal
- title={createGroupId === -1 ? "新建列表" : "重命名列表"}
+ title={createGroupId === "-1" ? "新建列表" : "重命名列表"}
open={openCreateGroup}
onCancel={createGroupCancel}
footer={
@@ -140,7 +140,7 @@ const UserManageSidebar = memo(
disabled={groupName.length === 0}
onClick={async () => {
setCreateGroupLoading(true);
- if (createGroupId === -1) {
+ if (createGroupId === "-1") {
await createAccountGroupApi({
name: groupName,
});
@@ -248,7 +248,7 @@ const UserManageSidebar = memo(
type="primary"
icon={<PlusOutlined />}
onClick={() => {
- setCreateGroupId(-1);
+ setCreateGroupId("-1");
setOpenCreateGroup(true);
}}
>
diff --git a/src/app/[lng]/publish/videoPage/page.tsx b/src/app/[lng]/publish/videoPage/page.tsx
index 203e5251..26625e65 100644
--- a/src/app/[lng]/publish/videoPage/page.tsx
+++ b/src/app/[lng]/publish/videoPage/page.tsx
@@ -56,7 +56,7 @@ export default function Page() {
useEffect(() => {
return () => {
- // clear();
+ clear();
};
}, []);
diff --git a/src/store/account.ts b/src/store/account.ts
index 228c27f1..e55fca93 100644
--- a/src/store/account.ts
+++ b/src/store/account.ts
@@ -10,9 +10,9 @@ export interface AccountGroup extends AccountGroupItem {
export interface IAccountStore {
accountList: SocialAccount[];
- accountMap: Map<number, SocialAccount>;
+ accountMap: Map<string, SocialAccount>;
accountGroupList: AccountGroup[];
- accountGroupMap: Map<number, AccountGroup>;
+ accountGroupMap: Map<string, AccountGroup>;
accountLoading: boolean;
}
@@ -52,7 +52,7 @@ export const useAccountStore = create(
if (get().accountLoading) return;
set({ accountLoading: true });
- const accountMap = new Map<number, SocialAccount>([]);
+ const accountMap = new Map<string, SocialAccount>([]);
const result = await getAccountListApi();
if (result?.code !== 0) return;
@@ -79,7 +79,7 @@ export const useAccountStore = create(
if (groupList.length === 0) return;
const accountGroupList: AccountGroup[] = [];
// key=组ID,val=账户ID
- const accountGroupMap = new Map<number, AccountGroup>();
+ const accountGroupMap = new Map<string, AccountGroup>();
const defaultGroup = groupList.find((v) => v.isDefault)!;