🐛 数据库加载更多后的操作

This commit is contained in:
Vanessa 2023-12-19 17:02:10 +08:00
parent c9eed7c86d
commit c301a4ac0a

View File

@ -13,7 +13,7 @@ import {previewImage} from "../../preview/image";
import {genAVValueHTML} from "./blockAttr"; import {genAVValueHTML} from "./blockAttr";
import {hideMessage, showMessage} from "../../../dialog/message"; import {hideMessage, showMessage} from "../../../dialog/message";
import {fetchPost} from "../../../util/fetch"; import {fetchPost} from "../../../util/fetch";
import {hasClosestByClassName} from "../../util/hasClosest"; import {hasClosestBlock, hasClosestByClassName} from "../../util/hasClosest";
export const bindAssetEvent = (options: { export const bindAssetEvent = (options: {
protyle: IProtyle, protyle: IProtyle,
@ -334,35 +334,39 @@ export const dragUpload = (files: string[], protyle: IProtyle, cellElement: HTML
isUpload: true, isUpload: true,
id: protyle.block.rootID id: protyle.block.rootID
}, (response) => { }, (response) => {
hideMessage(msgId); const blockElement = hasClosestBlock(cellElement);
const addUpdateValue: IAVCellAssetValue[] = []; if (blockElement) {
Object.keys(response.data.succMap).forEach(key => { hideMessage(msgId);
const type = pathPosix().extname(key).toLowerCase(); const addUpdateValue: IAVCellAssetValue[] = [];
const name = key.substring(0, key.length - type.length); Object.keys(response.data.succMap).forEach(key => {
if (Constants.SIYUAN_ASSETS_IMAGE.includes(type)) { const type = pathPosix().extname(key).toLowerCase();
addUpdateValue.push({ const name = key.substring(0, key.length - type.length);
type: "image", if (Constants.SIYUAN_ASSETS_IMAGE.includes(type)) {
name, addUpdateValue.push({
content: response.data.succMap[key], type: "image",
}); name,
} else { content: response.data.succMap[key],
addUpdateValue.push({ });
type: "file", } else {
name, addUpdateValue.push({
content: response.data.succMap[key], type: "file",
}); name,
} content: response.data.succMap[key],
}); });
fetchPost("/api/av/renderAttributeView", { }
id: avID,
}, (response) => {
updateAssetCell({
protyle,
data: response.data as IAV,
cellElements: [cellElement],
type: "addUpdate",
addUpdateValue
}); });
}); fetchPost("/api/av/renderAttributeView", {
id: avID,
pageSize: parseInt(blockElement.getAttribute("data-page-size")) || undefined,
}, (response) => {
updateAssetCell({
protyle,
data: response.data as IAV,
cellElements: [cellElement],
type: "addUpdate",
addUpdateValue
});
});
}
}); });
}; };