mirror of
https://github.com/Wx-2025/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 13:55:51 +00:00
Update drawer.js
This commit is contained in:
135
ui/drawer.js
135
ui/drawer.js
@@ -63,9 +63,14 @@ async function loadSettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function createDrawer() {
|
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_main_drawer" class="drawer">
|
||||||
<div id="amily2_drawer_icon" class="drawer-toggle drawer-header closedIcon interactable" title="Amily2号优化助手" tabindex="0">
|
<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>
|
<i class="drawer-icon fa-solid fa-magic fa-fw"></i>
|
||||||
@@ -73,68 +78,90 @@ const amily2DrawerHtml = `
|
|||||||
<div id="amily2_drawer_content" class="drawer-content closedDrawer" style="display: none;">
|
<div id="amily2_drawer_content" class="drawer-content closedDrawer" style="display: none;">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
$("#sys-settings-button").after(amily2DrawerHtml);
|
$("#sys-settings-button").after(amily2DrawerHtml);
|
||||||
|
|
||||||
|
$(document).off("mousedown.amily2Drawer").on(
|
||||||
|
"mousedown.amily2Drawer",
|
||||||
|
"#amily2_drawer_icon",
|
||||||
|
async function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
$(document).on(
|
const drawerIcon = $(this);
|
||||||
"mousedown",
|
const contentPanel = $("#amily2_drawer_content");
|
||||||
"#amily2_drawer_icon",
|
|
||||||
async function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
|
|
||||||
const drawerIcon = $(this);
|
$('.openDrawer').not(contentPanel).not('.pinnedOpen').addClass('resizing').each((_, el) => {
|
||||||
const contentPanel = $("#amily2_drawer_content");
|
slideToggle(el, {
|
||||||
|
...getSlideToggleOptions(),
|
||||||
|
onAnimationEnd: function (el) {
|
||||||
|
el.closest('.drawer-content').classList.remove('resizing');
|
||||||
$('.openDrawer').not(contentPanel).not('.pinnedOpen').addClass('resizing').each((_, el) => {
|
},
|
||||||
slideToggle(el, {
|
});
|
||||||
...getSlideToggleOptions(),
|
|
||||||
onAnimationEnd: function (el) {
|
|
||||||
el.closest('.drawer-content').classList.remove('resizing');
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
$('.openIcon').not(drawerIcon).not('.drawerPinnedOpen').toggleClass('closedIcon openIcon');
|
||||||
|
$('.openDrawer').not(contentPanel).not('.pinnedOpen').toggleClass('closedDrawer openDrawer');
|
||||||
$('.openIcon').not(drawerIcon).not('.drawerPinnedOpen').toggleClass('closedIcon openIcon');
|
drawerIcon.toggleClass('closedIcon openIcon');
|
||||||
$('.openDrawer').not(contentPanel).not('.pinnedOpen').toggleClass('closedDrawer openDrawer');
|
contentPanel.toggleClass('closedDrawer openDrawer');
|
||||||
|
contentPanel.addClass('resizing').each((_, el) => {
|
||||||
drawerIcon.toggleClass('closedIcon openIcon');
|
slideToggle(el, {
|
||||||
contentPanel.toggleClass('closedDrawer openDrawer');
|
...getSlideToggleOptions(),
|
||||||
|
onAnimationEnd: function (el) {
|
||||||
|
el.closest('.drawer-content').classList.remove('resizing');
|
||||||
contentPanel.addClass('resizing').each((_, el) => {
|
},
|
||||||
slideToggle(el, {
|
});
|
||||||
...getSlideToggleOptions(),
|
|
||||||
onAnimationEnd: function (el) {
|
|
||||||
el.closest('.drawer-content').classList.remove('resizing');
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
const isInitialized = contentPanel.data("initialized");
|
||||||
|
if (drawerIcon.hasClass("openIcon") && !isInitialized) {
|
||||||
|
try {
|
||||||
|
const modalContent = await $.get(`${extensionFolderPath}/assets/amily2-modal.html`);
|
||||||
|
contentPanel.html(modalContent);
|
||||||
|
await loadSettings();
|
||||||
|
bindModalEvents();
|
||||||
|
contentPanel.data("initialized", true);
|
||||||
|
console.log("[Amily2号-建设部] 顶栏宫殿内室已根据最高指令激活。");
|
||||||
|
applyUpdateIndicator();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("[Amily2号-建设部] 加载顶栏宫殿内部HTML失败:", error);
|
||||||
|
contentPanel.html('<p style="color:red; padding: 20px;">紧急报告:无法加载Amily2号府邸内饰。</p>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const isInitialized = contentPanel.data("initialized");
|
} else if (location === 'extensions') {
|
||||||
if (drawerIcon.hasClass("openIcon") && !isInitialized) {
|
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 {
|
try {
|
||||||
const extensionFolderPath = `scripts/extensions/third-party/${extensionName}`;
|
console.log("[Amily2号-建设部] 收到指令,开始在'扩展'官方区域建造宫殿。");
|
||||||
const modalContent = await $.get(
|
const modalContent = await $.get(`${extensionFolderPath}/assets/amily2-modal.html`);
|
||||||
`${extensionFolderPath}/assets/amily2-modal.html`,
|
$('#amily2_extension_frame .inline-drawer-content').html(modalContent);
|
||||||
);
|
|
||||||
contentPanel.html(modalContent);
|
|
||||||
await loadSettings();
|
await loadSettings();
|
||||||
bindModalEvents();
|
bindModalEvents();
|
||||||
contentPanel.data("initialized", true);
|
console.log("[Amily2号-建设部] '扩展'宫殿已根据最高指令建成并完全激活。");
|
||||||
console.log("[Amily2号-建设部] 宫殿内室已根据最高指令激活。");
|
applyUpdateIndicator();
|
||||||
applyUpdateIndicator();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[Amily2号-建设部] 加载宫殿内部HTML失败:", error);
|
console.error("[Amily2号-建设部] 在'扩展'区域加载宫殿HTML失败:", error);
|
||||||
contentPanel.html(
|
$('#extensions_settings2').append('<p style="color:red; padding:10px; border:1px solid red; border-radius:5px;">紧急报告:在扩展区域建造Amily2号府邸时发生意外。</p>');
|
||||||
'<p style="color:red; padding: 20px;">紧急报告:无法加载Amily2号府邸内饰。</p>',
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
})();
|
||||||
},
|
}
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user