Files
ST-Amily2-Chat-Optimisation/ui/drawer.js
2025-08-05 07:14:39 +08:00

1 line
10 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const _0x38a0e4=_0xaffc;(function(_0x83275d,_0x5123cb){const _0x1532d3=_0xaffc,_0x2ad276=_0x83275d();while(!![]){try{const _0x3301ce=-parseInt(_0x1532d3(0x172))/0x1*(parseInt(_0x1532d3(0x170))/0x2)+-parseInt(_0x1532d3(0x16f))/0x3*(-parseInt(_0x1532d3(0x151))/0x4)+-parseInt(_0x1532d3(0x17a))/0x5*(parseInt(_0x1532d3(0x178))/0x6)+parseInt(_0x1532d3(0x176))/0x7*(parseInt(_0x1532d3(0x15a))/0x8)+parseInt(_0x1532d3(0x183))/0x9*(parseInt(_0x1532d3(0x155))/0xa)+-parseInt(_0x1532d3(0x14d))/0xb+parseInt(_0x1532d3(0x18a))/0xc*(parseInt(_0x1532d3(0x14f))/0xd);if(_0x3301ce===_0x5123cb)break;else _0x2ad276['push'](_0x2ad276['shift']());}catch(_0x1b9d92){_0x2ad276['push'](_0x2ad276['shift']());}}}(_0x5cf7,0xaf8da));import{getSlideToggleOptions}from'/script.js';import{slideToggle}from'/lib.js';function _0x5cf7(){const _0x31d098=['doNavbarIconClick\x20is\x20not\x20a\x20function','6VodJNB','\x0a\x20\x20\x20\x20\x20\x20<div\x20id=\x22amily2_extension_frame\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22inline-drawer\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22inline-drawer-toggle\x20inline-drawer-header\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<b><i\x20class=\x22fas\x20fa-crown\x22\x20style=\x22color:\x20#ffc107;\x22></i>\x20Amily2号\x20优化中枢</b>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22inline-drawer-icon\x20fa-solid\x20fa-circle-chevron-down\x20down\x22></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22inline-drawer-content\x22\x20style=\x22display:\x20none;\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20','2312435PSKJQr','[Amily2号]\x20检测到有效授权将执行自动UI更新。','#extensions_settings2','[Amily2-兼容性]\x20检测到旧版环境\x20(无法导入\x20doNavbarIconClick),已绑定后备点击事件。','#sys-settings-button','\x0a\x20\x20\x20\x20\x20\x20<div\x20id=\x22amily2_main_drawer\x22\x20class=\x22drawer\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22drawer-toggle\x22\x20data-drawer=\x22amily2_drawer_content\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20id=\x22amily2_drawer_icon\x22\x20class=\x22drawer-icon\x20fa-solid\x20fa-magic\x20fa-fw\x20closedIcon\x20interactable\x22\x20title=\x22Amily2号优化助手\x22\x20tabindex=\x220\x22></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20id=\x22amily2_drawer_content\x22\x20class=\x22drawer-content\x20closedDrawer\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20','[Amily2-调试]\x20授权状态:\x20','openIcon','plugin_auto_login','1467zpMjnm','not','.inline-drawer-content','data','.openIcon','#amily2_drawer_content','authorized','12kULFcj','<div\x20id=\x22amily2_additional_features_panel\x22\x20style=\x22display:\x20none;\x22>','[Amily2号]\x20从缓存加载模型列表\x20(','closedDrawer\x20openDrawer','resizing','getItem','info','.openDrawer','parse','.pinnedOpen','each','#extensions_settings2\x20#amily2_chat_optimiser','Amily2号','/assets/hanlinyuan.html','length','toggleClass','closedIcon\x20openIcon','/assets/Amily2-AdditionalFeatures.html','#expiry_info','remove','.drawer-content','append','/script.js',',\x20自动登录标志:\x20','true','15569301RvGDlY','#amily2_drawer_icon','12107186GJgOvS','closedIcon','293032ksBqZb','function','error','[Amily-建设部]\x20紧急报告加载模块化蓝图时发生意外:','32950oNmTFI','initialized','get','<p\x20style=\x22color:red;\x20padding:10px;\x20border:1px\x20solid\x20red;\x20border-radius:5px;\x22>紧急报告在扩展区域建造Amily2号府邸时发生意外。</p>','find','4280qIgGcY',':visible','/assets/amily2-modal.html','iconLocation','closest','openIcon\x20closedIcon','classList','hasClass','[Amily2-兼容性]\x20检测到新版环境已绑定官方点击事件。','log','html','scripts/extensions/third-party/','.drawerPinnedOpen','#amily2_chat_optimiser','正在自动加载模型列表...','<div\x20id=\x22amily2_hanlinyuan_panel\x22\x20style=\x22display:\x20none;\x22>','</div>','#amily2_main_drawer\x20.drawer-toggle','click','openDrawer\x20closedDrawer','[Amily-重构]\x20宫殿模块已按蓝图竣工。','21xLlLHz','2hkMXde','removeClass','691274RluxZa','topbar','<p\x20style=\x22color:red;\x20padding:\x2020px;\x22>紧急报告无法加载Amily2号府邸内饰。</p>','addClass','17101puJmrn'];_0x5cf7=function(){return _0x31d098;};return _0x5cf7();}import{extension_settings,renderExtensionTemplateAsync}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';import{bindHistoriographyEvents}from'./historiography-bindings.js';import{bindHanlinyuanEvents}from'./hanlinyuan-bindings.js';import{showContentModal}from'./page-window.js';const extensionFolderPath=_0x38a0e4(0x165)+extensionName;async function loadSettings(){const _0x771de9=_0x38a0e4;extension_settings[extensionName]={...defaultSettings,...extension_settings[extensionName]||{}},checkAuthorization();const _0xcc9759=localStorage[_0x771de9(0x18f)](_0x771de9(0x182))===_0x771de9(0x14c);console[_0x771de9(0x163)](_0x771de9(0x180)+pluginAuthStatus['authorized']+_0x771de9(0x14b)+_0xcc9759);_0xcc9759&&pluginAuthStatus[_0x771de9(0x189)]&&console[_0x771de9(0x163)](_0x771de9(0x17b));$(_0x771de9(0x146))[_0x771de9(0x164)](displayExpiryInfo()),updateUI();if(pluginAuthStatus[_0x771de9(0x189)]&&extension_settings[extensionName]['apiUrl']){const _0x9fb226=localStorage[_0x771de9(0x18f)]('cached_models_amily2');if(_0x9fb226){const _0x56a679=JSON[_0x771de9(0x192)](_0x9fb226);console[_0x771de9(0x163)](_0x771de9(0x18c)+_0x56a679[_0x771de9(0x142)]+'个)'),setAvailableModels(_0x56a679),populateModelDropdown();}else toastr[_0x771de9(0x190)](_0x771de9(0x168),_0x771de9(0x140)),setTimeout(async()=>{const _0x2d531c=await fetchSupportedModels();_0x2d531c['length']>0x0&&(setAvailableModels(_0x2d531c),localStorage['setItem']('cached_models_amily2',JSON['stringify'](_0x2d531c)),populateModelDropdown());},0x1f4);}}async function initializePanel(_0x4dc13d,_0x4b12fc){const _0x510a17=_0x38a0e4;if(_0x4dc13d[_0x510a17(0x186)](_0x510a17(0x156)))return;try{const _0x11b1bf=await $[_0x510a17(0x157)](extensionFolderPath+_0x510a17(0x15c));_0x4dc13d[_0x510a17(0x164)](_0x11b1bf);const _0x367df2=_0x4dc13d[_0x510a17(0x159)](_0x510a17(0x167));if(_0x367df2['length']){const _0x2d15c3=await $[_0x510a17(0x157)](extensionFolderPath+_0x510a17(0x145)),_0x55bb27=_0x510a17(0x18b)+_0x2d15c3+_0x510a17(0x16a);_0x367df2[_0x510a17(0x149)](_0x55bb27);const _0x3a7d27=await $[_0x510a17(0x157)](extensionFolderPath+_0x510a17(0x141)),_0x2a6072=_0x510a17(0x169)+_0x3a7d27+'</div>';_0x367df2[_0x510a17(0x149)](_0x2a6072);}await loadSettings(),bindModalEvents(),bindHistoriographyEvents(),bindHanlinyuanEvents(),_0x4dc13d[_0x510a17(0x186)]('initialized',!![]),console[_0x510a17(0x163)](_0x510a17(0x16e)),applyUpdateIndicator();}catch(_0x53213c){console[_0x510a17(0x153)](_0x510a17(0x154),_0x53213c);const _0x2c22fc=_0x4b12fc?_0x510a17(0x158):_0x510a17(0x174);_0x4b12fc?_0x4b12fc['append'](_0x2c22fc):_0x4dc13d[_0x510a17(0x164)](_0x2c22fc);}}function _0xaffc(_0xe42ec0,_0x3bf86f){const _0x5cf776=_0x5cf7();return _0xaffc=function(_0xaffcb6,_0x3b371a){_0xaffcb6=_0xaffcb6-0x140;let _0x2f417b=_0x5cf776[_0xaffcb6];return _0x2f417b;},_0xaffc(_0xe42ec0,_0x3bf86f);}function toggleDrawerFallback(){const _0x218213=_0x38a0e4,_0x394dcd=$(_0x218213(0x14e)),_0xbe36df=$('#amily2_drawer_content');_0x394dcd[_0x218213(0x161)](_0x218213(0x181))&&!_0xbe36df['is'](_0x218213(0x15b))&&_0x394dcd[_0x218213(0x171)](_0x218213(0x181))[_0x218213(0x175)](_0x218213(0x150)),_0x394dcd[_0x218213(0x161)](_0x218213(0x150))?($(_0x218213(0x191))[_0x218213(0x184)](_0xbe36df)[_0x218213(0x184)](_0x218213(0x193))['addClass']('resizing')['each']((_0x1edb09,_0x11b0ae)=>{slideToggle(_0x11b0ae,{...getSlideToggleOptions(),'onAnimationEnd':function(_0xffbf62){const _0x158282=_0xaffc;_0xffbf62[_0x158282(0x15e)](_0x158282(0x148))['classList'][_0x158282(0x147)](_0x158282(0x18e));}});}),$(_0x218213(0x187))['not'](_0x394dcd)[_0x218213(0x184)](_0x218213(0x166))['toggleClass']('closedIcon\x20openIcon'),$(_0x218213(0x191))['not'](_0xbe36df)[_0x218213(0x184)]('.pinnedOpen')[_0x218213(0x143)](_0x218213(0x18d)),_0x394dcd['toggleClass'](_0x218213(0x144)),_0xbe36df[_0x218213(0x143)]('closedDrawer\x20openDrawer'),_0xbe36df[_0x218213(0x175)](_0x218213(0x18e))[_0x218213(0x194)]((_0x13af92,_0x1809c1)=>{slideToggle(_0x1809c1,{...getSlideToggleOptions(),'onAnimationEnd':function(_0x428acb){const _0x39de17=_0xaffc;_0x428acb[_0x39de17(0x15e)](_0x39de17(0x148))[_0x39de17(0x160)][_0x39de17(0x147)](_0x39de17(0x18e));}});})):(_0x394dcd[_0x218213(0x143)](_0x218213(0x15f)),_0xbe36df[_0x218213(0x143)](_0x218213(0x16d)),_0xbe36df[_0x218213(0x175)]('resizing')[_0x218213(0x194)]((_0x5e3849,_0x4e0a1e)=>{slideToggle(_0x4e0a1e,{...getSlideToggleOptions(),'onAnimationEnd':function(_0x30a661){const _0x1134cd=_0xaffc;_0x30a661[_0x1134cd(0x15e)]('.drawer-content')[_0x1134cd(0x160)][_0x1134cd(0x147)](_0x1134cd(0x18e));}});}));}export async function createDrawer(){const _0x427024=_0x38a0e4,_0x3f5608=extension_settings[extensionName],_0x3280fc=_0x3f5608[_0x427024(0x15d)]||_0x427024(0x173);if(_0x3280fc===_0x427024(0x173)){if($('#amily2_main_drawer')['length']>0x0)return;const _0x435678=_0x427024(0x17f);$(_0x427024(0x17e))['after'](_0x435678);const _0x5de5fd=$(_0x427024(0x188));await initializePanel(_0x5de5fd);try{const {doNavbarIconClick:_0x4d04f8}=await import(_0x427024(0x14a));if(typeof _0x4d04f8===_0x427024(0x152))$('#amily2_main_drawer\x20.drawer-toggle')['on'](_0x427024(0x16c),_0x4d04f8),console[_0x427024(0x163)](_0x427024(0x162));else throw new Error(_0x427024(0x177));}catch(_0x12561f){$(_0x427024(0x16b))['on']('click',toggleDrawerFallback),console['log'](_0x427024(0x17d));}}else{if(_0x3280fc==='extensions'){if($(_0x427024(0x195))['length']>0x0)return;const _0x277477=_0x427024(0x179),_0x445664=$(_0x277477);$(_0x427024(0x17c))[_0x427024(0x149)](_0x445664);const _0x2c6fc8=_0x445664[_0x427024(0x159)](_0x427024(0x185));initializePanel(_0x2c6fc8,_0x445664);}}}