mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
This commit is contained in:
parent
aa5acf39cf
commit
f600cc1bde
4 changed files with 31 additions and 29 deletions
|
|
@ -705,17 +705,26 @@ app.whenReady().then(() => {
|
||||||
let webContentsId = event.sender.id
|
let webContentsId = event.sender.id
|
||||||
if (typeof data !== "string") {
|
if (typeof data !== "string") {
|
||||||
cmd = data.cmd;
|
cmd = data.cmd;
|
||||||
webContentsId = data.webContentsId
|
if (data.webContentsId) {
|
||||||
|
webContentsId = data.webContentsId
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
const currentWindow = getWindowByContentId(webContentsId);
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case "openDevTools":
|
case "openDevTools":
|
||||||
event.sender.openDevTools({mode: "bottom"});
|
event.sender.openDevTools({mode: "bottom"});
|
||||||
break;
|
break;
|
||||||
case "show":
|
case "show":
|
||||||
showWindow(getWindowByContentId(webContentsId));
|
showWindow(currentWindow);
|
||||||
break;
|
break;
|
||||||
case "hide":
|
case "hide":
|
||||||
getWindowByContentId(webContentsId).hide();
|
currentWindow.hide();
|
||||||
|
break;
|
||||||
|
case "focus":
|
||||||
|
currentWindow.focus();
|
||||||
|
break;
|
||||||
|
case "clearCache":
|
||||||
|
event.sender.session.clearCache();
|
||||||
break;
|
break;
|
||||||
case "redo":
|
case "redo":
|
||||||
event.sender.redo();
|
event.sender.redo();
|
||||||
|
|
@ -724,7 +733,14 @@ app.whenReady().then(() => {
|
||||||
event.sender.undo();
|
event.sender.undo();
|
||||||
break;
|
break;
|
||||||
case "destroy":
|
case "destroy":
|
||||||
getWindowByContentId(webContentsId).destroy();
|
currentWindow.destroy();
|
||||||
|
break;
|
||||||
|
case "setProxy":
|
||||||
|
event.sender.session.closeAllConnections().then(() => {
|
||||||
|
event.sender.session.setProxy({proxyRules: data.proxyURL}).then(() => {
|
||||||
|
console.log("network proxy [" + data.proxyURL + "]");
|
||||||
|
});
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
import {getCurrentWindow} from "@electron/remote";
|
import {ipcRenderer} from "electron";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {Dialog} from "../../dialog";
|
import {Dialog} from "../../dialog";
|
||||||
import {isMobile} from "../../util/functions";
|
import {isMobile} from "../../util/functions";
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
|
import {Constants} from "../../constants";
|
||||||
|
|
||||||
export const setProxy = () => {
|
export const setProxy = () => {
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
|
|
@ -11,13 +12,9 @@ export const setProxy = () => {
|
||||||
console.log("network proxy [system]");
|
console.log("network proxy [system]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ipcRenderer.send(Constants.SIYUAN_CMD, {
|
||||||
const session = getCurrentWindow().webContents.session;
|
cmd: "setProxy",
|
||||||
session.closeAllConnections().then(() => {
|
proxyURL: `${window.siyuan.config.system.networkProxy.scheme}://${window.siyuan.config.system.networkProxy.host}:${window.siyuan.config.system.networkProxy.port}`
|
||||||
const proxyURL = `${window.siyuan.config.system.networkProxy.scheme}://${window.siyuan.config.system.networkProxy.host}:${window.siyuan.config.system.networkProxy.port}`;
|
|
||||||
session.setProxy({proxyRules: proxyURL}).then(
|
|
||||||
() => console.log("network proxy [" + proxyURL + "]"),
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
/// #endif
|
/// #endif
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName} from "../
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
import {webFrame, ipcRenderer} from "electron";
|
import {webFrame, ipcRenderer} from "electron";
|
||||||
import {getCurrentWindow} from "@electron/remote";
|
|
||||||
import {setModelsHash, setTabPosition} from "../window/setHeader";
|
import {setModelsHash, setTabPosition} from "../window/setHeader";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {Search} from "../search";
|
import {Search} from "../search";
|
||||||
|
|
@ -123,17 +122,6 @@ export class Wnd {
|
||||||
if (window.siyuan.config.fileTree.openFilesUseCurrentTab && target.getAttribute("data-type") === "tab-header") {
|
if (window.siyuan.config.fileTree.openFilesUseCurrentTab && target.getAttribute("data-type") === "tab-header") {
|
||||||
target.classList.remove("item--unupdate");
|
target.classList.remove("item--unupdate");
|
||||||
break;
|
break;
|
||||||
} else if (target.tagName === "SPAN" && target.className === "fn__flex-1" &&
|
|
||||||
isWindow() && this.headersElement.getBoundingClientRect().top <= 0) {
|
|
||||||
/// #if !BROWSER
|
|
||||||
const currentWindow = getCurrentWindow();
|
|
||||||
if (currentWindow.isMaximized()) {
|
|
||||||
currentWindow.unmaximize();
|
|
||||||
} else {
|
|
||||||
currentWindow.maximize();
|
|
||||||
}
|
|
||||||
/// #endif
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
target = target.parentElement;
|
target = target.parentElement;
|
||||||
}
|
}
|
||||||
|
|
@ -237,7 +225,7 @@ export class Wnd {
|
||||||
ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "closetab", data: tabData.id});
|
ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "closetab", data: tabData.id});
|
||||||
it.querySelector("li[data-clone='true']").remove();
|
it.querySelector("li[data-clone='true']").remove();
|
||||||
wnd.switchTab(oldTab.headElement);
|
wnd.switchTab(oldTab.headElement);
|
||||||
getCurrentWindow().focus();
|
ipcRenderer.send(Constants.SIYUAN_CMD, "focus");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// #endif
|
/// #endif
|
||||||
|
|
@ -344,7 +332,7 @@ export class Wnd {
|
||||||
JSONToCenter(app, tabData, this);
|
JSONToCenter(app, tabData, this);
|
||||||
oldTab = this.children[this.children.length - 1];
|
oldTab = this.children[this.children.length - 1];
|
||||||
ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "closetab", data: tabData.id});
|
ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "closetab", data: tabData.id});
|
||||||
getCurrentWindow().focus();
|
ipcRenderer.send(Constants.SIYUAN_CMD, "focus");
|
||||||
}
|
}
|
||||||
/// #endif
|
/// #endif
|
||||||
if (!oldTab) {
|
if (!oldTab) {
|
||||||
|
|
@ -791,7 +779,7 @@ export class Wnd {
|
||||||
}
|
}
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
webFrame.clearCache();
|
webFrame.clearCache();
|
||||||
getCurrentWindow().webContents.session.clearCache();
|
ipcRenderer.send(Constants.SIYUAN_CMD, "clearCache");
|
||||||
setTabPosition();
|
setTabPosition();
|
||||||
/// #endif
|
/// #endif
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import {App} from "../index";
|
import {App} from "../index";
|
||||||
import {getCurrentWindow} from "@electron/remote";
|
import {Constants} from "../constants";
|
||||||
|
import { ipcRenderer } from "electron";
|
||||||
|
|
||||||
export const closeWindow = async (app: App) => {
|
export const closeWindow = async (app: App) => {
|
||||||
for (let i = 0; i < app.plugins.length; i++) {
|
for (let i = 0; i < app.plugins.length; i++) {
|
||||||
|
|
@ -9,5 +10,5 @@ export const closeWindow = async (app: App) => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getCurrentWindow().destroy();
|
ipcRenderer.send(Constants.SIYUAN_CMD, "destroy");
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue