Files
AIcreat/app/static/mode-hint.js
2026-04-28 19:16:27 +08:00

28 lines
819 B
JavaScript

(() => {
const badges = Array.from(document.querySelectorAll(".global-mode-hint"));
if (!badges.length) return;
function setText(text) {
badges.forEach((el) => {
el.textContent = text;
});
}
async function run() {
try {
const res = await fetch("/api/auth/me");
const data = await res.json();
if (!res.ok || !data || !data.logged_in) return;
const vip = data.vip || {};
const now = Math.floor(Date.now() / 1000);
const enabled = Boolean(vip.vip_enabled);
const hasActiveSubscription = Number(vip.cycle_started_at || 0) > 0 && Number(vip.cycle_expires_at || 0) > now;
setText(enabled && hasActiveSubscription ? "当前模型模式:平台模型" : "当前模型模式:自由模型");
} catch {
// ignore
}
}
run();
})();