mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
This commit is contained in:
parent
08c66696f8
commit
4116583c15
8 changed files with 52 additions and 2 deletions
|
|
@ -368,7 +368,7 @@ const initMainWindow = () => {
|
|||
|
||||
if (-1 < details.url.toLowerCase().indexOf("youtube")) {
|
||||
// YouTube 设置 Referer https://github.com/siyuan-note/siyuan/issues/16319
|
||||
details.requestHeaders["Referer"] = 'https://b3log.org/siyuan/';
|
||||
details.requestHeaders["Referer"] = "https://b3log.org/siyuan/";
|
||||
cb({requestHeaders: details.requestHeaders});
|
||||
return;
|
||||
}
|
||||
|
|
@ -1048,6 +1048,25 @@ app.whenReady().then(() => {
|
|||
ipcMain.on("siyuan-quit", (event, port) => {
|
||||
exitApp(port);
|
||||
});
|
||||
ipcMain.on("siyuan-reload-window", (event, port) => {
|
||||
BrowserWindow.getAllWindows().forEach((item) => {
|
||||
try {
|
||||
const currentURL = new URL(item.getURL());
|
||||
if (port.toString() === currentURL.port.toString()) {
|
||||
const hasMain = workspaces.find((workspaceItem) => {
|
||||
if (workspaceItem.browserWindow.id === item.id) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (!hasMain) {
|
||||
item.reload();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// load file is not a url
|
||||
}
|
||||
});
|
||||
});
|
||||
ipcMain.on("siyuan-show-window", (event) => {
|
||||
const mainWindow = getWindowByContentId(event.sender.id);
|
||||
if (!mainWindow) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import {resetFloatDockSize} from "../layout/dock/util";
|
|||
import {confirmDialog} from "../dialog/confirmDialog";
|
||||
import {useShell} from "../util/pathName";
|
||||
import {Dialog} from "../dialog";
|
||||
import {reloadOtherWindow} from "../dialog/processSystem";
|
||||
|
||||
export const appearance = {
|
||||
element: undefined as Element,
|
||||
|
|
@ -207,6 +208,13 @@ export const appearance = {
|
|||
msgTaskHistoryGenerateFileDisabled: statusBar ? statusBar.msgTaskHistoryGenerateFileDisabled : window.siyuan.config.appearance.statusBar.msgTaskHistoryGenerateFileDisabled,
|
||||
}
|
||||
}, async response => {
|
||||
if (response.data.mode !== window.siyuan.config.appearance.mode ||
|
||||
(response.data.mode === window.siyuan.config.appearance.mode && (
|
||||
(response.data.mode === 0 && window.siyuan.config.appearance.themeLight !== response.data.themeLight) ||
|
||||
(response.data.mode === 1 && window.siyuan.config.appearance.themeDark !== response.data.themeDark))
|
||||
) || response.data.lang !== window.siyuan.config.appearance.lang) {
|
||||
reloadOtherWindow();
|
||||
}
|
||||
if (window.siyuan.config.appearance.themeJS) {
|
||||
if (response.data.mode !== window.siyuan.config.appearance.mode ||
|
||||
(response.data.mode === window.siyuan.config.appearance.mode && (
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import {afterLoadPlugin, loadPlugin, loadPlugins, reloadPlugin} from "../plugin/
|
|||
import {loadAssets} from "../util/assets";
|
||||
import {addScript} from "../protyle/util/addScript";
|
||||
import {useShell} from "../util/pathName";
|
||||
import {reloadOtherWindow} from "../dialog/processSystem";
|
||||
|
||||
export const bazaar = {
|
||||
element: undefined as Element,
|
||||
|
|
@ -857,6 +858,7 @@ export const bazaar = {
|
|||
response.data.appearance = appearanceResponse.data;
|
||||
bazaar._onBazaar(response, "icons", true);
|
||||
bazaar._data.icons = response.data.packages;
|
||||
reloadOtherWindow();
|
||||
});
|
||||
});
|
||||
} else if (bazaarType === "themes") {
|
||||
|
|
@ -866,6 +868,7 @@ export const bazaar = {
|
|||
themeDark: mode === 1 ? packageName : window.siyuan.config.appearance.themeDark,
|
||||
themeLight: mode === 0 ? packageName : window.siyuan.config.appearance.themeLight,
|
||||
}), async (appearanceResponse) => {
|
||||
reloadOtherWindow();
|
||||
if ((mode !== window.siyuan.config.appearance.mode ||
|
||||
(mode === 1 && window.siyuan.config.appearance.themeDark !== packageName) ||
|
||||
(mode === 0 && window.siyuan.config.appearance.themeLight !== packageName)) &&
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import {Dialog} from "../../dialog";
|
|||
import {objEquals} from "../../util/functions";
|
||||
import {confirmDialog} from "../../dialog/confirmDialog";
|
||||
import {Constants} from "../../constants";
|
||||
import {reloadOtherWindow} from "../../dialog/processSystem";
|
||||
|
||||
export const renderSnippet = () => {
|
||||
fetchPost("/api/snippet/getSnippet", {type: "all", enabled: 2}, (response) => {
|
||||
|
|
@ -224,7 +225,9 @@ const setSnippetPost = (dialog: Dialog, snippets: ISnippet[], removeIds: string[
|
|||
});
|
||||
window.siyuan.config.snippet.enabledCSS = (dialog.element.querySelector('.b3-switch[data-action="toggleCSS"]') as HTMLInputElement).checked;
|
||||
window.siyuan.config.snippet.enabledJS = (dialog.element.querySelector('.b3-switch[data-action="toggleJS"]') as HTMLInputElement).checked;
|
||||
fetchPost("/api/setting/setSnippet", window.siyuan.config.snippet);
|
||||
fetchPost("/api/setting/setSnippet", window.siyuan.config.snippet, () => {
|
||||
reloadOtherWindow();
|
||||
});
|
||||
renderSnippet();
|
||||
dialog.destroy({cancel: "true"});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ export abstract class Constants {
|
|||
public static readonly SIYUAN_CONTEXT_MENU: string = "siyuan-context-menu";
|
||||
|
||||
public static readonly SIYUAN_SHOW_WINDOW: string = "siyuan-show-window";
|
||||
public static readonly SIYUAN_RELOAD_WINDOW: string = "siyuan-reload-window";
|
||||
|
||||
// custom
|
||||
public static readonly CUSTOM_SY_READONLY: string = "custom-sy-readonly";
|
||||
|
|
|
|||
|
|
@ -280,6 +280,12 @@ export const kernelError = () => {
|
|||
}
|
||||
};
|
||||
|
||||
export const reloadOtherWindow = () => {
|
||||
/// #if !BROWSER
|
||||
ipcRenderer.send(Constants.SIYUAN_RELOAD_WINDOW, location.port);
|
||||
/// #endif
|
||||
};
|
||||
|
||||
export const exitSiYuan = async () => {
|
||||
hideAllElements(["util"]);
|
||||
/// #if MOBILE
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import {fetchPost} from "../../util/fetch";
|
||||
import {genLangOptions, genOptions} from "../../util/genOptions";
|
||||
import {openModel} from "../menu/model";
|
||||
import {reloadOtherWindow} from "../../dialog/processSystem";
|
||||
|
||||
export const initAppearance = () => {
|
||||
openModel({
|
||||
|
|
@ -55,6 +56,7 @@ export const initAppearance = () => {
|
|||
themeLight: (modelMainElement.querySelector("#themeLight") as HTMLSelectElement).value,
|
||||
lang: (modelMainElement.querySelector("#lang") as HTMLSelectElement).value,
|
||||
}), () => {
|
||||
reloadOtherWindow();
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import {exportLayout} from "../layout/util";
|
|||
import {fetchPost} from "./fetch";
|
||||
import {appearance} from "../config/appearance";
|
||||
import {isInAndroid, isInHarmony, isInIOS, isIPad, isIPhone, isMac, isWin11} from "../protyle/util/compatibility";
|
||||
import {reloadOtherWindow} from "../dialog/processSystem";
|
||||
|
||||
export const loadAssets = (data: Config.IAppearance) => {
|
||||
const htmlElement = document.getElementsByTagName("html")[0];
|
||||
|
|
@ -371,6 +372,13 @@ export const setMode = (modeElementValue: number) => {
|
|||
mode,
|
||||
modeOS: modeElementValue === 2,
|
||||
}), async response => {
|
||||
if (response.data.mode !== window.siyuan.config.appearance.mode ||
|
||||
(response.data.mode === window.siyuan.config.appearance.mode && (
|
||||
(response.data.mode === 0 && window.siyuan.config.appearance.themeLight !== response.data.themeLight) ||
|
||||
(response.data.mode === 1 && window.siyuan.config.appearance.themeDark !== response.data.themeDark))
|
||||
)) {
|
||||
reloadOtherWindow();
|
||||
}
|
||||
if (window.siyuan.config.appearance.themeJS) {
|
||||
if (response.data.mode !== window.siyuan.config.appearance.mode ||
|
||||
(response.data.mode === window.siyuan.config.appearance.mode && (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue