feat: add Kefu widget and related components for customer service integration

This commit is contained in:
mlogclub
2026-04-24 19:17:07 +08:00
parent 4bcfd36620
commit 92fd571f28
11 changed files with 839 additions and 54 deletions
+5 -2
View File
@@ -13,6 +13,7 @@ type JsonResult<T> = {
type RequestOptions = RequestInit & {
skipAuth?: boolean
retryOnAuthError?: boolean
baseUrl?: string
}
async function parseResult<T>(response: Response) {
@@ -57,8 +58,9 @@ export async function request<T>(
options: RequestOptions = {},
retryOnAuthError = true
): Promise<T> {
const { headers, skipAuth, ...rest } = options
const { headers, skipAuth, baseUrl, ...rest } = options
delete (rest as RequestOptions).retryOnAuthError
delete (rest as RequestOptions).baseUrl
const session = readSession()
const authHeaders = new Headers(headers)
@@ -73,7 +75,8 @@ export async function request<T>(
authHeaders.set("Content-Type", "application/json")
}
const response = await fetch(`${API_BASE_URL}${path}`, {
const requestBaseUrl = baseUrl !== undefined ? baseUrl : API_BASE_URL
const response = await fetch(`${requestBaseUrl}${path}`, {
...rest,
headers: authHeaders,
cache: "no-store",