mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 07:30:12 +01:00
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();
|
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) => {
|
const hotKey2Electron = (key) => {
|
||||||
if (!key) {
|
if (!key) {
|
||||||
return key;
|
return key;
|
||||||
|
|
@ -287,6 +296,16 @@ const boot = () => {
|
||||||
windowStateInitialized ? currentWindow.setPosition(x, y) : currentWindow.center();
|
windowStateInitialized ? currentWindow.setPosition(x, y) : currentWindow.center();
|
||||||
currentWindow.webContents.userAgent = "SiYuan/" + appVer + " https://b3log.org/siyuan Electron " + currentWindow.webContents.userAgent;
|
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"]);
|
currentWindow.webContents.session.setSpellCheckerLanguages(["en-US"]);
|
||||||
|
|
||||||
// 发起互联网服务请求时绕过安全策略 https://github.com/siyuan-note/siyuan/issues/5516
|
// 发起互联网服务请求时绕过安全策略 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 productName = "SiYuan";
|
||||||
const template = [{
|
const template = [{
|
||||||
|
|
@ -687,6 +703,9 @@ app.whenReady().then(() => {
|
||||||
if (data.cmd === "showOpenDialog") {
|
if (data.cmd === "showOpenDialog") {
|
||||||
return dialog.showOpenDialog(data);
|
return dialog.showOpenDialog(data);
|
||||||
}
|
}
|
||||||
|
if (data.cmd === "setProxy") {
|
||||||
|
return setProxy(data.proxyURL, event.sender);
|
||||||
|
}
|
||||||
if (data.cmd === "showSaveDialog") {
|
if (data.cmd === "showSaveDialog") {
|
||||||
return dialog.showSaveDialog(data);
|
return dialog.showSaveDialog(data);
|
||||||
}
|
}
|
||||||
|
|
@ -819,19 +838,6 @@ app.whenReady().then(() => {
|
||||||
currentWindow.hide();
|
currentWindow.hide();
|
||||||
}
|
}
|
||||||
break;
|
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) => {
|
ipcMain.on("siyuan-config-tray", (event, data) => {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ import {showMessage} from "../dialog/message";
|
||||||
import {replaceLocalPath} from "../editor/rename";
|
import {replaceLocalPath} from "../editor/rename";
|
||||||
import {setTabPosition} from "../window/setHeader";
|
import {setTabPosition} from "../window/setHeader";
|
||||||
import {initBar} from "../layout/topBar";
|
import {initBar} from "../layout/topBar";
|
||||||
import {setProxy} from "../config/util/about";
|
|
||||||
import {openChangelog} from "./openChangelog";
|
import {openChangelog} from "./openChangelog";
|
||||||
import {getIdFromSYProtocol, isSYProtocol} from "../util/pathName";
|
import {getIdFromSYProtocol, isSYProtocol} from "../util/pathName";
|
||||||
import {App} from "../index";
|
import {App} from "../index";
|
||||||
|
|
@ -135,7 +134,6 @@ export const onGetConfig = (isStart: boolean, app: App) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
initBar(app);
|
initBar(app);
|
||||||
setProxy();
|
|
||||||
initStatus();
|
initStatus();
|
||||||
initWindow(app);
|
initWindow(app);
|
||||||
appearance.onSetappearance(window.siyuan.config.appearance);
|
appearance.onSetappearance(window.siyuan.config.appearance);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import {ipcRenderer, shell} from "electron";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {isBrowser} from "../util/functions";
|
import {isBrowser} from "../util/functions";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
import {setAccessAuthCode, setProxy} from "./util/about";
|
import {setAccessAuthCode} from "./util/about";
|
||||||
import {exportLayout} from "../layout/util";
|
import {exportLayout} from "../layout/util";
|
||||||
import {exitSiYuan, processSync} from "../dialog/processSystem";
|
import {exitSiYuan, processSync} from "../dialog/processSystem";
|
||||||
import {isInAndroid, isInIOS, isIPad, openByMobile, writeText} from "../protyle/util/compatibility";
|
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 scheme = (about.element.querySelector("#aboutScheme") as HTMLInputElement).value;
|
||||||
const host = (about.element.querySelector("#aboutHost") as HTMLInputElement).value;
|
const host = (about.element.querySelector("#aboutHost") as HTMLInputElement).value;
|
||||||
const port = (about.element.querySelector("#aboutPort") 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.scheme = scheme;
|
||||||
window.siyuan.config.system.networkProxy.host = host;
|
window.siyuan.config.system.networkProxy.host = host;
|
||||||
window.siyuan.config.system.networkProxy.port = port;
|
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 {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 = () => {
|
|
||||||
/// #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 = () => {
|
export const setAccessAuthCode = () => {
|
||||||
const dialog = new Dialog({
|
const dialog = new Dialog({
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ export const setEmpty = (app: App) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setEditor = () => {
|
export const setEditor = () => {
|
||||||
const toolbarNameElement = document.getElementById("toolbarName") as HTMLInputElement
|
const toolbarNameElement = document.getElementById("toolbarName") as HTMLInputElement;
|
||||||
setTitle(toolbarNameElement.value);
|
setTitle(toolbarNameElement.value);
|
||||||
toolbarNameElement.classList.remove("fn__hidden");
|
toolbarNameElement.classList.remove("fn__hidden");
|
||||||
document.getElementById("editor").classList.remove("fn__none");
|
document.getElementById("editor").classList.remove("fn__none");
|
||||||
|
|
|
||||||
|
|
@ -94,17 +94,17 @@ id="preview"></div>
|
||||||
// https://github.com/siyuan-note/siyuan/issues/9685
|
// https://github.com/siyuan-note/siyuan/issues/9685
|
||||||
previewElement.querySelectorAll('[data-type~="mark"]').forEach((markItem: HTMLElement) => {
|
previewElement.querySelectorAll('[data-type~="mark"]').forEach((markItem: HTMLElement) => {
|
||||||
markItem.childNodes.forEach((item) => {
|
markItem.childNodes.forEach((item) => {
|
||||||
let spanHTML = ""
|
let spanHTML = "";
|
||||||
Array.from(item.textContent).forEach(str => {
|
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");
|
const templateElement = document.createElement("template");
|
||||||
templateElement.innerHTML = spanHTML;
|
templateElement.innerHTML = spanHTML;
|
||||||
item.after(templateElement.content);
|
item.after(templateElement.content);
|
||||||
item.remove();
|
item.remove();
|
||||||
})
|
});
|
||||||
if (markItem.childNodes.length > 0) {
|
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");
|
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) {
|
if (name === inputElement.value || !inputElement.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let hasName = false
|
let hasName = false;
|
||||||
data.view.columns.find(column => {
|
data.view.columns.find(column => {
|
||||||
if (column.id === colId) {
|
if (column.id === colId) {
|
||||||
column.options.find((item) => {
|
column.options.find((item) => {
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ export const blockRender = (protyle: IProtyle, element: Element, top?: number) =
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
renderEmbed([], protyle, item, top);
|
renderEmbed([], protyle, item, top);
|
||||||
})
|
});
|
||||||
} else if (Array.isArray(includeIDs)) {
|
} else if (Array.isArray(includeIDs)) {
|
||||||
fetchPost("/api/search/getEmbedBlock", {
|
fetchPost("/api/search/getEmbedBlock", {
|
||||||
embedBlockID: item.getAttribute("data-node-id"),
|
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],
|
excludeIDs: [item.getAttribute("data-node-id"), protyle.block.rootID],
|
||||||
breadcrumb
|
breadcrumb
|
||||||
}, (response) => {
|
}, (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 = "";
|
item.style.height = "";
|
||||||
}
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue