From 21823e11d861a7b5f67a24bcf5ac45a1be06b916 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Tue, 30 Apr 2024 08:58:20 +0800 Subject: [PATCH] :art: Clean code --- app/electron/main.js | 4 ++-- app/src/boot/globalEvent/commandPanel.ts | 6 ++--- app/src/boot/onGetConfig.ts | 4 ++-- app/src/config/about.ts | 2 +- app/src/config/editor.ts | 2 +- app/src/editor/util.ts | 2 +- app/src/history/history.ts | 28 ++++++++++++------------ app/src/menus/onGetnotebookconf.ts | 2 +- app/src/protyle/header/Background.ts | 20 ++++++++--------- app/src/protyle/ui/initUI.ts | 2 +- app/src/protyle/util/hotKey.ts | 4 ++-- app/src/protyle/wysiwyg/input.ts | 2 +- 12 files changed, 39 insertions(+), 39 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index 203b864b2..66a1c1863 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -231,9 +231,9 @@ const writeLog = (out) => { }; let openAsHidden = false; -isOpenAsHidden = function () { +const isOpenAsHidden = function () { return 1 === workspaces.length && openAsHidden; -} +}; const initMainWindow = () => { let windowStateInitialized = true; diff --git a/app/src/boot/globalEvent/commandPanel.ts b/app/src/boot/globalEvent/commandPanel.ts index 387340eb9..db1084870 100644 --- a/app/src/boot/globalEvent/commandPanel.ts +++ b/app/src/boot/globalEvent/commandPanel.ts @@ -19,7 +19,7 @@ import {Files} from "../../layout/dock/Files"; /// #endif export const commandPanel = (app: App) => { - const range = getSelection().getRangeAt(0) + const range = getSelection().getRangeAt(0); const dialog = new Dialog({ width: isMobile() ? "92vw" : "80vw", height: isMobile() ? "80vh" : "70vh", @@ -83,7 +83,7 @@ export const commandPanel = (app: App) => { inputElement.focus(); /// #if !MOBILE listElement.addEventListener("click", (event: KeyboardEvent) => { - const liElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item") + const liElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item"); if (liElement) { const command = liElement.getAttribute("data-command"); if (command) { @@ -93,7 +93,7 @@ export const commandPanel = (app: App) => { event.stopPropagation(); } } - }) + }); /// #endif inputElement.addEventListener("keydown", (event: KeyboardEvent) => { event.stopPropagation(); diff --git a/app/src/boot/onGetConfig.ts b/app/src/boot/onGetConfig.ts index 57e0cbad4..fbb3a1f82 100644 --- a/app/src/boot/onGetConfig.ts +++ b/app/src/boot/onGetConfig.ts @@ -34,7 +34,7 @@ const matchKeymap = (keymap: Config.IKeys, key1: "general" | "editor", key2?: "g if (!window.siyuan.config.keymap[key1]) { ipcRenderer.send(Constants.SIYUAN_CMD, { cmd: "writeLog", - msg: 'window.siyuan.config.keymap.general is not found' + msg: "window.siyuan.config.keymap.general is not found" }); window.siyuan.config.keymap[key1] = keymap as Config.IKeymapGeneral; return false; @@ -43,7 +43,7 @@ const matchKeymap = (keymap: Config.IKeys, key1: "general" | "editor", key2?: "g if (!window.siyuan.config.keymap[key1]) { ipcRenderer.send(Constants.SIYUAN_CMD, { cmd: "writeLog", - msg: 'window.siyuan.config.keymap.editor is not found' + msg: "window.siyuan.config.keymap.editor is not found" }); window.siyuan.config.keymap[key1] = JSON.parse(JSON.stringify(Constants.SIYUAN_KEYMAP.editor)); return false; diff --git a/app/src/config/about.ts b/app/src/config/about.ts index cfe0444f0..67ed8a807 100644 --- a/app/src/config/about.ts +++ b/app/src/config/about.ts @@ -352,7 +352,7 @@ export const about = { /// #if !BROWSER const autoLaunchElement = about.element.querySelector("#autoLaunch") as HTMLInputElement; autoLaunchElement.addEventListener("change", () => { - const autoLaunchMode = parseInt(autoLaunchElement.value) + const autoLaunchMode = parseInt(autoLaunchElement.value); fetchPost("/api/system/setAutoLaunch", {autoLaunch: autoLaunchMode}, () => { window.siyuan.config.system.autoLaunch2 = autoLaunchMode; ipcRenderer.send(Constants.SIYUAN_AUTO_LAUNCH, { diff --git a/app/src/config/editor.ts b/app/src/config/editor.ts index 88e774ded..2b0a9d29b 100644 --- a/app/src/config/editor.ts +++ b/app/src/config/editor.ts @@ -336,7 +336,7 @@ export const editor = { (editor.element.querySelector("#dynamicLoadBlocks") as HTMLInputElement).value = "1024"; } - let markdown = { + const markdown = { inlineSup: (editor.element.querySelector("#editorMarkdownInlineSup") as HTMLInputElement).checked, inlineSub: (editor.element.querySelector("#editorMarkdownInlineSub") as HTMLInputElement).checked, inlineTag: (editor.element.querySelector("#editorMarkdownInlineTag") as HTMLInputElement).checked, diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts index e4ab2f499..4a1366371 100644 --- a/app/src/editor/util.ts +++ b/app/src/editor/util.ts @@ -750,4 +750,4 @@ export const openLink = (protyle: IProtyle, aLink: string, event?: MouseEvent, c /// #endif } /// #endif -} +}; diff --git a/app/src/history/history.ts b/app/src/history/history.ts index f239b39ae..0dff8cd62 100644 --- a/app/src/history/history.ts +++ b/app/src/history/history.ts @@ -42,25 +42,25 @@ const renderDoc = (element: HTMLElement, currentPage: number) => { if (window.siyuan.storage[Constants.LOCAL_HISTORY].type !== 2) { opElement.value = "all"; } - opElement.querySelector('option[value="clean"]').classList.remove("fn__none") - opElement.querySelector('option[value="update"]').classList.remove("fn__none") - opElement.querySelector('option[value="delete"]').classList.add("fn__none") - opElement.querySelector('option[value="format"]').classList.add("fn__none") - opElement.querySelector('option[value="sync"]').classList.remove("fn__none") - opElement.querySelector('option[value="replace"]').classList.add("fn__none") - opElement.querySelector('option[value="outline"]').classList.add("fn__none") + opElement.querySelector('option[value="clean"]').classList.remove("fn__none"); + opElement.querySelector('option[value="update"]').classList.remove("fn__none"); + opElement.querySelector('option[value="delete"]').classList.add("fn__none"); + opElement.querySelector('option[value="format"]').classList.add("fn__none"); + opElement.querySelector('option[value="sync"]').classList.remove("fn__none"); + opElement.querySelector('option[value="replace"]').classList.add("fn__none"); + opElement.querySelector('option[value="outline"]').classList.add("fn__none"); } else { notebookElement.removeAttribute("disabled"); if (window.siyuan.storage[Constants.LOCAL_HISTORY].type === 2) { opElement.value = "all"; } - opElement.querySelector('option[value="clean"]').classList.add("fn__none") - opElement.querySelector('option[value="update"]').classList.remove("fn__none") - opElement.querySelector('option[value="delete"]').classList.remove("fn__none") - opElement.querySelector('option[value="format"]').classList.remove("fn__none") - opElement.querySelector('option[value="sync"]').classList.remove("fn__none") - opElement.querySelector('option[value="replace"]').classList.remove("fn__none") - opElement.querySelector('option[value="outline"]').classList.remove("fn__none") + opElement.querySelector('option[value="clean"]').classList.add("fn__none"); + opElement.querySelector('option[value="update"]').classList.remove("fn__none"); + opElement.querySelector('option[value="delete"]').classList.remove("fn__none"); + opElement.querySelector('option[value="format"]').classList.remove("fn__none"); + opElement.querySelector('option[value="sync"]').classList.remove("fn__none"); + opElement.querySelector('option[value="replace"]').classList.remove("fn__none"); + opElement.querySelector('option[value="outline"]').classList.remove("fn__none"); } window.siyuan.storage[Constants.LOCAL_HISTORY] = { notebookId: notebookElement.value, diff --git a/app/src/menus/onGetnotebookconf.ts b/app/src/menus/onGetnotebookconf.ts index a7de89d44..85d255f02 100644 --- a/app/src/menus/onGetnotebookconf.ts +++ b/app/src/menus/onGetnotebookconf.ts @@ -33,7 +33,7 @@ export const genNotebookOption = (id: string, notebookId?: string) => { html += ``; }); return html; -} +}; export const onGetnotebookconf = (data: INotebookConf) => { const titleHTML = `