feat(client): 添加对groupId的处理

This commit is contained in:
dayjoy
2025-09-11 10:59:02 +08:00
parent 01294f58b1
commit 80ee3ca5a5
3 changed files with 44 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import { getAuthToken } from '../utils/auth';
import {getAuthToken, getGroupId} from '../utils/auth';
interface RequestOptions extends RequestInit {
headers?: Record<string, string>;
@@ -13,6 +13,7 @@ export const apiRequest = async <T = any>(
options: RequestOptions = {}
): Promise<T> => {
const authToken = getAuthToken();
const groupId = getGroupId();
const url = endpoint;
@@ -27,6 +28,11 @@ export const apiRequest = async <T = any>(
headers.authorization = `Bearer ${authToken}`;
}
// 如果有groupId添加groupId头
if (groupId) {
headers.groupId = groupId;
}
// 发起请求
const response = await fetch(url, {
...options,