浏览代码

:bug: 数据库加载更多后的操作

Vanessa 1 年之前
父节点
当前提交
c301a4ac0a
共有 1 个文件被更改,包括 33 次插入29 次删除
  1. 33 29
      app/src/protyle/render/av/asset.ts

+ 33 - 29
app/src/protyle/render/av/asset.ts

@@ -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 addUpdateValue: IAVCellAssetValue[] = [];
-        Object.keys(response.data.succMap).forEach(key => {
-            const type = pathPosix().extname(key).toLowerCase();
-            const name = key.substring(0, key.length - type.length);
-            if (Constants.SIYUAN_ASSETS_IMAGE.includes(type)) {
-                addUpdateValue.push({
-                    type: "image",
-                    name,
-                    content: response.data.succMap[key],
-                });
-            } else {
-                addUpdateValue.push({
-                    type: "file",
-                    name,
-                    content: response.data.succMap[key],
+        const blockElement = hasClosestBlock(cellElement);
+        if (blockElement) {
+            hideMessage(msgId);
+            const addUpdateValue: IAVCellAssetValue[] = [];
+            Object.keys(response.data.succMap).forEach(key => {
+                const type = pathPosix().extname(key).toLowerCase();
+                const name = key.substring(0, key.length - type.length);
+                if (Constants.SIYUAN_ASSETS_IMAGE.includes(type)) {
+                    addUpdateValue.push({
+                        type: "image",
+                        name,
+                        content: response.data.succMap[key],
+                    });
+                } else {
+                    addUpdateValue.push({
+                        type: "file",
+                        name,
+                        content: response.data.succMap[key],
+                    });
+                }
+            });
+            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
                 });
                 });
-            }
-        });
-        fetchPost("/api/av/renderAttributeView", {
-            id: avID,
-        }, (response) => {
-            updateAssetCell({
-                protyle,
-                data: response.data as IAV,
-                cellElements: [cellElement],
-                type: "addUpdate",
-                addUpdateValue
             });
             });
-        });
+        }
     });
     });
 };
 };