🎨 调整 hideSideBar 逻辑

This commit is contained in:
BTMuli
2023-11-02 11:26:29 +08:00
parent 149c7b3f27
commit a474b96280

View File

@@ -88,17 +88,21 @@ class TGClient {
/** /**
* @func hideSideBar * @func hideSideBar
* @since Beta v0.3.4 * @since Beta v0.3.5
* @desc 隐藏侧边栏 * @desc 隐藏侧边栏
* @returns {void} - 无返回值 * @returns {void} - 无返回值
*/ */
async hideSideBar(): Promise<void> { async hideSideBar(): Promise<void> {
const executeJS = const executeJS = `javascript:(function(){
"javascript:(function(){" + if (document.getElementById('teyvat_style')) {
"let st = document.createElement('style');" + return;
"st.innerHTML = '::-webkit-scrollbar{display:none}';" + } else {
"document.querySelector('body').appendChild(st);" + let style = document.createElement('style');
"})();"; style.innerHTML = '::-webkit-scrollbar{display:none}';
style.id = 'teyvat_style';
document.querySelector('body').appendChild(style);
}
})();`;
await invoke("execute_js", { label: "mhy_client", js: executeJS }); await invoke("execute_js", { label: "mhy_client", js: executeJS });
} }
@@ -154,13 +158,14 @@ class TGClient {
/** /**
* @func handleCallback * @func handleCallback
* @since Beta v0.3.4 * @since Beta v0.3.5
* @desc 处理米游社客户端的 callback * @desc 处理米游社客户端的 callback
* @param {Event<string>} arg - 事件参数 * @param {Event<string>} arg - 事件参数
* @returns {any} - 返回值 * @returns {any} - 返回值
*/ */
async handleCallback(arg: Event<string>): Promise<any> { async handleCallback(arg: Event<string>): Promise<any> {
console.log(`[${arg.windowLabel}] ${arg.payload}`); console.log(`[${arg.windowLabel}] ${arg.payload}`);
await this.hideSideBar();
const { method, payload, callback } = <NormalArg>JSON.parse(arg.payload); const { method, payload, callback } = <NormalArg>JSON.parse(arg.payload);
switch (method) { switch (method) {
case "getStatusBarHeight": case "getStatusBarHeight":
@@ -205,7 +210,6 @@ class TGClient {
// getNotificationSettings // getNotificationSettings
default: default:
console.warn(`[${arg.windowLabel}] ${arg.payload}`); console.warn(`[${arg.windowLabel}] ${arg.payload}`);
await this.hideSideBar();
} }
} }