Vanessa 2026-01-09 11:08:37 +08:00
parent f2479af3b9
commit 0fbf1c4ed3
4 changed files with 9 additions and 9 deletions

View file

@ -62,6 +62,7 @@
"encoding": "^0.1.13",
"esbuild-loader": "^3.0.1",
"eslint": "^9.15.0",
"filesize": "^11.0.13",
"file-loader": "^6.2.0",
"globals": "^15.12.0",
"html-loader": "^2.1.2",
@ -76,8 +77,7 @@
"typescript": "^4.7.4",
"webpack": "^5.94.0",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.10.0",
"pretty-bytes": "^7.1.0"
"webpack-cli": "^4.10.0"
},
"dependencies": {
"@electron/remote": "^2.1.3"

View file

@ -9,7 +9,7 @@ import {Dialog} from "../dialog";
import {showMessage} from "../dialog/message";
import {isMobile} from "../util/functions";
import {confirmDialog} from "../dialog/confirmDialog";
import prettyBytes from "pretty-bytes";
import {filesize} from "filesize";
export const initAnno = (element: HTMLElement, pdf: any) => {
getConfig(pdf);
@ -743,7 +743,7 @@ const copyAnno = (idPath: string, fileName: string, pdf: any) => {
const imageName = content + ".png";
let msg = "";
if (Constants.SIZE_UPLOAD_TIP_SIZE <= blob.size) {
msg = window.siyuan.languages.uploadFileTooLarge.replace("${x}", imageName).replace("${y}", prettyBytes(blob.size, {binary: true}));
msg = window.siyuan.languages.uploadFileTooLarge.replace("${x}", imageName).replace("${y}", filesize(blob.size, {standard: "jedec"}));
}
confirmDialog(msg ? window.siyuan.languages.upload : "", msg, () => {
const formData = new FormData();

View file

@ -23,7 +23,7 @@ import {getColId} from "./col";
import {getFieldIdByCellElement} from "./row";
import {getCompressURL, removeCompressURL} from "../../../util/image";
import {confirmDialog} from "../../../dialog/confirmDialog";
import prettyBytes from "pretty-bytes";
import {filesize} from "filesize";
export const bindAssetEvent = (options: {
protyle: IProtyle,
@ -427,7 +427,7 @@ export const dragUpload = (files: ILocalFiles[], protyle: IProtyle, cellElement:
const assetPaths: string[] = [];
files.forEach(item => {
if (item.size && Constants.SIZE_UPLOAD_TIP_SIZE <= item.size) {
msg += window.siyuan.languages.uploadFileTooLarge.replace("${x}", item.path).replace("${y}", prettyBytes(item.size, {binary: true})) + "<br>";
msg += window.siyuan.languages.uploadFileTooLarge.replace("${x}", item.path).replace("${y}", filesize(item.size, {standard: "jedec"})) + "<br>";
}
assetPaths.push(item.path);
});

View file

@ -11,7 +11,7 @@ import {getContenteditableElement} from "../wysiwyg/getBlock";
import {getTypeByCellElement, updateCellsValue} from "../render/av/cell";
import {scrollCenter} from "../../util/highlightById";
import {confirmDialog} from "../../dialog/confirmDialog";
import prettyBytes from "pretty-bytes";
import {filesize} from "filesize";
interface FileWithPath extends File {
path: string;
@ -220,7 +220,7 @@ export const uploadLocalFiles = (files: ILocalFiles[], protyle: IProtyle, isUplo
const assetPaths: string[] = [];
files.forEach(item => {
if (item.size && Constants.SIZE_UPLOAD_TIP_SIZE <= item.size) {
msg += window.siyuan.languages.uploadFileTooLarge.replace("${x}", item.path).replace("${y}", prettyBytes(item.size, {binary: true})) + "<br>";
msg += window.siyuan.languages.uploadFileTooLarge.replace("${x}", item.path).replace("${y}", filesize(item.size, {standard: "jedec"})) + "<br>";
}
assetPaths.push(item.path);
});
@ -311,7 +311,7 @@ export const uploadFiles = (protyle: IProtyle, files: FileList | DataTransferIte
for (let i = 0, iMax = validateResult.files.length; i < iMax; i++) {
formData.append(protyle.options.upload.fieldName, validateResult.files[i]);
if (Constants.SIZE_UPLOAD_TIP_SIZE <= validateResult.files[i].size) {
msg += window.siyuan.languages.uploadFileTooLarge.replace("${x}", validateResult.files[i].name).replace("${y}", prettyBytes(validateResult.files[i].size, {binary: true})) + "<br>";
msg += window.siyuan.languages.uploadFileTooLarge.replace("${x}", validateResult.files[i].name).replace("${y}", filesize(validateResult.files[i].size, {standard: "jedec"})) + "<br>";
}
}