providers: the page shows its rows as they load, skeletons in the shape of the list, until the providers are in — it was blank on first open; a reload keeps the list it has

This commit is contained in:
yetone
2026-09-24 23:40:09 +08:00
parent fa30d2b8ce
commit 837923c435
2 changed files with 30 additions and 0 deletions
+7
View File
@@ -411,6 +411,13 @@ body.window .foot { padding-left: 18px; }
/* ---- gateway page --------------------------------------------------------- */
/* Loading keeps the final geometry in place, so entering Gateway feels calm
even while provider discovery and account checks are still running. */
.pv-sk-row { min-height: 45px; }
.pv-sk-icon { width: 18px; height: 18px; border-radius: 5px; flex: none; }
.pv-sk-who { display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.pv-sk-name { width: 112px; height: 11px; }
.pv-sk-sub { width: min(260px, 64%); height: 8px; }
.pv-sk-key { width: 64px; height: 18px; border-radius: 9px; flex: none; }
#view-providers.loading .after-list { visibility: hidden; }
.gw-sk-dot { width: 8px; height: 8px; margin: 0 7px; border-radius: 50%; flex: none; }
.gw-sk-who { display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.gw-sk-title { width: 118px; height: 12px; }
+23
View File
@@ -212,6 +212,7 @@ function fit() {
}
async function load() {
if (view === "providers" && !providers) renderProvidersLoading();
try {
state = await api("state");
applyPrefs(state.settings);
@@ -603,12 +604,32 @@ $("#save").onclick = () => {
async function loadProviders() {
if (view === "gateway") renderGatewayLoading();
else if (!providers) renderProvidersLoading();
providers = await api("providers");
if (!providers.providers.length && editing === null) adding = true;
if (view === "gateway") renderGatewayView();
else renderProviders();
}
// Rows in the shape of the list while it is first asked for; a reload keeps
// the list it has until the new one is in.
function renderProvidersLoading() {
const page = $("#view-providers");
page.classList.add("loading");
page.setAttribute("aria-busy", "true");
const list = $("#providers");
list.hidden = false;
list.replaceChildren();
for (let i = 0; i < 5; i++) {
const row = el("div", "row provider pv-sk-row");
const who = el("div", "who pv-sk-who");
who.append(el("span", "skeleton pv-sk-name"), el("span", "skeleton pv-sk-sub"));
row.append(el("span", "skeleton pv-sk-icon"), who, el("span", "skeleton pv-sk-key"));
list.append(row);
}
$("#excluded").replaceChildren();
}
// One row per provider: logo, name, the agents pointed at it, key status.
// Everything else lives in the editor, a dialog over the page.
function renderProviders() {
@@ -616,6 +637,8 @@ function renderProviders() {
// scroll to the top; put it back so closing the editor leaves the reader
// where they were.
const view = $("#view-providers"), top = view.scrollTop;
view.classList.remove("loading");
view.removeAttribute("aria-busy");
closeProtoMenu();
const list = $("#providers");
list.replaceChildren();