fix(web): code review pass — scroll watch, SSE same-origin, store concurrency, modal reset, admin validation

This commit is contained in:
2026-05-04 20:58:48 +08:00
parent ff283013da
commit b8d29d8ea7
11 changed files with 145 additions and 85 deletions
+1 -11
View File
@@ -1,4 +1,4 @@
import { request } from './client'
import { buildQuery, request } from './client'
export type MessageRole = 'user' | 'assistant'
export type MessageStatus = 'pending' | 'ok' | 'error' | 'cancelled'
@@ -95,16 +95,6 @@ export interface UsageDailyItem {
const enc = (v: string) => encodeURIComponent(v)
function buildQuery(params: object): string {
const q = new URLSearchParams()
for (const [k, v] of Object.entries(params)) {
if (v === undefined || v === null || v === '') continue
q.set(k, String(v))
}
const s = q.toString()
return s ? '?' + s : ''
}
export const chatApi = {
// ===== Conversations =====
listConversations: (params: ListConversationsParams = {}) =>
+12
View File
@@ -75,3 +75,15 @@ export async function request<T>(path: string, opts: RequestOptions = {}): Promi
clearTimeout(timer)
}
}
// buildQuery 把任意对象拼成 "?k=v&..." 形式;undefined / null / '' 跳过;
// 数组与对象用 String() 退化(业务侧目前没有数组 query 需求)。
export function buildQuery(params: object): string {
const q = new URLSearchParams()
for (const [k, v] of Object.entries(params)) {
if (v === undefined || v === null || v === '') continue
q.set(k, String(v))
}
const s = q.toString()
return s ? '?' + s : ''
}
+1 -11
View File
@@ -1,4 +1,4 @@
import { request } from './client'
import { buildQuery, request } from './client'
export type LLMProvider = 'anthropic' | 'openai' | 'gemini'
@@ -79,16 +79,6 @@ export interface AdminUsageItem {
const enc = (v: string) => encodeURIComponent(v)
function buildQuery(params: object): string {
const q = new URLSearchParams()
for (const [k, v] of Object.entries(params)) {
if (v === undefined || v === null || v === '') continue
q.set(k, String(v))
}
const s = q.toString()
return s ? '?' + s : ''
}
export const llmAdminApi = {
// ===== Endpoints =====
listEndpoints: () =>