import { getSlideToggleOptions } from '/script.js'; import { slideToggle } from '/lib.js'; import { extension_settings } from "/scripts/extensions.js"; import { extensionName, defaultSettings } from "../utils/settings.js"; import { checkAuthorization, displayExpiryInfo, pluginAuthStatus, } from "../utils/auth.js"; import { updateUI, setAvailableModels, populateModelDropdown, applyUpdateIndicator, } from "./state.js"; import { bindModalEvents } from "./bindings.js"; import { fetchSupportedModels } from "../core/api.js"; const extensionFolderPath = `scripts/extensions/third-party/${extensionName}`; async function loadSettings() { if (!extension_settings[extensionName]) { extension_settings[extensionName] = {}; } Object.assign(extension_settings[extensionName], { ...defaultSettings, ...extension_settings[extensionName], }); checkAuthorization(); const autoLogin = localStorage.getItem("plugin_auto_login") === "true"; console.log( `[Amily2-调试] 授权状态: ${pluginAuthStatus.authorized}, 自动登录标志: ${autoLogin}`, ); if (autoLogin && pluginAuthStatus.authorized) { console.log("[Amily2号] 检测到有效授权,将执行自动UI更新。"); } $("#expiry_info").html(displayExpiryInfo()); updateUI(); if (pluginAuthStatus.authorized && extension_settings[extensionName].apiUrl) { const cachedModels = localStorage.getItem("cached_models_amily2"); if (cachedModels) { const models = JSON.parse(cachedModels); console.log(`[Amily2号] 从缓存加载模型列表 (${models.length}个)`); setAvailableModels(models); populateModelDropdown(); } else { toastr.info("正在自动加载模型列表...", "Amily2号"); setTimeout(async () => { const models = await fetchSupportedModels(); if (models.length > 0) { setAvailableModels(models); localStorage.setItem("cached_models_amily2", JSON.stringify(models)); populateModelDropdown(); } }, 500); } } } export function createDrawer() { const settings = extension_settings[extensionName]; const location = settings.iconLocation || 'topbar'; if (location === 'topbar') { if ($("#amily2_main_drawer").length > 0) return; const amily2DrawerHtml = `
紧急报告:无法加载Amily2号府邸内饰。
'); } } }, ); } else if (location === 'extensions') { if ($("#extensions_settings2 #amily2_chat_optimiser").length > 0) return; const amilyFrameHtml = `紧急报告:在扩展区域建造Amily2号府邸时发生意外。
'); } })(); } }