🎨 选择全部后预览界面删除后台报错

This commit is contained in:
Vanessa 2023-02-25 13:43:55 +08:00
parent 5f875e9db2
commit b77026c704
2 changed files with 6 additions and 8 deletions

View file

@ -125,13 +125,9 @@ export const openCardByData = (cardsData: ICard[], html = "") => {
const viewElement = hasClosestByAttribute(event.target as HTMLElement, "data-type", "view");
if (viewElement) {
if (selectElement) {
viewCards(selectElement.value, selectElement.options[selectElement.selectedIndex].text, (removeResponse) => {
countElement.lastElementChild.lastElementChild.innerHTML = removeResponse.data.size.toString();
});
viewCards(selectElement.value, selectElement.options[selectElement.selectedIndex].text);
} else {
viewCards(titleElement.getAttribute("data-id"), titleElement.textContent, (removeResponse) => {
countElement.lastElementChild.lastElementChild.innerHTML = removeResponse.data.size.toString();
}, true);
viewCards(titleElement.getAttribute("data-id"), titleElement.textContent, undefined, true);
}
event.preventDefault();
event.stopPropagation();

View file

@ -10,7 +10,7 @@ import {addLoading} from "../protyle/ui/initUI";
import {Constants} from "../constants";
import {disabledProtyle, onGet} from "../protyle/util/onGet";
export const viewCards = (deckID: string, title: string, cb:(response:IWebSocketData)=>void,isDoc = false) => {
export const viewCards = (deckID: string, title: string, cb?: (response: IWebSocketData) => void, isDoc = false) => {
let pageIndex = 1;
let edit: Protyle;
fetchPost(isDoc ? "/api/riff/getTreeRiffCards" : "/api/riff/getRiffCards", {
@ -139,7 +139,9 @@ export const viewCards = (deckID: string, title: string, cb:(response:IWebSocket
nextElment.classList.add("b3-list-item--focus");
target.parentElement.remove();
}
cb(removeResponse);
if (cb) {
cb(removeResponse);
}
});
event.stopPropagation();
event.preventDefault();