mirror of
https://github.com/jasonxu114514/opencode2api.git
synced 2026-12-05 16:04:01 +00:00
Replace the single-file frontend (app.js, styles.css) with a multi-file ES module structure served from go:embed, and reorganize the 13 pages into 8 tabbed pages under 4 navigation groups: runtime (overview, diagnostics), integrations (access guide, API keys), models (quotas, rotation), and system (configuration, account). The redesign adopts a monochrome light/dark design system driven by prefers-color-scheme, replaces prompt()/confirm() flows with in-page dialogs, and keeps every management API call and deep link (old hashes alias to the new pages). Behavior changes: the log SSE connection now spans the whole console session and buffers while the stream tab is hidden; quota polling runs only while its tab is active; the first-run checklist appears on the overview page and hides once ready. Also fixes a crash on the rotation page: the persisted state serializes empty orders and maps as JSON null, which is now normalized before rendering, with the same defensive handling in the quota and API key pages. CI now syntax-checks the ES modules via node --input-type=module, and the README structure notes are updated.
27 lines
713 B
JavaScript
27 lines
713 B
JavaScript
// Shared API loaders that populate the console store.
|
|
import { api } from "./api.js";
|
|
import * as store from "./store.js";
|
|
import { toast } from "./ui.js";
|
|
|
|
export async function refreshMonitor() {
|
|
try {
|
|
store.set("monitor", await api("/api/monitor"));
|
|
} catch {
|
|
// The 3s poll stays silent; transient failures surface in the log stream.
|
|
}
|
|
}
|
|
|
|
export async function loadConfig() {
|
|
store.set("config", await api("/api/config"));
|
|
}
|
|
|
|
export async function loadDebugModels() {
|
|
try {
|
|
const data = await api("/api/debug/models");
|
|
if (data.last_inference) store.set("lastPlayground", data.last_inference);
|
|
store.set("debug", data);
|
|
} catch (error) {
|
|
toast(error.message, true);
|
|
}
|
|
}
|