mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
This commit is contained in:
parent
fd98963038
commit
575a151b89
5 changed files with 80 additions and 19 deletions
|
|
@ -861,6 +861,15 @@ app.whenReady().then(() => {
|
||||||
globalShortcut.unregister(hotKey2Electron(data.accelerator));
|
globalShortcut.unregister(hotKey2Electron(data.accelerator));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "setTrafficLightPosition":
|
||||||
|
if (!currentWindow) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (new URL(currentWindow.getURL()).pathname === "/stage/build/app/window.html") {
|
||||||
|
data.position.y += 5 * data.zoom;
|
||||||
|
}
|
||||||
|
currentWindow.setWindowButtonPosition(data.position);
|
||||||
|
break;
|
||||||
case "show":
|
case "show":
|
||||||
if (!currentWindow) {
|
if (!currentWindow) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,11 @@ export const onGetConfig = (isStart: boolean, app: App) => {
|
||||||
port: location.port
|
port: location.port
|
||||||
});
|
});
|
||||||
webFrame.setZoomFactor(window.siyuan.storage[Constants.LOCAL_ZOOM]);
|
webFrame.setZoomFactor(window.siyuan.storage[Constants.LOCAL_ZOOM]);
|
||||||
|
ipcRenderer.send(Constants.SIYUAN_CMD, {
|
||||||
|
cmd: "setTrafficLightPosition",
|
||||||
|
zoom: window.siyuan.storage[Constants.LOCAL_ZOOM],
|
||||||
|
position: Constants.SIZE_ZOOM.find((item) => item.zoom === window.siyuan.storage[Constants.LOCAL_ZOOM]).position
|
||||||
|
});
|
||||||
/// #endif
|
/// #endif
|
||||||
if (!window.siyuan.config.uiLayout || (window.siyuan.config.uiLayout && !window.siyuan.config.uiLayout.left)) {
|
if (!window.siyuan.config.uiLayout || (window.siyuan.config.uiLayout && !window.siyuan.config.uiLayout.left)) {
|
||||||
window.siyuan.config.uiLayout = Constants.SIYUAN_EMPTY_LAYOUT;
|
window.siyuan.config.uiLayout = Constants.SIYUAN_EMPTY_LAYOUT;
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,45 @@ export abstract class Constants {
|
||||||
public static readonly SIZE_UNDO = 64;
|
public static readonly SIZE_UNDO = 64;
|
||||||
public static readonly SIZE_TITLE = 512;
|
public static readonly SIZE_TITLE = 512;
|
||||||
public static readonly SIZE_EDITOR_WIDTH = 760;
|
public static readonly SIZE_EDITOR_WIDTH = 760;
|
||||||
public static readonly SIZE_ZOOM = [0.25, 0.33, 0.5, 0.67, 0.75, 0.8, 0.9, 1, 1.1, 1.25, 1.5, 1.75, 2, 2.5, 3];
|
public static readonly SIZE_ZOOM = [
|
||||||
|
{
|
||||||
|
zoom: 0.67,
|
||||||
|
position: {x: 0, y: 2}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
zoom: 0.75,
|
||||||
|
position: {x: 1, y: 4}
|
||||||
|
}, {
|
||||||
|
zoom: 0.8,
|
||||||
|
position: {x: 2, y: 4}
|
||||||
|
}, {
|
||||||
|
zoom: 0.9,
|
||||||
|
position: {x: 5, y: 6}
|
||||||
|
}, {
|
||||||
|
zoom: 1,
|
||||||
|
position: {x: 8, y: 8}
|
||||||
|
}, {
|
||||||
|
zoom: 1.1,
|
||||||
|
position: {x: 12, y: 9}
|
||||||
|
}, {
|
||||||
|
zoom: 1.25,
|
||||||
|
position: {x: 18, y: 12}
|
||||||
|
}, {
|
||||||
|
zoom: 1.5,
|
||||||
|
position: {x: 27, y: 16}
|
||||||
|
}, {
|
||||||
|
zoom: 1.75,
|
||||||
|
position: {x: 36, y: 20}
|
||||||
|
}, {
|
||||||
|
zoom: 2,
|
||||||
|
position: {x: 45, y: 23}
|
||||||
|
}, {
|
||||||
|
zoom: 2.5,
|
||||||
|
position: {x: 63, y: 31}
|
||||||
|
}, {
|
||||||
|
zoom: 3,
|
||||||
|
position: {x: 80, y: 39}
|
||||||
|
}];
|
||||||
|
|
||||||
// ws callback
|
// ws callback
|
||||||
public static readonly CB_MOVE_NOLIST = "cb-move-nolist";
|
public static readonly CB_MOVE_NOLIST = "cb-move-nolist";
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import {openSetting} from "../config";
|
||||||
import {openSearch} from "../search/spread";
|
import {openSearch} from "../search/spread";
|
||||||
import {App} from "../index";
|
import {App} from "../index";
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
import {webFrame} from "electron";
|
import {ipcRenderer, webFrame} from "electron";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {isBrowser, isWindow} from "../util/functions";
|
import {isBrowser, isWindow} from "../util/functions";
|
||||||
|
|
@ -262,39 +262,43 @@ export const initBar = (app: App) => {
|
||||||
|
|
||||||
export const setZoom = (type: "zoomIn" | "zoomOut" | "restore") => {
|
export const setZoom = (type: "zoomIn" | "zoomOut" | "restore") => {
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
const isTabWindow = isWindow();
|
|
||||||
let zoom = 1;
|
let zoom = 1;
|
||||||
if (type === "zoomIn") {
|
if (type === "zoomIn") {
|
||||||
Constants.SIZE_ZOOM.find((item, index) => {
|
Constants.SIZE_ZOOM.find((item, index) => {
|
||||||
if (item === window.siyuan.storage[Constants.LOCAL_ZOOM]) {
|
if (item.zoom === window.siyuan.storage[Constants.LOCAL_ZOOM]) {
|
||||||
zoom = Constants.SIZE_ZOOM[index + 1] || 3;
|
zoom = Constants.SIZE_ZOOM[index + 1]?.zoom || 3;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (type === "zoomOut") {
|
} else if (type === "zoomOut") {
|
||||||
Constants.SIZE_ZOOM.find((item, index) => {
|
Constants.SIZE_ZOOM.find((item, index) => {
|
||||||
if (item === window.siyuan.storage[Constants.LOCAL_ZOOM]) {
|
if (item.zoom === window.siyuan.storage[Constants.LOCAL_ZOOM]) {
|
||||||
zoom = Constants.SIZE_ZOOM[index - 1] || 0.25;
|
zoom = Constants.SIZE_ZOOM[index - 1]?.zoom || 0.67;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
webFrame.setZoomFactor(zoom);
|
webFrame.setZoomFactor(zoom);
|
||||||
|
ipcRenderer.send(Constants.SIYUAN_CMD, {
|
||||||
|
cmd: "setTrafficLightPosition",
|
||||||
|
zoom,
|
||||||
|
position: Constants.SIZE_ZOOM.find((item) => item.zoom === zoom).position
|
||||||
|
});
|
||||||
window.siyuan.storage[Constants.LOCAL_ZOOM] = zoom;
|
window.siyuan.storage[Constants.LOCAL_ZOOM] = zoom;
|
||||||
if (!isTabWindow) {
|
setStorageVal(Constants.LOCAL_ZOOM, zoom);
|
||||||
setStorageVal(Constants.LOCAL_ZOOM, zoom);
|
if (!isWindow()) {
|
||||||
}
|
const barZoomElement = document.getElementById("barZoom");
|
||||||
const barZoomElement = document.getElementById("barZoom");
|
if (zoom === 1) {
|
||||||
if (zoom === 1) {
|
barZoomElement.classList.add("fn__none");
|
||||||
barZoomElement.classList.add("fn__none");
|
|
||||||
} else {
|
|
||||||
if (zoom > 1) {
|
|
||||||
barZoomElement.querySelector("use").setAttribute("xlink:href", "#iconZoomIn");
|
|
||||||
} else {
|
} else {
|
||||||
barZoomElement.querySelector("use").setAttribute("xlink:href", "#iconZoomOut");
|
if (zoom > 1) {
|
||||||
|
barZoomElement.querySelector("use").setAttribute("xlink:href", "#iconZoomIn");
|
||||||
|
} else {
|
||||||
|
barZoomElement.querySelector("use").setAttribute("xlink:href", "#iconZoomOut");
|
||||||
|
}
|
||||||
|
barZoomElement.classList.remove("fn__none");
|
||||||
}
|
}
|
||||||
barZoomElement.classList.remove("fn__none");
|
|
||||||
}
|
}
|
||||||
/// #endif
|
/// #endif
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {webFrame} from "electron";
|
import {ipcRenderer, webFrame} from "electron";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
import {adjustLayout, getInstanceById, JSONToCenter} from "../layout/util";
|
import {adjustLayout, getInstanceById, JSONToCenter} from "../layout/util";
|
||||||
import {resizeTabs} from "../layout/tabUtil";
|
import {resizeTabs} from "../layout/tabUtil";
|
||||||
|
|
@ -16,6 +16,11 @@ import {initWindowEvent} from "../boot/globalEvent/event";
|
||||||
|
|
||||||
export const init = (app: App) => {
|
export const init = (app: App) => {
|
||||||
webFrame.setZoomFactor(window.siyuan.storage[Constants.LOCAL_ZOOM]);
|
webFrame.setZoomFactor(window.siyuan.storage[Constants.LOCAL_ZOOM]);
|
||||||
|
ipcRenderer.send(Constants.SIYUAN_CMD, {
|
||||||
|
cmd: "setTrafficLightPosition",
|
||||||
|
zoom: window.siyuan.storage[Constants.LOCAL_ZOOM],
|
||||||
|
position: Constants.SIZE_ZOOM.find((item) => item.zoom === window.siyuan.storage[Constants.LOCAL_ZOOM]).position
|
||||||
|
});
|
||||||
initWindowEvent(app);
|
initWindowEvent(app);
|
||||||
fetchPost("/api/system/getEmojiConf", {}, response => {
|
fetchPost("/api/system/getEmojiConf", {}, response => {
|
||||||
window.siyuan.emojis = response.data as IEmoji[];
|
window.siyuan.emojis = response.data as IEmoji[];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue