mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
1047305274
commit
8a90ad0ba1
2 changed files with 101 additions and 103 deletions
|
|
@ -1,38 +0,0 @@
|
||||||
import {MenuItem} from "./Menu";
|
|
||||||
import {openSetting} from "../config";
|
|
||||||
/// #if !BROWSER
|
|
||||||
import {getCurrentWindow} from "@electron/remote";
|
|
||||||
/// #endif
|
|
||||||
import {openHistory} from "../util/history";
|
|
||||||
|
|
||||||
export const initToolbarMore = () => {
|
|
||||||
window.siyuan.menus.menu.remove();
|
|
||||||
if (!window.siyuan.config.readonly) {
|
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
|
||||||
icon: "iconSettings",
|
|
||||||
accelerator: window.siyuan.config.keymap.general.config.custom,
|
|
||||||
label: window.siyuan.languages.config,
|
|
||||||
click: () => {
|
|
||||||
openSetting();
|
|
||||||
}
|
|
||||||
}).element);
|
|
||||||
}
|
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
|
||||||
label: window.siyuan.languages.dataHistory,
|
|
||||||
icon: "iconVideo",
|
|
||||||
accelerator: window.siyuan.config.keymap.general.history.custom,
|
|
||||||
click: () => {
|
|
||||||
openHistory();
|
|
||||||
}
|
|
||||||
}).element);
|
|
||||||
/// #if !BROWSER
|
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
|
||||||
icon: "iconBug",
|
|
||||||
label: window.siyuan.languages.debug,
|
|
||||||
click: () => {
|
|
||||||
getCurrentWindow().webContents.openDevTools({mode: "bottom"});
|
|
||||||
}
|
|
||||||
}).element);
|
|
||||||
/// #endif
|
|
||||||
return window.siyuan.menus.menu;
|
|
||||||
};
|
|
||||||
|
|
@ -7,7 +7,6 @@ import {getCurrentWindow} from "@electron/remote";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {appearance} from "../config/appearance";
|
import {appearance} from "../config/appearance";
|
||||||
import {initToolbarMore} from "../menus/toolbar";
|
|
||||||
import {globalShortcut} from "./globalShortcut";
|
import {globalShortcut} from "./globalShortcut";
|
||||||
import {fetchPost} from "./fetch";
|
import {fetchPost} from "./fetch";
|
||||||
import {mountHelp, newDailyNote} from "./mount";
|
import {mountHelp, newDailyNote} from "./mount";
|
||||||
|
|
@ -24,6 +23,7 @@ import {openSetting} from "../config";
|
||||||
import {getSearch} from "./functions";
|
import {getSearch} from "./functions";
|
||||||
import {getAllDocks} from "../layout/getAll";
|
import {getAllDocks} from "../layout/getAll";
|
||||||
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
||||||
|
import {openHistory} from "./history";
|
||||||
|
|
||||||
const matchKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => {
|
const matchKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => {
|
||||||
if (key1 === "general") {
|
if (key1 === "general") {
|
||||||
|
|
@ -284,9 +284,19 @@ const initBar = () => {
|
||||||
<use xlink:href="#iconMoon"></use>
|
<use xlink:href="#iconMoon"></use>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<div data-menu="true" id="barMore" class="toolbar__item b3-tooltips b3-tooltips__se" aria-label="${window.siyuan.languages.more}">
|
<div id="barSetting" class="toolbar__item b3-tooltips b3-tooltips__se${window.siyuan.config.readonly ? " fn__none" : ""}" aria-label="${window.siyuan.languages.config} ${updateHotkeyTip(window.siyuan.config.keymap.general.config.custom)}">
|
||||||
<svg>
|
<svg>
|
||||||
<use xlink:href="#iconMore"></use>
|
<use xlink:href="#iconSettings"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div id="barHistory" class="toolbar__item b3-tooltips b3-tooltips__se" aria-label="${window.siyuan.languages.dataHistory} ${updateHotkeyTip(window.siyuan.config.keymap.general.history.custom)}">
|
||||||
|
<svg>
|
||||||
|
<use xlink:href="#iconVideo"></use>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div id="barDebug" class="toolbar__item b3-tooltips b3-tooltips__se fn__none" aria-label="${window.siyuan.languages.debug}">
|
||||||
|
<svg>
|
||||||
|
<use xlink:href="#iconBug"></use>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<button id="barBack" data-menu="true" class="toolbar__item toolbar__item--disabled b3-tooltips b3-tooltips__se" aria-label="${window.siyuan.languages.goBack} ${updateHotkeyTip(window.siyuan.config.keymap.general.goBack.custom)}">
|
<button id="barBack" data-menu="true" class="toolbar__item toolbar__item--disabled b3-tooltips b3-tooltips__se" aria-label="${window.siyuan.languages.goBack} ${updateHotkeyTip(window.siyuan.config.keymap.general.goBack.custom)}">
|
||||||
|
|
@ -301,48 +311,72 @@ const initBar = () => {
|
||||||
</button>
|
</button>
|
||||||
<div class="fn__flex-1 fn__ellipsis" id="drag"><span class="fn__none">开发版,使用前请进行备份 Development version, please backup before use</span></div>
|
<div class="fn__flex-1 fn__ellipsis" id="drag"><span class="fn__none">开发版,使用前请进行备份 Development version, please backup before use</span></div>
|
||||||
<div class="fn__flex" style="top: -1px;z-index: 502;right: -1px;position: relative;" id="windowControls"></div>`;
|
<div class="fn__flex" style="top: -1px;z-index: 502;right: -1px;position: relative;" id="windowControls"></div>`;
|
||||||
document.getElementById("barBack").addEventListener("click", () => {
|
/// #if !BROWSER
|
||||||
|
document.querySelector("#barDebug").classList.remove("fn__none");
|
||||||
|
/// #endif
|
||||||
|
document.querySelector(".toolbar").addEventListener("click", (event: MouseEvent) => {
|
||||||
|
let target = event.target as HTMLElement;
|
||||||
|
while (!target.classList.contains("toolbar")) {
|
||||||
|
if (target.id === "barBack") {
|
||||||
goBack();
|
goBack();
|
||||||
});
|
event.stopPropagation();
|
||||||
document.getElementById("barForward").addEventListener("click", () => {
|
break;
|
||||||
|
} else if (target.id === "barForward") {
|
||||||
goForward();
|
goForward();
|
||||||
});
|
event.stopPropagation();
|
||||||
document.getElementById("barMore").addEventListener("click", (event) => {
|
break;
|
||||||
initToolbarMore().popup({x: event.clientX, y: event.clientY});
|
} else if (target.id === "barHistory") {
|
||||||
});
|
openHistory();
|
||||||
const barThemeModeElement = document.getElementById("barThemeMode");
|
event.stopPropagation();
|
||||||
barThemeModeElement.addEventListener("click", () => {
|
break;
|
||||||
if (barThemeModeElement.getAttribute("disabled")) {
|
} else if (target.id === "barSetting") {
|
||||||
|
openSetting();
|
||||||
|
event.stopPropagation();
|
||||||
|
break;
|
||||||
|
} else if (target.id === "barDebug") {
|
||||||
|
/// #if !BROWSER
|
||||||
|
getCurrentWindow().webContents.openDevTools({mode: "bottom"});
|
||||||
|
/// #endif
|
||||||
|
event.stopPropagation();
|
||||||
|
break;
|
||||||
|
} else if (target.id === "toolbarVIP") {
|
||||||
|
const dialogSetting = openSetting();
|
||||||
|
dialogSetting.element.querySelector('.b3-tab-bar [data-name="account"]').dispatchEvent(new CustomEvent("click"));
|
||||||
|
event.stopPropagation();
|
||||||
|
break;
|
||||||
|
} else if (target.id === "barSearch") {
|
||||||
|
openSearch(window.siyuan.config.keymap.general.globalSearch.custom);
|
||||||
|
event.stopPropagation();
|
||||||
|
break;
|
||||||
|
} else if (target.id === "barThemeMode") {
|
||||||
|
if (target.getAttribute("disabled")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (barThemeModeElement.classList.contains("toolbar__item--active")) {
|
if (target.classList.contains("toolbar__item--active")) {
|
||||||
barThemeModeElement.classList.remove("toolbar__item--active");
|
target.classList.remove("toolbar__item--active");
|
||||||
barThemeModeElement.setAttribute("aria-label", window.siyuan.languages.themeDark);
|
target.setAttribute("aria-label", window.siyuan.languages.themeDark);
|
||||||
} else {
|
} else {
|
||||||
barThemeModeElement.classList.add("toolbar__item--active");
|
target.classList.add("toolbar__item--active");
|
||||||
barThemeModeElement.setAttribute("aria-label", window.siyuan.languages.themeLight);
|
target.setAttribute("aria-label", window.siyuan.languages.themeLight);
|
||||||
}
|
}
|
||||||
barThemeModeElement.setAttribute("disabled", "disabled");
|
target.setAttribute("disabled", "disabled");
|
||||||
fetchPost("/api/system/setAppearanceMode", {
|
fetchPost("/api/system/setAppearanceMode", {
|
||||||
mode: barThemeModeElement.classList.contains("toolbar__item--active") ? 1 : 0
|
mode: target.classList.contains("toolbar__item--active") ? 1 : 0
|
||||||
}, response => {
|
}, response => {
|
||||||
if (window.siyuan.config.appearance.themeJS) {
|
if (window.siyuan.config.appearance.themeJS) {
|
||||||
exportLayout(true);
|
exportLayout(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.siyuan.config.appearance = response.data.appearance;
|
window.siyuan.config.appearance = response.data.appearance;
|
||||||
barThemeModeElement.removeAttribute("disabled");
|
target.removeAttribute("disabled");
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
ipcRenderer.send(Constants.SIYUAN_CONFIG_THEME, response.data.mode === 1 ? "dark" : "light");
|
ipcRenderer.send(Constants.SIYUAN_CONFIG_THEME, response.data.mode === 1 ? "dark" : "light");
|
||||||
/// #endif
|
/// #endif
|
||||||
loadAssets(response.data.appearance);
|
loadAssets(response.data.appearance);
|
||||||
});
|
});
|
||||||
});
|
event.stopPropagation();
|
||||||
document.getElementById("toolbarVIP").addEventListener("click", () => {
|
break;
|
||||||
const dialogSetting = openSetting();
|
} else if (target.id === "barDailyNote") {
|
||||||
dialogSetting.element.querySelector('.b3-tab-bar [data-name="account"]').dispatchEvent(new CustomEvent("click"));
|
|
||||||
});
|
|
||||||
document.getElementById("barDailyNote").addEventListener("click", (event) => {
|
|
||||||
if (getOpenNotebookCount() < 2) {
|
if (getOpenNotebookCount() < 2) {
|
||||||
newDailyNote();
|
newDailyNote();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -362,9 +396,11 @@ const initBar = () => {
|
||||||
});
|
});
|
||||||
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY});
|
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY});
|
||||||
}
|
}
|
||||||
});
|
event.stopPropagation();
|
||||||
document.getElementById("barSearch").addEventListener("click", () => {
|
break;
|
||||||
openSearch(window.siyuan.config.keymap.general.globalSearch.custom);
|
}
|
||||||
|
target = target.parentElement;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
setProxy();
|
setProxy();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue