Skip to content

Let's use AI to Earn!

feat: 账户组处理账户和组ID对应不上的问题

gaoSir7cc005217175
diff --git a/src/store/account.ts b/src/store/account.ts
index 925f2e17..e222f7ec 100644
--- a/src/store/account.ts
+++ b/src/store/account.ts
@@ -1,7 +1,11 @@
import { create } from "zustand";
import { combine } from "zustand/middleware";
import lodash from "lodash";
-import { AccountGroupItem, SocialAccount } from "@/api/types/account.type";
+import {
+ AccountGroupDefaultType,
+ AccountGroupItem,
+ SocialAccount,
+} from "@/api/types/account.type";
import { getAccountGroupApi, getAccountListApi } from "@/api/account";
export interface AccountGroup extends AccountGroupItem {
@@ -74,12 +78,17 @@ export const useAccountStore = create(
async getAccountGroup() {
const res = await getAccountGroupApi();
const groupList = res?.data;
- if (!groupList) return;
+ if (!groupList) return;
if (groupList.length === 0) return;
const accountGroupList: AccountGroup[] = [];
// key=组ID,val=账户ID
const accountGroupMap = new Map<number, AccountGroup>();
+
+ const defaultGroup = groupList.find(
+ (v) => v.isDefault === AccountGroupDefaultType.Default,
+ )!;
+
groupList.map((v) => {
const accountGroupItem = {
...v,
@@ -89,7 +98,10 @@ export const useAccountStore = create(
accountGroupMap.set(v.id, accountGroupItem);
});
get().accountList.map((v) => {
- accountGroupMap.get(v.groupId!)!.children?.push(v);
+ (
+ accountGroupMap.get(v.groupId!) ||
+ accountGroupMap.get(defaultGroup.id)!
+ ).children?.push(v);
});
accountGroupList.sort((a, b) => {
diff --git a/src/utils/FetchService/FetchService.ts b/src/utils/FetchService/FetchService.ts
index a2925919..ee5877ff 100644
--- a/src/utils/FetchService/FetchService.ts
+++ b/src/utils/FetchService/FetchService.ts
@@ -31,8 +31,6 @@ class FetchService<T = Response> {
}
public async request(requestParams: RequestParams): Promise<T> {
- console.log(requestParams);
-
return new Promise(async (resolve, reject) => {
// 请求拦截
if (this.requestInterceptor) {