refactor(webui): extract ApiClient + lift OneBotInstance config editor
App.tsx was the single source of truth for token, fetch policy, 401 handling, and per-UIN config edit state — fetchApi was drilled into every page and LogsPage read localStorage directly to build its SSE URL, giving two parallel truths for the bearer token. Promote the closure to a deep ApiClient module (domain methods + request() escape hatch) injected via ApiProvider/useApi, and lift selectedUin/config/saveStatus into useOneBotInstanceConfig so ConfigPage is self-contained. normalizeOneBotConfig becomes a pure function. ConfigPage now guards UIN switches when the editor is dirty and refetches the server-normalised config after save. ConfigPage prop count drops from 7 to 1; App.tsx from 421 to 270 LOC.
This commit is contained in:
11 files changed
+818
-398
No files matched your search
@@ -0,0 +1,13 @@
|
||||
export { createApiClient } from './client';
|
||||
export { ApiProvider, useApi } from './context';
|
||||
export { ApiError } from './types';
|
||||
export type {
|
||||
ApiClient,
|
||||
ChangePasswordResult,
|
||||
CreateApiClientOptions,
|
||||
LoginResult,
|
||||
LogsStreamOptions,
|
||||
ProcessActionResult,
|
||||
StreamStatus,
|
||||
TokenStore,
|
||||
} from './types';
|
||||
Reference in new issue
Block a user