This commit is contained in:
parent
7cbf14a42f
commit
69a795b99b
8 changed files with 46 additions and 44 deletions
|
@ -52,6 +52,15 @@ try {
|
|||
app.exit();
|
||||
}
|
||||
|
||||
const setProxy = (proxyURL, webContents) => {
|
||||
if (proxyURL.startsWith("://")) {
|
||||
console.log("network proxy [system]");
|
||||
return webContents.session.setProxy({mode: "system"});
|
||||
}
|
||||
console.log("network proxy [" + proxyURL + "]");
|
||||
return webContents.session.setProxy({proxyRules: proxyURL});
|
||||
};
|
||||
|
||||
const hotKey2Electron = (key) => {
|
||||
if (!key) {
|
||||
return key;
|
||||
|
@ -287,6 +296,16 @@ const boot = () => {
|
|||
windowStateInitialized ? currentWindow.setPosition(x, y) : currentWindow.center();
|
||||
currentWindow.webContents.userAgent = "SiYuan/" + appVer + " https://b3log.org/siyuan Electron " + currentWindow.webContents.userAgent;
|
||||
|
||||
// set proxy
|
||||
net.fetch(getServer() + "/api/system/getConf", {method: "POST"}).then((response) => {
|
||||
return response.json();
|
||||
}).then((response) => {
|
||||
setProxy(`${response.data.conf.system.networkProxy.scheme}://${response.data.conf.system.networkProxy.host}:${response.data.conf.system.networkProxy.port}`, currentWindow.webContents).then(() => {
|
||||
// 加载主界面
|
||||
currentWindow.loadURL(getServer() + "/stage/build/app/index.html?v=" + new Date().getTime());
|
||||
});
|
||||
});
|
||||
|
||||
currentWindow.webContents.session.setSpellCheckerLanguages(["en-US"]);
|
||||
|
||||
// 发起互联网服务请求时绕过安全策略 https://github.com/siyuan-note/siyuan/issues/5516
|
||||
|
@ -351,9 +370,6 @@ const boot = () => {
|
|||
}
|
||||
});
|
||||
|
||||
// 加载主界面
|
||||
currentWindow.loadURL(getServer() + "/stage/build/app/index.html?v=" + new Date().getTime());
|
||||
|
||||
// 菜单
|
||||
const productName = "SiYuan";
|
||||
const template = [{
|
||||
|
@ -687,6 +703,9 @@ app.whenReady().then(() => {
|
|||
if (data.cmd === "showOpenDialog") {
|
||||
return dialog.showOpenDialog(data);
|
||||
}
|
||||
if (data.cmd === "setProxy") {
|
||||
return setProxy(data.proxyURL, event.sender);
|
||||
}
|
||||
if (data.cmd === "showSaveDialog") {
|
||||
return dialog.showSaveDialog(data);
|
||||
}
|
||||
|
@ -819,19 +838,6 @@ app.whenReady().then(() => {
|
|||
currentWindow.hide();
|
||||
}
|
||||
break;
|
||||
case "setProxy":
|
||||
event.sender.session.closeAllConnections().then(() => {
|
||||
if (data.proxyURL.startsWith("://")) {
|
||||
event.sender.session.setProxy({mode: "system"}).then(() => {
|
||||
console.log("network proxy [system]");
|
||||
});
|
||||
return;
|
||||
}
|
||||
event.sender.session.setProxy({proxyRules: data.proxyURL}).then(() => {
|
||||
console.log("network proxy [" + data.proxyURL + "]");
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
});
|
||||
ipcMain.on("siyuan-config-tray", (event, data) => {
|
||||
|
|
|
@ -22,7 +22,6 @@ import {showMessage} from "../dialog/message";
|
|||
import {replaceLocalPath} from "../editor/rename";
|
||||
import {setTabPosition} from "../window/setHeader";
|
||||
import {initBar} from "../layout/topBar";
|
||||
import {setProxy} from "../config/util/about";
|
||||
import {openChangelog} from "./openChangelog";
|
||||
import {getIdFromSYProtocol, isSYProtocol} from "../util/pathName";
|
||||
import {App} from "../index";
|
||||
|
@ -135,7 +134,6 @@ export const onGetConfig = (isStart: boolean, app: App) => {
|
|||
}
|
||||
});
|
||||
initBar(app);
|
||||
setProxy();
|
||||
initStatus();
|
||||
initWindow(app);
|
||||
appearance.onSetappearance(window.siyuan.config.appearance);
|
||||
|
|
|
@ -4,7 +4,7 @@ import {ipcRenderer, shell} from "electron";
|
|||
/// #endif
|
||||
import {isBrowser} from "../util/functions";
|
||||
import {fetchPost} from "../util/fetch";
|
||||
import {setAccessAuthCode, setProxy} from "./util/about";
|
||||
import {setAccessAuthCode} from "./util/about";
|
||||
import {exportLayout} from "../layout/util";
|
||||
import {exitSiYuan, processSync} from "../dialog/processSystem";
|
||||
import {isInAndroid, isInIOS, isIPad, openByMobile, writeText} from "../protyle/util/compatibility";
|
||||
|
@ -359,11 +359,22 @@ export const about = {
|
|||
const scheme = (about.element.querySelector("#aboutScheme") as HTMLInputElement).value;
|
||||
const host = (about.element.querySelector("#aboutHost") as HTMLInputElement).value;
|
||||
const port = (about.element.querySelector("#aboutPort") as HTMLInputElement).value;
|
||||
fetchPost("/api/system/setNetworkProxy", {scheme, host, port}, () => {
|
||||
fetchPost("/api/system/setNetworkProxy", {scheme, host, port}, async () => {
|
||||
window.siyuan.config.system.networkProxy.scheme = scheme;
|
||||
window.siyuan.config.system.networkProxy.host = host;
|
||||
window.siyuan.config.system.networkProxy.port = port;
|
||||
setProxy();
|
||||
/// #if !BROWSER
|
||||
ipcRenderer.invoke(Constants.SIYUAN_GET, {
|
||||
cmd: "setProxy",
|
||||
proxyURL: `${window.siyuan.config.system.networkProxy.scheme}://${window.siyuan.config.system.networkProxy.host}:${window.siyuan.config.system.networkProxy.port}`,
|
||||
}).then(() => {
|
||||
exportLayout({
|
||||
reload: true,
|
||||
onlyData: false,
|
||||
errorExit: false,
|
||||
});
|
||||
});
|
||||
/// #endif
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,19 +1,6 @@
|
|||
/// #if !BROWSER
|
||||
import {ipcRenderer} from "electron";
|
||||
/// #endif
|
||||
import {Dialog} from "../../dialog";
|
||||
import {isMobile} from "../../util/functions";
|
||||
import {fetchPost} from "../../util/fetch";
|
||||
import {Constants} from "../../constants";
|
||||
|
||||
export const setProxy = () => {
|
||||
/// #if !BROWSER
|
||||
ipcRenderer.send(Constants.SIYUAN_CMD, {
|
||||
cmd: "setProxy",
|
||||
proxyURL: `${window.siyuan.config.system.networkProxy.scheme}://${window.siyuan.config.system.networkProxy.host}:${window.siyuan.config.system.networkProxy.port}`
|
||||
});
|
||||
/// #endif
|
||||
};
|
||||
|
||||
export const setAccessAuthCode = () => {
|
||||
const dialog = new Dialog({
|
||||
|
|
|
@ -77,7 +77,7 @@ export const setEmpty = (app: App) => {
|
|||
};
|
||||
|
||||
export const setEditor = () => {
|
||||
const toolbarNameElement = document.getElementById("toolbarName") as HTMLInputElement
|
||||
const toolbarNameElement = document.getElementById("toolbarName") as HTMLInputElement;
|
||||
setTitle(toolbarNameElement.value);
|
||||
toolbarNameElement.classList.remove("fn__hidden");
|
||||
document.getElementById("editor").classList.remove("fn__none");
|
||||
|
|
|
@ -94,17 +94,17 @@ id="preview"></div>
|
|||
// https://github.com/siyuan-note/siyuan/issues/9685
|
||||
previewElement.querySelectorAll('[data-type~="mark"]').forEach((markItem: HTMLElement) => {
|
||||
markItem.childNodes.forEach((item) => {
|
||||
let spanHTML = ""
|
||||
let spanHTML = "";
|
||||
Array.from(item.textContent).forEach(str => {
|
||||
spanHTML += `<span data-type="mark">${str}</span>`
|
||||
})
|
||||
spanHTML += `<span data-type="mark">${str}</span>`;
|
||||
});
|
||||
const templateElement = document.createElement("template");
|
||||
templateElement.innerHTML = spanHTML;
|
||||
item.after(templateElement.content);
|
||||
item.remove();
|
||||
})
|
||||
});
|
||||
if (markItem.childNodes.length > 0) {
|
||||
markItem.setAttribute("data-type", markItem.getAttribute("data-type").replace("mark", ""))
|
||||
markItem.setAttribute("data-type", markItem.getAttribute("data-type").replace("mark", ""));
|
||||
}
|
||||
});
|
||||
previewElement.setAttribute("data-doc-type", response.data.type || "NodeDocument");
|
||||
|
|
|
@ -121,7 +121,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement,
|
|||
if (name === inputElement.value || !inputElement.value) {
|
||||
return;
|
||||
}
|
||||
let hasName = false
|
||||
let hasName = false;
|
||||
data.view.columns.find(column => {
|
||||
if (column.id === colId) {
|
||||
column.options.find((item) => {
|
||||
|
|
|
@ -60,7 +60,7 @@ export const blockRender = (protyle: IProtyle, element: Element, top?: number) =
|
|||
}
|
||||
}).catch(() => {
|
||||
renderEmbed([], protyle, item, top);
|
||||
})
|
||||
});
|
||||
} else if (Array.isArray(includeIDs)) {
|
||||
fetchPost("/api/search/getEmbedBlock", {
|
||||
embedBlockID: item.getAttribute("data-node-id"),
|
||||
|
@ -85,7 +85,7 @@ export const blockRender = (protyle: IProtyle, element: Element, top?: number) =
|
|||
excludeIDs: [item.getAttribute("data-node-id"), protyle.block.rootID],
|
||||
breadcrumb
|
||||
}, (response) => {
|
||||
renderEmbed(response.data.blocks, protyle, item, top)
|
||||
renderEmbed(response.data.blocks, protyle, item, top);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -135,4 +135,4 @@ const renderEmbed = (blocks: {
|
|||
});
|
||||
}
|
||||
item.style.height = "";
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue