feat(model-manager): flag Early Access models in CivitAI browse
CivitAI Early Access versions require purchased access and otherwise fail with 401. Surface version `availability` from the API as an `early_access` flag (per card and per version), show an amber "EARLY ACCESS" tag on the card, label such entries in the version dropdown, and warn before attempting to download one. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -477,6 +477,12 @@ function renderBrowseCard(m) {
|
||||
n.textContent = "NSFW";
|
||||
thumb.appendChild(n);
|
||||
}
|
||||
if (m.early_access) {
|
||||
const ea = document.createElement("span");
|
||||
ea.className = "ea-tag";
|
||||
ea.textContent = "EARLY ACCESS";
|
||||
thumb.appendChild(ea);
|
||||
}
|
||||
|
||||
const body = document.createElement("div");
|
||||
body.className = "body";
|
||||
@@ -497,7 +503,8 @@ function renderBrowseCard(m) {
|
||||
for (const v of m.versions) {
|
||||
const o = document.createElement("option");
|
||||
o.value = v.id;
|
||||
o.textContent = v.name || `v${v.id}`;
|
||||
o.textContent = (v.name || `v${v.id}`) + (v.early_access ? " — Early Access" : "");
|
||||
o.dataset.ea = v.early_access ? "1" : "";
|
||||
versionSel.appendChild(o);
|
||||
}
|
||||
foot.appendChild(versionSel);
|
||||
@@ -507,8 +514,15 @@ function renderBrowseCard(m) {
|
||||
btn.className = "btn primary";
|
||||
btn.textContent = "Download";
|
||||
btn.addEventListener("click", () => {
|
||||
const vid = versionSel ? Number(versionSel.value) : m.primary_version_id;
|
||||
downloadVersion(vid, btn);
|
||||
let vid, isEa;
|
||||
if (versionSel) {
|
||||
vid = Number(versionSel.value);
|
||||
isEa = versionSel.selectedOptions[0]?.dataset.ea === "1";
|
||||
} else {
|
||||
vid = m.primary_version_id;
|
||||
isEa = m.early_access;
|
||||
}
|
||||
downloadVersion(vid, btn, isEa);
|
||||
});
|
||||
foot.appendChild(btn);
|
||||
|
||||
@@ -517,8 +531,15 @@ function renderBrowseCard(m) {
|
||||
return card;
|
||||
}
|
||||
|
||||
async function downloadVersion(versionId, btn) {
|
||||
async function downloadVersion(versionId, btn, isEarlyAccess) {
|
||||
if (!versionId) { toast($("#browseToast"), "No version available", true); return; }
|
||||
if (isEarlyAccess) {
|
||||
const ok = await confirmDialog(
|
||||
"This is an Early Access version. CivitAI only allows downloading it if " +
|
||||
"your account has purchased/unlocked access — otherwise it will fail with " +
|
||||
"401. Try anyway?", "Download");
|
||||
if (!ok) return;
|
||||
}
|
||||
btn.disabled = true;
|
||||
const original = btn.textContent;
|
||||
btn.textContent = "Queued ✓";
|
||||
|
||||
Reference in New Issue
Block a user