mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-04 20:00:17 +01:00
This commit is contained in:
parent
8c02c2cb93
commit
448b04abf8
6 changed files with 34 additions and 28 deletions
|
|
@ -240,13 +240,7 @@ export const lockScreen = (app: App) => {
|
|||
app.plugins.forEach(item => {
|
||||
item.eventBus.emit("lock-screen");
|
||||
});
|
||||
/// #if BROWSER
|
||||
fetchPost("/api/system/logoutAuth", {}, () => {
|
||||
redirectToCheckAuth();
|
||||
});
|
||||
/// #else
|
||||
ipcRenderer.send(Constants.SIYUAN_SEND_WINDOWS, {cmd: "lockscreen"});
|
||||
/// #endif
|
||||
fetchPost("/api/system/logoutAuth");
|
||||
};
|
||||
|
||||
export const kernelError = () => {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import {account} from "./config/account";
|
|||
import {addScript, addScriptSync} from "./protyle/util/addScript";
|
||||
import {genUUID} from "./util/genID";
|
||||
import {fetchGet, fetchPost} from "./util/fetch";
|
||||
import {addBaseURL, getIdFromSYProtocol, isSYProtocol, setNoteBook} from "./util/pathName";
|
||||
import {addBaseURL, getIdFromSYProtocol, isSYProtocol, redirectToCheckAuth, setNoteBook} from "./util/pathName";
|
||||
import {registerServiceWorker} from "./util/serviceWorker";
|
||||
import {openFileById} from "./editor/util";
|
||||
import {
|
||||
|
|
@ -75,6 +75,9 @@ export class App {
|
|||
});
|
||||
if (data) {
|
||||
switch (data.cmd) {
|
||||
case "logoutAuth":
|
||||
redirectToCheckAuth();
|
||||
break;
|
||||
case "setAppearance":
|
||||
updateAppearance(data.data);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import {reloadEmoji} from "../../emoji";
|
|||
import {setLocalShorthandCount} from "../../util/noRelyPCFunction";
|
||||
import {updateControlAlt} from "../../protyle/util/hotKey";
|
||||
import {renderSnippet} from "../../config/util/snippets";
|
||||
import {redirectToCheckAuth} from "../../util/pathName";
|
||||
|
||||
let statusTimeout: number;
|
||||
const statusElement = document.querySelector("#status") as HTMLElement;
|
||||
|
|
@ -18,6 +19,9 @@ const statusElement = document.querySelector("#status") as HTMLElement;
|
|||
export const onMessage = (app: App, data: IWebSocketData) => {
|
||||
if (data) {
|
||||
switch (data.cmd) {
|
||||
case "logoutAuth":
|
||||
redirectToCheckAuth();
|
||||
break;
|
||||
case "sendDeviceNotification":
|
||||
if (window.JSAndroid.sendNotification) {
|
||||
window.JSAndroid.sendNotification(data.data.title, data.data.body);
|
||||
|
|
|
|||
|
|
@ -9,11 +9,15 @@ import {Constants} from "../constants";
|
|||
/// #if !BROWSER
|
||||
import {ipcRenderer} from "electron";
|
||||
/// #endif
|
||||
/// #if !MOBILE
|
||||
import {exportLayout} from "../layout/util";
|
||||
/// #endif
|
||||
import {showMessage} from "../dialog/message";
|
||||
import {isOnlyMeta, isWindows, setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";
|
||||
import {matchHotKey} from "../protyle/util/hotKey";
|
||||
import {Menu} from "../plugin/Menu";
|
||||
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
||||
import {saveScroll} from "../protyle/scroll/saveScroll";
|
||||
|
||||
export const useShell = (cmd: "showItemInFolder" | "openPath", filePath: string) => {
|
||||
/// #if !BROWSER
|
||||
|
|
@ -60,11 +64,26 @@ export const getIdFromSYProtocol = (url: string) => {
|
|||
};
|
||||
|
||||
/* redirect to auth page */
|
||||
export const redirectToCheckAuth = (to: string = window.location.href) => {
|
||||
export const redirectToCheckAuth = async (to: string = window.location.href) => {
|
||||
/// #if !MOBILE
|
||||
exportLayout({
|
||||
errorExit: false,
|
||||
cb() {
|
||||
const url = new URL(window.location.origin);
|
||||
url.pathname = "/check-auth";
|
||||
url.searchParams.set("to", to);
|
||||
window.location.href = url.href;
|
||||
}
|
||||
});
|
||||
/// #else
|
||||
if (window.siyuan.mobile.editor) {
|
||||
await saveScroll(window.siyuan.mobile.editor.protyle);
|
||||
}
|
||||
const url = new URL(window.location.origin);
|
||||
url.pathname = "/check-auth";
|
||||
url.searchParams.set("to", to);
|
||||
window.location.href = url.href;
|
||||
/// #endif
|
||||
};
|
||||
|
||||
export const addBaseURL = () => {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import {initBlockPopover} from "../block/popover";
|
|||
import {addScript, addScriptSync} from "../protyle/util/addScript";
|
||||
import {genUUID} from "../util/genID";
|
||||
import {fetchGet, fetchPost} from "../util/fetch";
|
||||
import {addBaseURL, setNoteBook} from "../util/pathName";
|
||||
import {addBaseURL, redirectToCheckAuth, setNoteBook} from "../util/pathName";
|
||||
import {openFileById} from "../editor/util";
|
||||
import {
|
||||
processSync,
|
||||
|
|
@ -58,6 +58,9 @@ class App {
|
|||
});
|
||||
if (data) {
|
||||
switch (data.cmd) {
|
||||
case "logoutAuth":
|
||||
redirectToCheckAuth();
|
||||
break;
|
||||
case "setAppearance":
|
||||
updateAppearance(data.data);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -36,26 +36,9 @@ export const onWindowsMsg = (ipcData: IWebSocketData) => {
|
|||
});
|
||||
}
|
||||
break;
|
||||
case "lockscreen":
|
||||
exportLayout({
|
||||
errorExit: false,
|
||||
cb() {
|
||||
fetchPost("/api/system/logoutAuth", {}, () => {
|
||||
redirectToCheckAuth();
|
||||
});
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "lockscreenByMode":
|
||||
if (window.siyuan.config.system.lockScreenMode === 1) {
|
||||
exportLayout({
|
||||
errorExit: false,
|
||||
cb() {
|
||||
fetchPost("/api/system/logoutAuth", {}, () => {
|
||||
redirectToCheckAuth();
|
||||
});
|
||||
}
|
||||
});
|
||||
redirectToCheckAuth();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue