mirror of
https://github.com/SilenceLurker/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 10:05:50 +00:00
Update drawer.js
This commit is contained in:
71
ui/drawer.js
71
ui/drawer.js
@@ -63,9 +63,14 @@ async function loadSettings() {
|
||||
}
|
||||
|
||||
export function createDrawer() {
|
||||
if ($("#amily2_main_drawer").length > 0) return;
|
||||
const settings = extension_settings[extensionName];
|
||||
const location = settings.iconLocation || 'topbar';
|
||||
|
||||
const amily2DrawerHtml = `
|
||||
if (location === 'topbar') {
|
||||
if ($("#amily2_main_drawer").length > 0) return;
|
||||
|
||||
|
||||
const amily2DrawerHtml = `
|
||||
<div id="amily2_main_drawer" class="drawer">
|
||||
<div id="amily2_drawer_icon" class="drawer-toggle drawer-header closedIcon interactable" title="Amily2号优化助手" tabindex="0">
|
||||
<i class="drawer-icon fa-solid fa-magic fa-fw"></i>
|
||||
@@ -76,9 +81,8 @@ const amily2DrawerHtml = `
|
||||
`;
|
||||
$("#sys-settings-button").after(amily2DrawerHtml);
|
||||
|
||||
|
||||
$(document).on(
|
||||
"mousedown",
|
||||
$(document).off("mousedown.amily2Drawer").on(
|
||||
"mousedown.amily2Drawer",
|
||||
"#amily2_drawer_icon",
|
||||
async function (e) {
|
||||
e.preventDefault();
|
||||
@@ -87,8 +91,6 @@ $(document).on(
|
||||
const drawerIcon = $(this);
|
||||
const contentPanel = $("#amily2_drawer_content");
|
||||
|
||||
|
||||
|
||||
$('.openDrawer').not(contentPanel).not('.pinnedOpen').addClass('resizing').each((_, el) => {
|
||||
slideToggle(el, {
|
||||
...getSlideToggleOptions(),
|
||||
@@ -97,14 +99,10 @@ $(document).on(
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
$('.openIcon').not(drawerIcon).not('.drawerPinnedOpen').toggleClass('closedIcon openIcon');
|
||||
$('.openDrawer').not(contentPanel).not('.pinnedOpen').toggleClass('closedDrawer openDrawer');
|
||||
|
||||
drawerIcon.toggleClass('closedIcon openIcon');
|
||||
contentPanel.toggleClass('closedDrawer openDrawer');
|
||||
|
||||
|
||||
contentPanel.addClass('resizing').each((_, el) => {
|
||||
slideToggle(el, {
|
||||
...getSlideToggleOptions(),
|
||||
@@ -114,27 +112,56 @@ $(document).on(
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
const isInitialized = contentPanel.data("initialized");
|
||||
if (drawerIcon.hasClass("openIcon") && !isInitialized) {
|
||||
try {
|
||||
const extensionFolderPath = `scripts/extensions/third-party/${extensionName}`;
|
||||
const modalContent = await $.get(
|
||||
`${extensionFolderPath}/assets/amily2-modal.html`,
|
||||
);
|
||||
const modalContent = await $.get(`${extensionFolderPath}/assets/amily2-modal.html`);
|
||||
contentPanel.html(modalContent);
|
||||
await loadSettings();
|
||||
bindModalEvents();
|
||||
contentPanel.data("initialized", true);
|
||||
console.log("[Amily2号-建设部] 宫殿内室已根据最高指令激活。");
|
||||
console.log("[Amily2号-建设部] 顶栏宫殿内室已根据最高指令激活。");
|
||||
applyUpdateIndicator();
|
||||
} catch (error) {
|
||||
console.error("[Amily2号-建设部] 加载宫殿内部HTML失败:", error);
|
||||
contentPanel.html(
|
||||
'<p style="color:red; padding: 20px;">紧急报告:无法加载Amily2号府邸内饰。</p>',
|
||||
);
|
||||
console.error("[Amily2号-建设部] 加载顶栏宫殿内部HTML失败:", error);
|
||||
contentPanel.html('<p style="color:red; padding: 20px;">紧急报告:无法加载Amily2号府邸内饰。</p>');
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
);
|
||||
|
||||
} else if (location === 'extensions') {
|
||||
if ($("#extensions_settings2 #amily2_chat_optimiser").length > 0) return;
|
||||
const amilyFrameHtml = `
|
||||
<div id="amily2_extension_frame">
|
||||
<div class="inline-drawer">
|
||||
<div class="inline-drawer-toggle inline-drawer-header">
|
||||
<b><i class="fas fa-crown" style="color: #ffc107;"></i> Amily2号 优化中枢</b>
|
||||
<div class="inline-drawer-icon fa-solid fa-circle-chevron-down down"></div>
|
||||
</div>
|
||||
<div class="inline-drawer-content" style="display: none;">
|
||||
<!-- 宫殿的真正内室将在这里安家 -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
$('#extensions_settings2').append(amilyFrameHtml);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
console.log("[Amily2号-建设部] 收到指令,开始在'扩展'官方区域建造宫殿。");
|
||||
const modalContent = await $.get(`${extensionFolderPath}/assets/amily2-modal.html`);
|
||||
$('#amily2_extension_frame .inline-drawer-content').html(modalContent);
|
||||
await loadSettings();
|
||||
bindModalEvents();
|
||||
console.log("[Amily2号-建设部] '扩展'宫殿已根据最高指令建成并完全激活。");
|
||||
applyUpdateIndicator();
|
||||
|
||||
} catch (error) {
|
||||
console.error("[Amily2号-建设部] 在'扩展'区域加载宫殿HTML失败:", error);
|
||||
$('#extensions_settings2').append('<p style="color:red; padding:10px; border:1px solid red; border-radius:5px;">紧急报告:在扩展区域建造Amily2号府邸时发生意外。</p>');
|
||||
}
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user