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")) {
|
if (-1 < details.url.toLowerCase().indexOf("youtube")) {
|
||||||
// YouTube 设置 Referer https://github.com/siyuan-note/siyuan/issues/16319
|
// 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});
|
cb({requestHeaders: details.requestHeaders});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1048,6 +1048,25 @@ app.whenReady().then(() => {
|
||||||
ipcMain.on("siyuan-quit", (event, port) => {
|
ipcMain.on("siyuan-quit", (event, port) => {
|
||||||
exitApp(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) => {
|
ipcMain.on("siyuan-show-window", (event) => {
|
||||||
const mainWindow = getWindowByContentId(event.sender.id);
|
const mainWindow = getWindowByContentId(event.sender.id);
|
||||||
if (!mainWindow) {
|
if (!mainWindow) {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import {resetFloatDockSize} from "../layout/dock/util";
|
||||||
import {confirmDialog} from "../dialog/confirmDialog";
|
import {confirmDialog} from "../dialog/confirmDialog";
|
||||||
import {useShell} from "../util/pathName";
|
import {useShell} from "../util/pathName";
|
||||||
import {Dialog} from "../dialog";
|
import {Dialog} from "../dialog";
|
||||||
|
import {reloadOtherWindow} from "../dialog/processSystem";
|
||||||
|
|
||||||
export const appearance = {
|
export const appearance = {
|
||||||
element: undefined as Element,
|
element: undefined as Element,
|
||||||
|
|
@ -207,6 +208,13 @@ export const appearance = {
|
||||||
msgTaskHistoryGenerateFileDisabled: statusBar ? statusBar.msgTaskHistoryGenerateFileDisabled : window.siyuan.config.appearance.statusBar.msgTaskHistoryGenerateFileDisabled,
|
msgTaskHistoryGenerateFileDisabled: statusBar ? statusBar.msgTaskHistoryGenerateFileDisabled : window.siyuan.config.appearance.statusBar.msgTaskHistoryGenerateFileDisabled,
|
||||||
}
|
}
|
||||||
}, async response => {
|
}, 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 (window.siyuan.config.appearance.themeJS) {
|
||||||
if (response.data.mode !== window.siyuan.config.appearance.mode ||
|
if (response.data.mode !== window.siyuan.config.appearance.mode ||
|
||||||
(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 {loadAssets} from "../util/assets";
|
||||||
import {addScript} from "../protyle/util/addScript";
|
import {addScript} from "../protyle/util/addScript";
|
||||||
import {useShell} from "../util/pathName";
|
import {useShell} from "../util/pathName";
|
||||||
|
import {reloadOtherWindow} from "../dialog/processSystem";
|
||||||
|
|
||||||
export const bazaar = {
|
export const bazaar = {
|
||||||
element: undefined as Element,
|
element: undefined as Element,
|
||||||
|
|
@ -857,6 +858,7 @@ export const bazaar = {
|
||||||
response.data.appearance = appearanceResponse.data;
|
response.data.appearance = appearanceResponse.data;
|
||||||
bazaar._onBazaar(response, "icons", true);
|
bazaar._onBazaar(response, "icons", true);
|
||||||
bazaar._data.icons = response.data.packages;
|
bazaar._data.icons = response.data.packages;
|
||||||
|
reloadOtherWindow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else if (bazaarType === "themes") {
|
} else if (bazaarType === "themes") {
|
||||||
|
|
@ -866,6 +868,7 @@ export const bazaar = {
|
||||||
themeDark: mode === 1 ? packageName : window.siyuan.config.appearance.themeDark,
|
themeDark: mode === 1 ? packageName : window.siyuan.config.appearance.themeDark,
|
||||||
themeLight: mode === 0 ? packageName : window.siyuan.config.appearance.themeLight,
|
themeLight: mode === 0 ? packageName : window.siyuan.config.appearance.themeLight,
|
||||||
}), async (appearanceResponse) => {
|
}), async (appearanceResponse) => {
|
||||||
|
reloadOtherWindow();
|
||||||
if ((mode !== window.siyuan.config.appearance.mode ||
|
if ((mode !== window.siyuan.config.appearance.mode ||
|
||||||
(mode === 1 && window.siyuan.config.appearance.themeDark !== packageName) ||
|
(mode === 1 && window.siyuan.config.appearance.themeDark !== packageName) ||
|
||||||
(mode === 0 && window.siyuan.config.appearance.themeLight !== packageName)) &&
|
(mode === 0 && window.siyuan.config.appearance.themeLight !== packageName)) &&
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import {Dialog} from "../../dialog";
|
||||||
import {objEquals} from "../../util/functions";
|
import {objEquals} from "../../util/functions";
|
||||||
import {confirmDialog} from "../../dialog/confirmDialog";
|
import {confirmDialog} from "../../dialog/confirmDialog";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
|
import {reloadOtherWindow} from "../../dialog/processSystem";
|
||||||
|
|
||||||
export const renderSnippet = () => {
|
export const renderSnippet = () => {
|
||||||
fetchPost("/api/snippet/getSnippet", {type: "all", enabled: 2}, (response) => {
|
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.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;
|
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();
|
renderSnippet();
|
||||||
dialog.destroy({cancel: "true"});
|
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_CONTEXT_MENU: string = "siyuan-context-menu";
|
||||||
|
|
||||||
public static readonly SIYUAN_SHOW_WINDOW: string = "siyuan-show-window";
|
public static readonly SIYUAN_SHOW_WINDOW: string = "siyuan-show-window";
|
||||||
|
public static readonly SIYUAN_RELOAD_WINDOW: string = "siyuan-reload-window";
|
||||||
|
|
||||||
// custom
|
// custom
|
||||||
public static readonly CUSTOM_SY_READONLY: string = "custom-sy-readonly";
|
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 () => {
|
export const exitSiYuan = async () => {
|
||||||
hideAllElements(["util"]);
|
hideAllElements(["util"]);
|
||||||
/// #if MOBILE
|
/// #if MOBILE
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
import {genLangOptions, genOptions} from "../../util/genOptions";
|
import {genLangOptions, genOptions} from "../../util/genOptions";
|
||||||
import {openModel} from "../menu/model";
|
import {openModel} from "../menu/model";
|
||||||
|
import {reloadOtherWindow} from "../../dialog/processSystem";
|
||||||
|
|
||||||
export const initAppearance = () => {
|
export const initAppearance = () => {
|
||||||
openModel({
|
openModel({
|
||||||
|
|
@ -55,6 +56,7 @@ export const initAppearance = () => {
|
||||||
themeLight: (modelMainElement.querySelector("#themeLight") as HTMLSelectElement).value,
|
themeLight: (modelMainElement.querySelector("#themeLight") as HTMLSelectElement).value,
|
||||||
lang: (modelMainElement.querySelector("#lang") as HTMLSelectElement).value,
|
lang: (modelMainElement.querySelector("#lang") as HTMLSelectElement).value,
|
||||||
}), () => {
|
}), () => {
|
||||||
|
reloadOtherWindow();
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import {exportLayout} from "../layout/util";
|
||||||
import {fetchPost} from "./fetch";
|
import {fetchPost} from "./fetch";
|
||||||
import {appearance} from "../config/appearance";
|
import {appearance} from "../config/appearance";
|
||||||
import {isInAndroid, isInHarmony, isInIOS, isIPad, isIPhone, isMac, isWin11} from "../protyle/util/compatibility";
|
import {isInAndroid, isInHarmony, isInIOS, isIPad, isIPhone, isMac, isWin11} from "../protyle/util/compatibility";
|
||||||
|
import {reloadOtherWindow} from "../dialog/processSystem";
|
||||||
|
|
||||||
export const loadAssets = (data: Config.IAppearance) => {
|
export const loadAssets = (data: Config.IAppearance) => {
|
||||||
const htmlElement = document.getElementsByTagName("html")[0];
|
const htmlElement = document.getElementsByTagName("html")[0];
|
||||||
|
|
@ -371,6 +372,13 @@ export const setMode = (modeElementValue: number) => {
|
||||||
mode,
|
mode,
|
||||||
modeOS: modeElementValue === 2,
|
modeOS: modeElementValue === 2,
|
||||||
}), async response => {
|
}), 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 (window.siyuan.config.appearance.themeJS) {
|
||||||
if (response.data.mode !== window.siyuan.config.appearance.mode ||
|
if (response.data.mode !== window.siyuan.config.appearance.mode ||
|
||||||
(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