This commit is contained in:
Vanessa 2023-02-26 11:45:50 +08:00
parent 69139f530d
commit 990b31dc00
4 changed files with 21 additions and 16 deletions

View file

@ -760,9 +760,9 @@ app.whenReady().then(() => {
}, },
}); });
win.loadURL(data.url); win.loadURL(data.url);
const targetScreen = screen.getDisplayNearestPoint(screen.getCursorScreenPoint()) const targetScreen = screen.getDisplayNearestPoint(screen.getCursorScreenPoint());
if (mainScreen.id !== targetScreen.id) { if (mainScreen.id !== targetScreen.id) {
win.setBounds(targetScreen.workArea) win.setBounds(targetScreen.workArea);
} }
require("@electron/remote/main").enable(win.webContents); require("@electron/remote/main").enable(win.webContents);
}); });

View file

@ -150,7 +150,7 @@ export const openCardByData = (cardsData: ICard[], html = "") => {
type = "3"; type = "3";
} else if (event.detail === " ") { } else if (event.detail === " ") {
type = "-1"; type = "-1";
}else if (event.detail === "p") { } else if (event.detail === "p") {
type = "-2"; type = "-2";
} }
} }
@ -167,6 +167,9 @@ export const openCardByData = (cardsData: ICard[], html = "") => {
event.stopPropagation(); event.stopPropagation();
hideElements(["toolbar", "hint", "util"], editor.protyle); hideElements(["toolbar", "hint", "util"], editor.protyle);
if (type === "-1") { if (type === "-1") {
if (actionElements[0].classList.contains("fn__none")) {
return;
}
editor.protyle.element.classList.remove("card__block--hide"); editor.protyle.element.classList.remove("card__block--hide");
actionElements[0].classList.add("fn__none"); actionElements[0].classList.add("fn__none");
actionElements[1].querySelectorAll(".b3-button").forEach((element, btnIndex) => { actionElements[1].querySelectorAll(".b3-button").forEach((element, btnIndex) => {
@ -176,6 +179,9 @@ export const openCardByData = (cardsData: ICard[], html = "") => {
return; return;
} }
if (type === "-2") { if (type === "-2") {
if (actionElements[0].classList.contains("fn__none")) {
return;
}
if (index > 0) { if (index > 0) {
index--; index--;
editor.protyle.element.classList.add("card__block--hide"); editor.protyle.element.classList.add("card__block--hide");
@ -185,11 +191,11 @@ export const openCardByData = (cardsData: ICard[], html = "") => {
actionElements, actionElements,
index, index,
blocks blocks
}) });
} }
return; return;
} }
if (["0", "1", "2", "3"].includes(type)) { if (["0", "1", "2", "3"].includes(type) && actionElements[0].classList.contains("fn__none")) {
fetchPost("/api/riff/reviewRiffCard", { fetchPost("/api/riff/reviewRiffCard", {
deckID: blocks[index].deckID, deckID: blocks[index].deckID,
cardID: blocks[index].cardID, cardID: blocks[index].cardID,
@ -202,10 +208,10 @@ export const openCardByData = (cardsData: ICard[], html = "") => {
rootID: titleElement.getAttribute("data-id"), rootID: titleElement.getAttribute("data-id"),
deckID: selectElement?.value deckID: selectElement?.value
}, (treeCards) => { }, (treeCards) => {
index = 0 index = 0;
blocks = treeCards.data blocks = treeCards.data;
if (treeCards.data.length === 0) { if (treeCards.data.length === 0) {
allDone(countElement, editor, actionElements) allDone(countElement, editor, actionElements);
} else { } else {
nextCard({ nextCard({
countElement, countElement,
@ -213,7 +219,7 @@ export const openCardByData = (cardsData: ICard[], html = "") => {
actionElements, actionElements,
index, index,
blocks blocks
}) });
} }
}); });
return; return;
@ -224,7 +230,7 @@ export const openCardByData = (cardsData: ICard[], html = "") => {
actionElements, actionElements,
index, index,
blocks blocks
}) });
}); });
} }
}); });
@ -243,9 +249,9 @@ export const openCardByData = (cardsData: ICard[], html = "") => {
actionElements, actionElements,
index, index,
blocks blocks
}) });
} else { } else {
allDone(countElement, editor, actionElements) allDone(countElement, editor, actionElements);
} }
}); });
}); });
@ -262,7 +268,7 @@ const nextCard = (options: {
options.countElement.classList.remove("fn__none"); options.countElement.classList.remove("fn__none");
if (options.index === 0) { if (options.index === 0) {
options.actionElements[0].firstElementChild.setAttribute("disabled", "disabled"); options.actionElements[0].firstElementChild.setAttribute("disabled", "disabled");
} else{ } else {
options.actionElements[0].firstElementChild.removeAttribute("disabled"); options.actionElements[0].firstElementChild.removeAttribute("disabled");
} }
fetchPost("/api/filetree/getDoc", { fetchPost("/api/filetree/getDoc", {
@ -272,7 +278,7 @@ const nextCard = (options: {
}, (response) => { }, (response) => {
onGet(response, options.editor.protyle, [Constants.CB_GET_ALL, Constants.CB_GET_HTML]); onGet(response, options.editor.protyle, [Constants.CB_GET_ALL, Constants.CB_GET_HTML]);
}); });
} };
const allDone = (countElement: Element, editor: Protyle, actionElements: NodeListOf<Element>) => { const allDone = (countElement: Element, editor: Protyle, actionElements: NodeListOf<Element>) => {
countElement.classList.add("fn__none"); countElement.classList.add("fn__none");

View file

@ -21,7 +21,6 @@ import {hideElements} from "../ui/hideElements";
import {fetchPost} from "../../util/fetch"; import {fetchPost} from "../../util/fetch";
import {getDisplayName, pathPosix} from "../../util/pathName"; import {getDisplayName, pathPosix} from "../../util/pathName";
import {addEmoji, filterEmoji, lazyLoadEmoji, lazyLoadEmojiImg, unicode2Emoji} from "../../emoji"; import {addEmoji, filterEmoji, lazyLoadEmoji, lazyLoadEmojiImg, unicode2Emoji} from "../../emoji";
import {escapeHtml} from "../../util/escape";
import {blockRender} from "../markdown/blockRender"; import {blockRender} from "../markdown/blockRender";
import {uploadFiles} from "../upload"; import {uploadFiles} from "../upload";
/// #if !MOBILE /// #if !MOBILE

View file

@ -88,7 +88,7 @@ const switchDialogEvent = (event: MouseEvent, switchDialog: Dialog) => {
}; };
export const globalShortcut = () => { export const globalShortcut = () => {
document.body.addEventListener("mouseleave", (event) => { document.body.addEventListener("mouseleave", () => {
window.siyuan.layout.leftDock.hideDock(); window.siyuan.layout.leftDock.hideDock();
window.siyuan.layout.rightDock.hideDock(); window.siyuan.layout.rightDock.hideDock();
window.siyuan.layout.bottomDock.hideDock(); window.siyuan.layout.bottomDock.hideDock();