Files
ST-Amily2-Chat-Optimisation/ui/drawer.js
2025-08-21 12:00:10 +08:00

2 lines
11 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.
(function(_0x37acb4,_0xb11e9b){const _0x52247c=_0x4cfb,_0x1b5802=_0x37acb4();while(!![]){try{const _0x50010d=-parseInt(_0x52247c(0x169))/0x1*(-parseInt(_0x52247c(0x181))/0x2)+parseInt(_0x52247c(0x16b))/0x3+-parseInt(_0x52247c(0x1a7))/0x4*(-parseInt(_0x52247c(0x171))/0x5)+parseInt(_0x52247c(0x1ac))/0x6*(-parseInt(_0x52247c(0x177))/0x7)+-parseInt(_0x52247c(0x191))/0x8*(parseInt(_0x52247c(0x17b))/0x9)+-parseInt(_0x52247c(0x1ae))/0xa*(parseInt(_0x52247c(0x1a2))/0xb)+-parseInt(_0x52247c(0x1a4))/0xc;if(_0x50010d===_0xb11e9b)break;else _0x1b5802['push'](_0x1b5802['shift']());}catch(_0x2eb233){_0x1b5802['push'](_0x1b5802['shift']());}}}(_0x23cd,0xeb8f1));import{getSlideToggleOptions}from'/script.js';import{slideToggle}from'/lib.js';function _0x23cd(){const _0x503477=['iconLocation','408191DkOZhq','closedDrawer\x20openDrawer','removeClass','append','332109DmfqbG','[Amily2-兼容性]\x20检测到旧版环境\x20(无法导入\x20doNavbarIconClick),已绑定后备点击事件。','parse','closest','extensions','</div>','12gDOVlO','closedIcon',',\x20自动登录标志:\x20','[Amily2号]\x20从缓存加载模型列表\x20(','\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','data','resizing','/assets/Amily2-optimization.html','<p\x20style=\x22color:red;\x20padding:\x2020px;\x22>紧急报告无法加载Amily2号府邸内饰。</p>',':visible','openIcon','after','[Amily2号]\x20检测到有效授权将执行自动UI更新。','.drawer-content','#expiry_info','#extensions_settings2\x20#amily2_chat_optimiser','40Enmmxw','cached_models_amily2','length','doNavbarIconClick\x20is\x20not\x20a\x20function','html','get','log','true','not','#sys-settings-button','classList','error','click','authorized','addClass','toggleClass','#amily2_drawer_icon','22XvgPIF','/assets/hanlinyuan.html','20719128otZsFO','#amily2_drawer_content','[Amily2-兼容性]\x20检测到新版环境已绑定官方点击事件。','1398596OcSMxI','.inline-drawer-content','remove','each','.drawerPinnedOpen','24OltWAq','/assets/amily2-modal.html','5827930qoCDyk','apiUrl','stringify','function','closedIcon\x20openIcon','hasClass','/script.js','setItem','find','#amily2_main_drawer\x20.drawer-toggle','.pinnedOpen','info','187679Yjwwsd','topbar','5250348UyRKue','/assets/Memorisation-forms.html','正在自动加载模型列表...','<div\x20id=\x22amily2_memorisation_forms_panel\x22\x20style=\x22display:\x20none;\x22>','<div\x20id=\x22amily2_plot_optimization_panel\x22\x20style=\x22display:\x20none;\x22>','#extensions_settings2','20lMJwfD','getItem','initialized','/assets/Amily2-AdditionalFeatures.html','<div\x20id=\x22amily2_additional_features_panel\x22\x20style=\x22display:\x20none;\x22>'];_0x23cd=function(){return _0x503477;};return _0x23cd();}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';function _0x4cfb(_0x230646,_0x2eb60f){const _0x23cdeb=_0x23cd();return _0x4cfb=function(_0x4cfba4,_0x49f995){_0x4cfba4=_0x4cfba4-0x164;let _0x1682a3=_0x23cdeb[_0x4cfba4];return _0x1682a3;},_0x4cfb(_0x230646,_0x2eb60f);}import{bindModalEvents}from'./bindings.js';import{fetchModels}from'../core/api.js';import{bindHistoriographyEvents}from'./historiography-bindings.js';import{bindHanlinyuanEvents}from'./hanlinyuan-bindings.js';import{bindTableEvents}from'./table-bindings.js';import{showContentModal}from'./page-window.js';const extensionFolderPath='scripts/extensions/third-party/'+extensionName;async function loadSettings(){const _0x5063b1=_0x4cfb;extension_settings[extensionName]={...defaultSettings,...extension_settings[extensionName]||{}},checkAuthorization();const _0x48d30e=localStorage[_0x5063b1(0x172)]('plugin_auto_login')===_0x5063b1(0x198);console['log']('[Amily2-调试]\x20授权状态:\x20'+pluginAuthStatus['authorized']+_0x5063b1(0x183)+_0x48d30e);_0x48d30e&&pluginAuthStatus[_0x5063b1(0x19e)]&&console[_0x5063b1(0x197)](_0x5063b1(0x18d));$(_0x5063b1(0x18f))[_0x5063b1(0x195)](displayExpiryInfo()),updateUI();if(pluginAuthStatus['authorized']&&extension_settings[extensionName][_0x5063b1(0x1af)]){const _0x29bffa=localStorage[_0x5063b1(0x172)](_0x5063b1(0x192));if(_0x29bffa){const _0x44c2f6=JSON[_0x5063b1(0x17d)](_0x29bffa);console[_0x5063b1(0x197)](_0x5063b1(0x184)+_0x44c2f6[_0x5063b1(0x193)]+'个)'),setAvailableModels(_0x44c2f6),populateModelDropdown();}else toastr[_0x5063b1(0x168)](_0x5063b1(0x16d),'Amily2号'),setTimeout(async()=>{const _0x4f108d=_0x5063b1,_0x25ad2f=await fetchModels();_0x25ad2f[_0x4f108d(0x193)]>0x0&&(setAvailableModels(_0x25ad2f),localStorage[_0x4f108d(0x164)](_0x4f108d(0x192),JSON[_0x4f108d(0x1b0)](_0x25ad2f)),populateModelDropdown());},0x1f4);}}async function initializePanel(_0x1314bf,_0x14e360){const _0x28d6b7=_0x4cfb;if(_0x1314bf[_0x28d6b7(0x186)](_0x28d6b7(0x173)))return;try{const _0x5b9201=await $[_0x28d6b7(0x196)](extensionFolderPath+_0x28d6b7(0x1ad));_0x1314bf['html'](_0x5b9201);const _0x291b6f=_0x1314bf[_0x28d6b7(0x165)]('#amily2_chat_optimiser');if(_0x291b6f[_0x28d6b7(0x193)]){const _0xadf1e8=await $['get'](extensionFolderPath+_0x28d6b7(0x174)),_0x9f2962=_0x28d6b7(0x175)+_0xadf1e8+_0x28d6b7(0x180);_0x291b6f[_0x28d6b7(0x17a)](_0x9f2962);const _0x182e17=await $[_0x28d6b7(0x196)](extensionFolderPath+_0x28d6b7(0x1a3)),_0x42c725='<div\x20id=\x22amily2_hanlinyuan_panel\x22\x20style=\x22display:\x20none;\x22>'+_0x182e17+_0x28d6b7(0x180);_0x291b6f['append'](_0x42c725);const _0x5416bd=await $[_0x28d6b7(0x196)](extensionFolderPath+_0x28d6b7(0x16c)),_0x44da1f=_0x28d6b7(0x16e)+_0x5416bd+_0x28d6b7(0x180);_0x291b6f['append'](_0x44da1f);const _0x592816=await $[_0x28d6b7(0x196)](extensionFolderPath+_0x28d6b7(0x188)),_0x3a4046=_0x28d6b7(0x16f)+_0x592816+'</div>';_0x291b6f[_0x28d6b7(0x17a)](_0x3a4046);}bindModalEvents(),bindHistoriographyEvents(),await loadSettings(),bindHanlinyuanEvents(),bindTableEvents(),_0x1314bf[_0x28d6b7(0x186)](_0x28d6b7(0x173),!![]),console[_0x28d6b7(0x197)]('[Amily-重构]\x20宫殿模块已按蓝图竣工。'),applyUpdateIndicator();}catch(_0x351308){console[_0x28d6b7(0x19c)]('[Amily-建设部]\x20紧急报告加载模块化蓝图时发生意外:',_0x351308);const _0x42e70e=_0x14e360?'<p\x20style=\x22color:red;\x20padding:10px;\x20border:1px\x20solid\x20red;\x20border-radius:5px;\x22>紧急报告在扩展区域建造Amily2号府邸时发生意外。</p>':_0x28d6b7(0x189);_0x14e360?_0x14e360['append'](_0x42e70e):_0x1314bf[_0x28d6b7(0x195)](_0x42e70e);}}function toggleDrawerFallback(){const _0x56b5ee=_0x4cfb,_0xdb7605=$(_0x56b5ee(0x1a1)),_0x1300d4=$(_0x56b5ee(0x1a5));_0xdb7605['hasClass'](_0x56b5ee(0x18b))&&!_0x1300d4['is'](_0x56b5ee(0x18a))&&_0xdb7605[_0x56b5ee(0x179)](_0x56b5ee(0x18b))[_0x56b5ee(0x19f)](_0x56b5ee(0x182)),_0xdb7605[_0x56b5ee(0x1b3)](_0x56b5ee(0x182))?($('.openDrawer')[_0x56b5ee(0x199)](_0x1300d4)['not'](_0x56b5ee(0x167))[_0x56b5ee(0x19f)]('resizing')[_0x56b5ee(0x1aa)]((_0x4acb84,_0x2f4a79)=>{slideToggle(_0x2f4a79,{...getSlideToggleOptions(),'onAnimationEnd':function(_0x3cf22a){const _0x2383ba=_0x4cfb;_0x3cf22a[_0x2383ba(0x17e)](_0x2383ba(0x18e))[_0x2383ba(0x19b)][_0x2383ba(0x1a9)](_0x2383ba(0x187));}});}),$('.openIcon')['not'](_0xdb7605)['not'](_0x56b5ee(0x1ab))[_0x56b5ee(0x1a0)](_0x56b5ee(0x1b2)),$('.openDrawer')[_0x56b5ee(0x199)](_0x1300d4)['not'](_0x56b5ee(0x167))['toggleClass'](_0x56b5ee(0x178)),_0xdb7605[_0x56b5ee(0x1a0)](_0x56b5ee(0x1b2)),_0x1300d4[_0x56b5ee(0x1a0)](_0x56b5ee(0x178)),_0x1300d4[_0x56b5ee(0x19f)](_0x56b5ee(0x187))[_0x56b5ee(0x1aa)]((_0x44d0fb,_0xf3efc5)=>{slideToggle(_0xf3efc5,{...getSlideToggleOptions(),'onAnimationEnd':function(_0x49b9a5){const _0x3282b7=_0x4cfb;_0x49b9a5['closest'](_0x3282b7(0x18e))[_0x3282b7(0x19b)]['remove'](_0x3282b7(0x187));}});})):(_0xdb7605[_0x56b5ee(0x1a0)]('openIcon\x20closedIcon'),_0x1300d4[_0x56b5ee(0x1a0)]('openDrawer\x20closedDrawer'),_0x1300d4[_0x56b5ee(0x19f)]('resizing')[_0x56b5ee(0x1aa)]((_0x4b74fa,_0x3b77f3)=>{slideToggle(_0x3b77f3,{...getSlideToggleOptions(),'onAnimationEnd':function(_0x81cc50){const _0x1fc749=_0x4cfb;_0x81cc50[_0x1fc749(0x17e)](_0x1fc749(0x18e))['classList'][_0x1fc749(0x1a9)](_0x1fc749(0x187));}});}));}export async function createDrawer(){const _0x58926b=_0x4cfb,_0x46f484=extension_settings[extensionName],_0x287c0b=_0x46f484[_0x58926b(0x176)]||_0x58926b(0x16a);if(_0x287c0b===_0x58926b(0x16a)){if($('#amily2_main_drawer')[_0x58926b(0x193)]>0x0)return;const _0x2bf1cf='\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';$(_0x58926b(0x19a))[_0x58926b(0x18c)](_0x2bf1cf);const _0x26bc6f=$(_0x58926b(0x1a5));await initializePanel(_0x26bc6f);try{const {doNavbarIconClick:_0x274892}=await import(_0x58926b(0x1b4));if(typeof _0x274892===_0x58926b(0x1b1))$(_0x58926b(0x166))['on'](_0x58926b(0x19d),_0x274892),console[_0x58926b(0x197)](_0x58926b(0x1a6));else throw new Error(_0x58926b(0x194));}catch(_0xafa094){$(_0x58926b(0x166))['on'](_0x58926b(0x19d),toggleDrawerFallback),console['log'](_0x58926b(0x17c));}}else{if(_0x287c0b===_0x58926b(0x17f)){if($(_0x58926b(0x190))[_0x58926b(0x193)]>0x0)return;const _0x442574=_0x58926b(0x185),_0x103f86=$(_0x442574);$(_0x58926b(0x170))[_0x58926b(0x17a)](_0x103f86);const _0x2798e7=_0x103f86['find'](_0x58926b(0x1a8));initializePanel(_0x2798e7,_0x103f86);}}}