mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
9e52b489a7
commit
d333088288
10 changed files with 109 additions and 38 deletions
|
|
@ -884,6 +884,10 @@ app.on('open-url', (event, url) => { // for macOS
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.on('browser-window-created', (_, window) => {
|
||||||
|
require("@electron/remote/main").enable(window.webContents)
|
||||||
|
})
|
||||||
|
|
||||||
app.on('second-instance', (event, argv) => {
|
app.on('second-instance', (event, argv) => {
|
||||||
writeLog('second-instance [' + argv + ']')
|
writeLog('second-instance [' + argv + ']')
|
||||||
let workspace = argv.find((arg) => arg.startsWith('--workspace='))
|
let workspace = argv.find((arg) => arg.startsWith('--workspace='))
|
||||||
|
|
|
||||||
|
|
@ -277,6 +277,6 @@ export const appearance = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadAssets(data);
|
loadAssets(data);
|
||||||
document.querySelector("#barMode use").setAttribute("xlink:href", `#icon${window.siyuan.config.appearance.modeOS ? "Mode" : (window.siyuan.config.appearance.mode === 0 ? "Light" : "Dark")}`);
|
document.querySelector("#barMode use")?.setAttribute("xlink:href", `#icon${window.siyuan.config.appearance.modeOS ? "Mode" : (window.siyuan.config.appearance.mode === 0 ? "Light" : "Dark")}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ import {Asset} from "../asset";
|
||||||
import {newFile} from "../util/newFile";
|
import {newFile} from "../util/newFile";
|
||||||
import {MenuItem} from "../menus/Menu";
|
import {MenuItem} from "../menus/Menu";
|
||||||
import {escapeHtml} from "../util/escape";
|
import {escapeHtml} from "../util/escape";
|
||||||
|
import {isWindow} from "../util/functions";
|
||||||
|
import {setTabPosition} from "../window/setHeader";
|
||||||
|
|
||||||
export class Wnd {
|
export class Wnd {
|
||||||
public id: string;
|
public id: string;
|
||||||
|
|
@ -319,6 +321,7 @@ export class Wnd {
|
||||||
switchWnd(newWnd, targetWnd);
|
switchWnd(newWnd, targetWnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setTabPosition();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -370,7 +373,7 @@ export class Wnd {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (currentTab) {
|
if (currentTab && currentTab.headElement) {
|
||||||
const initData = currentTab.headElement.getAttribute("data-initdata");
|
const initData = currentTab.headElement.getAttribute("data-initdata");
|
||||||
if (initData) {
|
if (initData) {
|
||||||
const json = JSON.parse(initData);
|
const json = JSON.parse(initData);
|
||||||
|
|
@ -495,6 +498,8 @@ export class Wnd {
|
||||||
} else if (this.children.length > window.siyuan.config.fileTree.maxOpenTabCount) {
|
} else if (this.children.length > window.siyuan.config.fileTree.maxOpenTabCount) {
|
||||||
this.removeOverCounter(oldFocusIndex);
|
this.removeOverCounter(oldFocusIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTabPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderTabList(event: MouseEvent) {
|
private renderTabList(event: MouseEvent) {
|
||||||
|
|
@ -652,6 +657,12 @@ export class Wnd {
|
||||||
if (window.siyuan.layout.centerLayout) {
|
if (window.siyuan.layout.centerLayout) {
|
||||||
const wnd = getWndByLayout(window.siyuan.layout.centerLayout);
|
const wnd = getWndByLayout(window.siyuan.layout.centerLayout);
|
||||||
if (!wnd) {
|
if (!wnd) {
|
||||||
|
/// #if !BROWSER
|
||||||
|
if (isWindow()) {
|
||||||
|
getCurrentWindow().destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/// #endif
|
||||||
const wnd = new Wnd();
|
const wnd = new Wnd();
|
||||||
window.siyuan.layout.centerLayout.addWnd(wnd);
|
window.siyuan.layout.centerLayout.addWnd(wnd);
|
||||||
wnd.addTab(newCenterEmptyTab());
|
wnd.addTab(newCenterEmptyTab());
|
||||||
|
|
|
||||||
|
|
@ -12,21 +12,25 @@ import {getCurrentWindow} from "@electron/remote";
|
||||||
import {MenuItem} from "../menus/Menu";
|
import {MenuItem} from "../menus/Menu";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
|
|
||||||
export const initStatus = () => {
|
export const initStatus = (isWindow = false) => {
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
const allDocks = getAllDocks();
|
const allDocks = getAllDocks();
|
||||||
let menuHTML = "";
|
let menuHTML = "";
|
||||||
allDocks.forEach(item => {
|
allDocks.forEach(item => {
|
||||||
menuHTML += `<button class="b3-menu__item" data-type="${item.type}"><svg class="b3-menu__icon""><use xlink:href="#${item.icon}"></use></svg><span class="b3-menu__label">${window.siyuan.languages[item.hotkeyLangId]}</span><span class="b3-menu__accelerator">${updateHotkeyTip(window.siyuan.config.keymap.general[item.hotkeyLangId].custom)}</span></button>`;
|
menuHTML += `<button class="b3-menu__item" data-type="${item.type}"><svg class="b3-menu__icon""><use xlink:href="#${item.icon}"></use></svg><span class="b3-menu__label">${window.siyuan.languages[item.hotkeyLangId]}</span><span class="b3-menu__accelerator">${updateHotkeyTip(window.siyuan.config.keymap.general[item.hotkeyLangId].custom)}</span></button>`;
|
||||||
});
|
});
|
||||||
document.getElementById("status").innerHTML = `<div id="barDock" class="toolbar__item b3-tooltips b3-tooltips__e${window.siyuan.config.readonly ? " fn__none" : ""}" aria-label="${window.siyuan.config.uiLayout.hideDock ? window.siyuan.languages.showDock : window.siyuan.languages.hideDock}">
|
let barDockHTML = "";
|
||||||
|
if (!isWindow) {
|
||||||
|
barDockHTML = `<div id="barDock" class="toolbar__item b3-tooltips b3-tooltips__e${window.siyuan.config.readonly || isWindow ? " fn__none" : ""}" aria-label="${window.siyuan.config.uiLayout.hideDock ? window.siyuan.languages.showDock : window.siyuan.languages.hideDock}">
|
||||||
<svg>
|
<svg>
|
||||||
<use xlink:href="#${window.siyuan.config.uiLayout.hideDock ? "iconDock" : "iconHideDock"}"></use>
|
<use xlink:href="#${window.siyuan.config.uiLayout.hideDock ? "iconDock" : "iconHideDock"}"></use>
|
||||||
</svg>
|
</svg>
|
||||||
<div class="b3-menu fn__none" style="bottom: 32px;left: 5px">
|
<div class="b3-menu fn__none" style="bottom: 32px;left: 5px">
|
||||||
${menuHTML}
|
${menuHTML}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>`
|
||||||
|
}
|
||||||
|
document.getElementById("status").innerHTML = `${barDockHTML}
|
||||||
<div class="status__msg"></div>
|
<div class="status__msg"></div>
|
||||||
<div class="fn__flex-1"></div>
|
<div class="fn__flex-1"></div>
|
||||||
<div class="status__backgroundtask fn__none"></div>
|
<div class="status__backgroundtask fn__none"></div>
|
||||||
|
|
@ -34,13 +38,16 @@ export const initStatus = () => {
|
||||||
<div id="statusHelp" class="toolbar__item b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.help}">
|
<div id="statusHelp" class="toolbar__item b3-tooltips b3-tooltips__w" aria-label="${window.siyuan.languages.help}">
|
||||||
<svg><use xlink:href="#iconHelp"></use></svg>
|
<svg><use xlink:href="#iconHelp"></use></svg>
|
||||||
</div>`;
|
</div>`;
|
||||||
const dockElement = document.getElementById("barDock");
|
if (!isWindow) {
|
||||||
dockElement.addEventListener("mousemove", () => {
|
const dockElement = document.getElementById("barDock");
|
||||||
dockElement.querySelector(".b3-menu").classList.remove("fn__none");
|
dockElement.addEventListener("mousemove", () => {
|
||||||
});
|
dockElement.querySelector(".b3-menu").classList.remove("fn__none");
|
||||||
dockElement.addEventListener("mouseleave", () => {
|
});
|
||||||
dockElement.querySelector(".b3-menu").classList.add("fn__none");
|
dockElement.addEventListener("mouseleave", () => {
|
||||||
});
|
dockElement.querySelector(".b3-menu").classList.add("fn__none");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
document.querySelector("#status").addEventListener("click", (event) => {
|
document.querySelector("#status").addEventListener("click", (event) => {
|
||||||
let target = event.target as HTMLElement;
|
let target = event.target as HTMLElement;
|
||||||
while (target.id !== "status") {
|
while (target.id !== "status") {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,8 @@ import {saveScroll} from "../protyle/scroll/saveScroll";
|
||||||
import {pdfResize} from "../asset/renderAssets";
|
import {pdfResize} from "../asset/renderAssets";
|
||||||
import {Backlink} from "./dock/Backlink";
|
import {Backlink} from "./dock/Backlink";
|
||||||
import {openFileById} from "../editor/util";
|
import {openFileById} from "../editor/util";
|
||||||
import {getSearch} from "../util/functions";
|
import {getSearch, isWindow} from "../util/functions";
|
||||||
|
import {setTabPosition} from "../window/setHeader";
|
||||||
|
|
||||||
export const setPanelFocus = (element: Element) => {
|
export const setPanelFocus = (element: Element) => {
|
||||||
if (element.classList.contains("layout__tab--active") || element.classList.contains("layout__wnd--active")) {
|
if (element.classList.contains("layout__tab--active") || element.classList.contains("layout__wnd--active")) {
|
||||||
|
|
@ -175,11 +176,17 @@ const JSONToDock = (json: any) => {
|
||||||
window.siyuan.layout.bottomDock = new Dock({position: "Bottom", data: json.bottom});
|
window.siyuan.layout.bottomDock = new Dock({position: "Bottom", data: json.bottom});
|
||||||
};
|
};
|
||||||
|
|
||||||
const JSONToCenter = (json: any, layout?: Layout | Wnd | Tab | Model) => {
|
export const JSONToCenter = (json: any, layout?: Layout | Wnd | Tab | Model) => {
|
||||||
let child: Layout | Wnd | Tab | Model;
|
let child: Layout | Wnd | Tab | Model;
|
||||||
if (json.instance === "Layout") {
|
if (json.instance === "Layout") {
|
||||||
if (!layout) {
|
if (!layout) {
|
||||||
window.siyuan.layout.layout = new Layout({element: document.getElementById("layouts")});
|
window.siyuan.layout.layout = new Layout({
|
||||||
|
element: document.getElementById("layouts"),
|
||||||
|
direction: json.direction,
|
||||||
|
size: json.size,
|
||||||
|
type: json.type,
|
||||||
|
resize: json.resize
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
child = new Layout({
|
child = new Layout({
|
||||||
direction: json.direction,
|
direction: json.direction,
|
||||||
|
|
@ -635,10 +642,10 @@ export const addResize = (obj: Layout | Wnd) => {
|
||||||
if (previousNowSize < 8 || nextNowSize < 8) {
|
if (previousNowSize < 8 || nextNowSize < 8) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (window.siyuan.layout.leftDock.layout.element.contains(previousElement) && previousNowSize < 188) {
|
if (window.siyuan.layout.leftDock?.layout.element.contains(previousElement) && previousNowSize < 188) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (window.siyuan.layout.rightDock.layout.element.contains(nextElement) && nextNowSize < 188) {
|
if (window.siyuan.layout.rightDock?.layout.element.contains(nextElement) && nextNowSize < 188) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
previousElement.style[direction === "lr" ? "width" : "height"] = previousNowSize + "px";
|
previousElement.style[direction === "lr" ? "width" : "height"] = previousNowSize + "px";
|
||||||
|
|
@ -666,10 +673,12 @@ export const addResize = (obj: Layout | Wnd) => {
|
||||||
nextElement.classList.add("fn__flex-1");
|
nextElement.classList.add("fn__flex-1");
|
||||||
}
|
}
|
||||||
resizeTabs();
|
resizeTabs();
|
||||||
window.siyuan.layout.leftDock.setSize();
|
if (!isWindow()) {
|
||||||
window.siyuan.layout.topDock.setSize();
|
window.siyuan.layout.leftDock.setSize();
|
||||||
window.siyuan.layout.bottomDock.setSize();
|
window.siyuan.layout.topDock.setSize();
|
||||||
window.siyuan.layout.rightDock.setSize();
|
window.siyuan.layout.bottomDock.setSize();
|
||||||
|
window.siyuan.layout.rightDock.setSize();
|
||||||
|
}
|
||||||
if (range) {
|
if (range) {
|
||||||
focusByRange(range);
|
focusByRange(range);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,12 @@ import {Tab} from "../layout/Tab";
|
||||||
import {MenuItem} from "./Menu";
|
import {MenuItem} from "./Menu";
|
||||||
import {Editor} from "../editor";
|
import {Editor} from "../editor";
|
||||||
import {copyTab} from "../layout/util";
|
import {copyTab} from "../layout/util";
|
||||||
|
/// #if !BROWSER
|
||||||
|
import {BrowserWindow} from "@electron/remote";
|
||||||
|
import * as path from "path";
|
||||||
|
/// #endif
|
||||||
import {copySubMenu} from "./commonMenuItem";
|
import {copySubMenu} from "./commonMenuItem";
|
||||||
|
import {Constants} from "../constants";
|
||||||
|
|
||||||
const closeMenu = (tab: Tab) => {
|
const closeMenu = (tab: Tab) => {
|
||||||
const allTabs: Tab[] = [];
|
const allTabs: Tab[] = [];
|
||||||
|
|
@ -163,7 +168,7 @@ export const initTabMenu = (tab: Tab) => {
|
||||||
submenu: splitSubMenu(tab)
|
submenu: splitSubMenu(tab)
|
||||||
}).element);
|
}).element);
|
||||||
const model = tab.model;
|
const model = tab.model;
|
||||||
let rootId;
|
let rootId:string;
|
||||||
if ((model && model instanceof Editor)) {
|
if ((model && model instanceof Editor)) {
|
||||||
rootId = model.editor.protyle.block.rootID;
|
rootId = model.editor.protyle.block.rootID;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -198,5 +203,27 @@ export const initTabMenu = (tab: Tab) => {
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
}
|
}
|
||||||
|
/// #if !BROWSER
|
||||||
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
label: "new window",
|
||||||
|
click: () => {
|
||||||
|
const win = new BrowserWindow({
|
||||||
|
show: true,
|
||||||
|
width: 1032,
|
||||||
|
height: 650,
|
||||||
|
frame: "darwin" === window.siyuan.config.system.os,
|
||||||
|
icon: path.join(window.siyuan.config.system.appDir, "stage", "icon-large.png"),
|
||||||
|
titleBarStyle: "hidden",
|
||||||
|
webPreferences: {
|
||||||
|
contextIsolation: false,
|
||||||
|
nodeIntegration: true,
|
||||||
|
webviewTag: true,
|
||||||
|
webSecurity: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
win.loadURL(`${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&id=${rootId}`)
|
||||||
|
}
|
||||||
|
}).element);
|
||||||
|
/// #endif
|
||||||
return window.siyuan.menus.menu;
|
return window.siyuan.menus.menu;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ export const goBack = async () => {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
document.querySelector("#barForward").classList.remove("toolbar__item--disabled");
|
document.querySelector("#barForward")?.classList.remove("toolbar__item--disabled");
|
||||||
if (!previousIsBack) {
|
if (!previousIsBack) {
|
||||||
forwardStack.push(window.siyuan.backStack.pop());
|
forwardStack.push(window.siyuan.backStack.pop());
|
||||||
}
|
}
|
||||||
|
|
@ -208,7 +208,7 @@ export const goBack = async () => {
|
||||||
}
|
}
|
||||||
previousIsBack = true;
|
previousIsBack = true;
|
||||||
if (window.siyuan.backStack.length === 0) {
|
if (window.siyuan.backStack.length === 0) {
|
||||||
document.querySelector("#barBack").classList.add("toolbar__item--disabled");
|
document.querySelector("#barBack")?.classList.add("toolbar__item--disabled");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -219,7 +219,7 @@ export const goForward = async () => {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
document.querySelector("#barBack").classList.remove("toolbar__item--disabled");
|
document.querySelector("#barBack")?.classList.remove("toolbar__item--disabled");
|
||||||
if (previousIsBack) {
|
if (previousIsBack) {
|
||||||
window.siyuan.backStack.push(forwardStack.pop());
|
window.siyuan.backStack.push(forwardStack.pop());
|
||||||
}
|
}
|
||||||
|
|
@ -236,7 +236,7 @@ export const goForward = async () => {
|
||||||
}
|
}
|
||||||
previousIsBack = false;
|
previousIsBack = false;
|
||||||
if (forwardStack.length === 0) {
|
if (forwardStack.length === 0) {
|
||||||
document.querySelector("#barForward").classList.add("toolbar__item--disabled");
|
document.querySelector("#barForward")?.classList.add("toolbar__item--disabled");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -269,7 +269,7 @@ export const pushBack = (protyle: IProtyle, range?: Range, blockElement?: Elemen
|
||||||
window.siyuan.backStack.push(forwardStack.pop());
|
window.siyuan.backStack.push(forwardStack.pop());
|
||||||
}
|
}
|
||||||
forwardStack = [];
|
forwardStack = [];
|
||||||
document.querySelector("#barForward").classList.add("toolbar__item--disabled");
|
document.querySelector("#barForward")?.classList.add("toolbar__item--disabled");
|
||||||
}
|
}
|
||||||
window.siyuan.backStack.push({
|
window.siyuan.backStack.push({
|
||||||
position,
|
position,
|
||||||
|
|
@ -283,7 +283,7 @@ export const pushBack = (protyle: IProtyle, range?: Range, blockElement?: Elemen
|
||||||
previousIsBack = false;
|
previousIsBack = false;
|
||||||
}
|
}
|
||||||
if (window.siyuan.backStack.length > 1) {
|
if (window.siyuan.backStack.length > 1) {
|
||||||
document.querySelector("#barBack").classList.remove("toolbar__item--disabled");
|
document.querySelector("#barBack")?.classList.remove("toolbar__item--disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
export const isMobile = () => {
|
export const isMobile = () => {
|
||||||
return !document.getElementById("dockBottom");
|
return document.getElementById("sidebar") ? true : false;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const isWindow = () => {
|
||||||
|
return document.getElementById("toolbar") ? false : true;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isTouchDevice = () => {
|
export const isTouchDevice = () => {
|
||||||
|
|
|
||||||
|
|
@ -118,8 +118,9 @@ export const onGetConfig = (isStart: boolean) => {
|
||||||
const hasKeymap4 = hasKeymap(Constants.SIYUAN_KEYMAP.editor.heading, "editor", "heading");
|
const hasKeymap4 = hasKeymap(Constants.SIYUAN_KEYMAP.editor.heading, "editor", "heading");
|
||||||
const hasKeymap5 = hasKeymap(Constants.SIYUAN_KEYMAP.editor.list, "editor", "list");
|
const hasKeymap5 = hasKeymap(Constants.SIYUAN_KEYMAP.editor.list, "editor", "list");
|
||||||
const hasKeymap6 = hasKeymap(Constants.SIYUAN_KEYMAP.editor.table, "editor", "table");
|
const hasKeymap6 = hasKeymap(Constants.SIYUAN_KEYMAP.editor.table, "editor", "table");
|
||||||
if (!window.siyuan.config.readonly && (!matchKeymap1 || !matchKeymap2 || !matchKeymap3 || !matchKeymap4 || !matchKeymap5 || !matchKeymap6) &&
|
if (!window.siyuan.config.readonly &&
|
||||||
(!hasKeymap1 || !hasKeymap2 || !hasKeymap3 || !hasKeymap4 || !hasKeymap5 || !hasKeymap6)) {
|
(!matchKeymap1 || !matchKeymap2 || !matchKeymap3 || !matchKeymap4 || !matchKeymap5 || !matchKeymap6 ||
|
||||||
|
!hasKeymap1 || !hasKeymap2 || !hasKeymap3 || !hasKeymap4 || !hasKeymap5 || !hasKeymap6)) {
|
||||||
fetchPost("/api/setting/setKeymap", {
|
fetchPost("/api/setting/setKeymap", {
|
||||||
data: window.siyuan.config.keymap
|
data: window.siyuan.config.keymap
|
||||||
}, () => {
|
}, () => {
|
||||||
|
|
@ -179,7 +180,7 @@ export const onGetConfig = (isStart: boolean) => {
|
||||||
addGA();
|
addGA();
|
||||||
};
|
};
|
||||||
|
|
||||||
const initBar = () => {
|
export const initBar = () => {
|
||||||
const toolbar = document.getElementById("toolbar");
|
const toolbar = document.getElementById("toolbar");
|
||||||
toolbar.innerHTML = `
|
toolbar.innerHTML = `
|
||||||
<div id="barWorkspace" class="toolbar__item">
|
<div id="barWorkspace" class="toolbar__item">
|
||||||
|
|
@ -325,7 +326,7 @@ const winOnClose = (currentWindow: Electron.BrowserWindow, close = false) => {
|
||||||
/// #endif
|
/// #endif
|
||||||
};
|
};
|
||||||
|
|
||||||
const initWindow = () => {
|
export const initWindow = () => {
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
const currentWindow = getCurrentWindow();
|
const currentWindow = getCurrentWindow();
|
||||||
currentWindow.on("focus", winOnFocus);
|
currentWindow.on("focus", winOnFocus);
|
||||||
|
|
@ -451,8 +452,8 @@ const initWindow = () => {
|
||||||
window.addEventListener("beforeunload", () => {
|
window.addEventListener("beforeunload", () => {
|
||||||
currentWindow.off("focus", winOnFocus);
|
currentWindow.off("focus", winOnFocus);
|
||||||
}, false);
|
}, false);
|
||||||
if ("windows" !== window.siyuan.config.system.os && "linux" !== window.siyuan.config.system.os) {
|
if ( "darwin" === window.siyuan.config.system.os) {
|
||||||
document.getElementById("drag").addEventListener("dblclick", () => {
|
document.getElementById("drag")?.addEventListener("dblclick", () => {
|
||||||
if (currentWindow.isMaximized()) {
|
if (currentWindow.isMaximized()) {
|
||||||
currentWindow.unmaximize();
|
currentWindow.unmaximize();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -474,7 +475,7 @@ const initWindow = () => {
|
||||||
}
|
}
|
||||||
document.body.classList.add("body--win32");
|
document.body.classList.add("body--win32");
|
||||||
|
|
||||||
//添加应用图标
|
// 添加应用图标
|
||||||
const toolbar = document.getElementById("toolbar");
|
const toolbar = document.getElementById("toolbar");
|
||||||
toolbar.insertAdjacentHTML("afterbegin", `<div class="toolbar__item" id="windowAppIcon">
|
toolbar.insertAdjacentHTML("afterbegin", `<div class="toolbar__item" id="windowAppIcon">
|
||||||
<svg>
|
<svg>
|
||||||
|
|
@ -482,7 +483,7 @@ const initWindow = () => {
|
||||||
</svg>
|
</svg>
|
||||||
</div>`);
|
</div>`);
|
||||||
|
|
||||||
//添加窗口控件
|
// 添加窗口控件
|
||||||
const controlsElement = document.getElementById("windowControls");
|
const controlsElement = document.getElementById("windowControls");
|
||||||
controlsElement.innerHTML = `<div class="toolbar__item b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.min}" id="minWindow">
|
controlsElement.innerHTML = `<div class="toolbar__item b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.min}" id="minWindow">
|
||||||
<svg>
|
<svg>
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ module.exports = (env, argv) => {
|
||||||
},
|
},
|
||||||
entry: {
|
entry: {
|
||||||
'main': './src/index.ts',
|
'main': './src/index.ts',
|
||||||
|
'window': './src/window.ts',
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.ts', '.js', '.tpl', '.scss', '.png', '.svg'],
|
extensions: ['.ts', '.js', '.tpl', '.scss', '.png', '.svg'],
|
||||||
|
|
@ -41,7 +42,8 @@ module.exports = (env, argv) => {
|
||||||
{
|
{
|
||||||
test: /\.tpl/,
|
test: /\.tpl/,
|
||||||
include: [
|
include: [
|
||||||
path.resolve(__dirname, 'src/assets/template/app/index.tpl')],
|
path.resolve(__dirname, 'src/assets/template/app/index.tpl'),
|
||||||
|
path.resolve(__dirname, 'src/assets/template/app/window.tpl')],
|
||||||
loader: 'html-loader',
|
loader: 'html-loader',
|
||||||
options: {
|
options: {
|
||||||
sources: false,
|
sources: false,
|
||||||
|
|
@ -117,6 +119,12 @@ module.exports = (env, argv) => {
|
||||||
filename: 'index.html',
|
filename: 'index.html',
|
||||||
template: 'src/assets/template/app/index.tpl',
|
template: 'src/assets/template/app/index.tpl',
|
||||||
}),
|
}),
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
inject: 'head',
|
||||||
|
chunks: ['window'],
|
||||||
|
filename: 'window.html',
|
||||||
|
template: 'src/assets/template/app/window.tpl',
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue