mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-21 11:30:42 +08:00
This commit is contained in:
parent
a86c4d346b
commit
e9bb0a9a06
@ -8,7 +8,7 @@ import {
|
||||
hasTopClosestByClassName,
|
||||
hasTopClosestByTag,
|
||||
} from "../protyle/util/hasClosest";
|
||||
import {newFile} from "./newFile";
|
||||
import {newFile} from "../util/newFile";
|
||||
import {Constants} from "../constants";
|
||||
import {openSetting} from "../config";
|
||||
import {getDockByType, getInstanceById} from "../layout/util";
|
||||
@ -17,12 +17,12 @@ import {Editor} from "../editor";
|
||||
import {setEditMode} from "../protyle/util/setEditMode";
|
||||
import {rename} from "../editor/rename";
|
||||
import {Files} from "../layout/dock/Files";
|
||||
import {newDailyNote} from "./mount";
|
||||
import {newDailyNote} from "../util/mount";
|
||||
import {hideAllElements, hideElements} from "../protyle/ui/hideElements";
|
||||
import {fetchPost} from "./fetch";
|
||||
import {goBack, goForward} from "./backForward";
|
||||
import {fetchPost} from "../util/fetch";
|
||||
import {goBack, goForward} from "../util/backForward";
|
||||
import {onGet} from "../protyle/util/onGet";
|
||||
import {getDisplayName, getNotebookName, getTopPaths, movePathTo, moveToPath} from "./pathName";
|
||||
import {getDisplayName, getNotebookName, getTopPaths, movePathTo, moveToPath} from "../util/pathName";
|
||||
import {openFileById} from "../editor/util";
|
||||
import {getAllDocks, getAllModels, getAllTabs} from "../layout/getAll";
|
||||
import {openGlobalSearch} from "../search/util";
|
||||
@ -34,7 +34,7 @@ import {showMessage} from "../dialog/message";
|
||||
import {Dialog} from "../dialog";
|
||||
import {unicode2Emoji} from "../emoji";
|
||||
import {deleteFiles} from "../editor/deleteFile";
|
||||
import {escapeHtml} from "./escape";
|
||||
import {escapeHtml} from "../util/escape";
|
||||
import {syncGuide} from "../sync/syncGuide";
|
||||
import {showPopover} from "../block/popover";
|
||||
import {getStartEndElement} from "../protyle/wysiwyg/commonHotkey";
|
||||
@ -48,7 +48,7 @@ import {webFrame} from "electron";
|
||||
import {openHistory} from "../history/history";
|
||||
import {openCard} from "../card/openCard";
|
||||
import {lockScreen} from "../dialog/processSystem";
|
||||
import {isWindow} from "./functions";
|
||||
import {isWindow} from "../util/functions";
|
||||
import {reloadProtyle} from "../protyle/util/reload";
|
||||
import {fullscreen} from "../protyle/breadcrumb/action";
|
||||
import {setPadding} from "../protyle/ui/initUI";
|
@ -10,19 +10,21 @@ import {onWindowsMsg} from "../window/onWindowsMsg";
|
||||
/// #endif
|
||||
import {Constants} from "../constants";
|
||||
import {appearance} from "../config/appearance";
|
||||
import {globalShortcut} from "./globalShortcut";
|
||||
import {fetchPost, fetchSyncPost} from "./fetch";
|
||||
import {addGA, initAssets, setInlineStyle} from "./assets";
|
||||
import {globalShortcut} from "../boot/globalShortcut";
|
||||
import {fetchPost, fetchSyncPost} from "../util/fetch";
|
||||
import {addGA, initAssets, setInlineStyle} from "../util/assets";
|
||||
import {renderSnippet} from "../config/util/snippets";
|
||||
import {openFileById} from "../editor/util";
|
||||
import {focusByRange} from "../protyle/util/selection";
|
||||
import {exitSiYuan} from "../dialog/processSystem";
|
||||
import {getSearch, isWindow} from "./functions";
|
||||
import {getSearch, isWindow} from "../util/functions";
|
||||
import {initStatus} from "../layout/status";
|
||||
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/setProxy";
|
||||
import {openChangelog} from "./openChangelog";
|
||||
|
||||
const matchKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => {
|
||||
if (key1 === "general") {
|
||||
@ -81,23 +83,6 @@ const hasKeymap = (keymap: Record<string, IKeymapItem>, key1: "general" | "edito
|
||||
return match;
|
||||
};
|
||||
|
||||
export const setProxy = () => {
|
||||
/// #if !BROWSER
|
||||
if ("" === window.siyuan.config.system.networkProxy.scheme) {
|
||||
console.log("network proxy [system]");
|
||||
return;
|
||||
}
|
||||
|
||||
const session = getCurrentWindow().webContents.session;
|
||||
session.closeAllConnections().then(() => {
|
||||
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
|
||||
};
|
||||
|
||||
export const onGetConfig = (isStart: boolean) => {
|
||||
const matchKeymap1 = matchKeymap(Constants.SIYUAN_KEYMAP.general, "general");
|
||||
const matchKeymap2 = matchKeymap(Constants.SIYUAN_KEYMAP.editor.general, "editor", "general");
|
||||
@ -149,6 +134,7 @@ export const onGetConfig = (isStart: boolean) => {
|
||||
window.siyuan.emojis = response.data as IEmoji[];
|
||||
try {
|
||||
JSONToLayout(isStart);
|
||||
openChangelog();
|
||||
if (window.JSAndroid) {
|
||||
window.openFileByURL(window.JSAndroid.getBlockURL());
|
||||
}
|
||||
@ -157,6 +143,7 @@ export const onGetConfig = (isStart: boolean) => {
|
||||
}
|
||||
});
|
||||
initBar();
|
||||
setProxy();
|
||||
initStatus();
|
||||
initWindow();
|
||||
appearance.onSetappearance(window.siyuan.config.appearance);
|
19
app/src/boot/openChangelog.ts
Normal file
19
app/src/boot/openChangelog.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import {fetchPost} from "../util/fetch";
|
||||
import {Dialog} from "../dialog";
|
||||
import {highlightRender} from "../protyle/markdown/highlightRender";
|
||||
import {isMobile} from "../util/functions";
|
||||
import {Constants} from "../constants";
|
||||
|
||||
export const openChangelog = () => {
|
||||
fetchPost("/api/system/getChangelog", {}, (response) => {
|
||||
if (!response.data.show) {
|
||||
return;
|
||||
}
|
||||
const dialog = new Dialog({
|
||||
title: `v${Constants.SIYUAN_VERSION} ${window.siyuan.languages.update}`,
|
||||
width: isMobile() ? "80vw" : "520px",
|
||||
content: `<div class="b3-dialog__content b3-typography b3-typography--default">${response.data.html}</div>`
|
||||
});
|
||||
highlightRender(dialog.element);
|
||||
});
|
||||
}
|
@ -11,7 +11,7 @@ import {openByMobile, writeText} from "../protyle/util/compatibility";
|
||||
import {showMessage} from "../dialog/message";
|
||||
import {Dialog} from "../dialog";
|
||||
import {confirmDialog} from "../dialog/confirmDialog";
|
||||
import {setProxy} from "../util/onGetConfig";
|
||||
import { setProxy } from "./util/setProxy";
|
||||
|
||||
export const about = {
|
||||
element: undefined as Element,
|
||||
|
20
app/src/config/util/setProxy.ts
Normal file
20
app/src/config/util/setProxy.ts
Normal file
@ -0,0 +1,20 @@
|
||||
/// #if !BROWSER
|
||||
import {getCurrentWindow} from "@electron/remote";
|
||||
/// #endif
|
||||
|
||||
export const setProxy = () => {
|
||||
/// #if !BROWSER
|
||||
if ("" === window.siyuan.config.system.networkProxy.scheme) {
|
||||
console.log("network proxy [system]");
|
||||
return;
|
||||
}
|
||||
|
||||
const session = getCurrentWindow().webContents.session;
|
||||
session.closeAllConnections().then(() => {
|
||||
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
|
||||
};
|
@ -1,7 +1,7 @@
|
||||
import {Constants} from "./constants";
|
||||
import {Menus} from "./menus";
|
||||
import {Model} from "./layout/Model";
|
||||
import {onGetConfig} from "./util/onGetConfig";
|
||||
import {onGetConfig} from "./boot/onGetConfig";
|
||||
import "./assets/scss/base.scss";
|
||||
import {initBlockPopover} from "./block/popover";
|
||||
import {account} from "./config/account";
|
||||
|
@ -9,7 +9,6 @@ import {MenuItem} from "../menus/Menu";
|
||||
import {setMode} from "../util/assets";
|
||||
import {openSetting} from "../config";
|
||||
import {openSearch} from "../search/spread";
|
||||
import {setProxy} from "../util/onGetConfig";
|
||||
|
||||
export const updateEditModeElement = () => {
|
||||
const target = document.querySelector("#barReadonly");
|
||||
@ -23,6 +22,7 @@ export const updateEditModeElement = () => {
|
||||
target.querySelector("use").setAttribute("xlink:href", "#iconEdit");
|
||||
}
|
||||
};
|
||||
|
||||
export const initBar = () => {
|
||||
const toolbarElement = document.getElementById("toolbar");
|
||||
toolbarElement.innerHTML = `
|
||||
@ -126,5 +126,4 @@ export const initBar = () => {
|
||||
target = target.parentElement;
|
||||
}
|
||||
});
|
||||
setProxy();
|
||||
};
|
||||
|
@ -20,6 +20,7 @@ import {getLocalStorage} from "../protyle/util/compatibility";
|
||||
import {openMobileFileById} from "./editor";
|
||||
import {getSearch} from "../util/functions";
|
||||
import {initRightMenu} from "./menu";
|
||||
import {openChangelog} from "../boot/openChangelog";
|
||||
|
||||
class App {
|
||||
constructor() {
|
||||
@ -65,6 +66,7 @@ class App {
|
||||
window.siyuan.emojis = emojiResponse.data as IEmoji[];
|
||||
initFramework();
|
||||
initRightMenu();
|
||||
openChangelog();
|
||||
});
|
||||
});
|
||||
addGA();
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {Constants} from "../constants";
|
||||
import {webFrame} from "electron";
|
||||
import {globalShortcut} from "../util/globalShortcut";
|
||||
import {globalShortcut} from "../boot/globalShortcut";
|
||||
import {fetchPost} from "../util/fetch";
|
||||
import {JSONToCenter, resizeTabs} from "../layout/util";
|
||||
import {initStatus} from "../layout/status";
|
||||
@ -8,7 +8,7 @@ import {appearance} from "../config/appearance";
|
||||
import {initAssets, setInlineStyle} from "../util/assets";
|
||||
import {renderSnippet} from "../config/util/snippets";
|
||||
import {getSearch} from "../util/functions";
|
||||
import {initWindow} from "../util/onGetConfig";
|
||||
import {initWindow} from "../boot/onGetConfig";
|
||||
|
||||
export const init = () => {
|
||||
webFrame.setZoomFactor(window.siyuan.storage[Constants.LOCAL_ZOOM]);
|
||||
|
Loading…
Reference in New Issue
Block a user