Vanessa 2026-01-12 20:11:59 +08:00
parent 7d266c7136
commit f51ad35809
3 changed files with 13 additions and 5 deletions

View file

@ -746,7 +746,7 @@ const copyAnno = (idPath: string, fileName: string, pdf: any) => {
}
confirmDialog(msg ? window.siyuan.languages.upload : "", msg, () => {
const formData = new FormData();
const imageName = content.substring(0, content.length - 22) + (imageData.rotation ? `-${imageData.rotation}-` : "") + content.substring(content.length - 22) + ".png";
const imageName = content.substring(0, content.length - 22) + (imageData.rotation ? `${imageData.rotation}-` : "") + content.substring(content.length - 22) + ".png";
formData.append("file[]", blob, imageName);
formData.append("skipIfDuplicated", "true");
fetchPost(Constants.UPLOAD_ADDRESS, formData, (response) => {

View file

@ -15,6 +15,7 @@ import {fetchPost} from "../util/fetch";
import {setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";
import {App} from "../index";
import {clearOBG} from "../layout/dock/util";
import {getDisplayName} from "../util/pathName";
export class Asset extends Model {
public path: string;
@ -49,6 +50,12 @@ export class Asset extends Model {
this.render();
}
public update(path: string) {
this.path = path;
this.parent.updateTitle(getDisplayName(path));
this.render(false);
}
private getPdfId(cb: () => void) {
fetchPost("/api/asset/getFileAnnotation", {
path: this.path + ".sya",
@ -85,7 +92,7 @@ export class Asset extends Model {
/// #endif
}
private render() {
private render(isInit = true) {
const type = this.path.substr(this.path.lastIndexOf(".")).toLowerCase().split("?")[0];
if (Constants.SIYUAN_ASSETS_IMAGE.includes(type)) {
this.element.innerHTML = `<div class="asset"><img src="${this.path.startsWith("file") ? this.path : document.getElementById("baseURL").getAttribute("href") + "/" + this.path}"></div>`;
@ -95,7 +102,8 @@ export class Asset extends Model {
this.element.innerHTML = `<div class="asset"><video controls="controls" src="${this.path.startsWith("file") ? this.path : document.getElementById("baseURL").getAttribute("href") + "/" + this.path}"></video></div>`;
} else if (type === ".pdf") {
/// #if !MOBILE
this.element.innerHTML = `<div class="pdf__outer" id="outerContainer">
if (isInit) {
this.element.innerHTML = `<div class="pdf__outer" id="outerContainer">
<div id="sidebarContainer">
<div id="toolbarSidebar">
<div id="toolbarSidebarLeft">
@ -470,6 +478,7 @@ export class Asset extends Model {
</div>
</div> <!-- outerContainer -->
<div id="printContainer"></div>`;
}
const localPDF = window.siyuan.storage[Constants.LOCAL_PDFTHEME];
const pdfTheme = window.siyuan.config.appearance.mode === 0 ? localPDF.light : localPDF.dark;
const darkElement = this.element.querySelector("#pdfDark");

View file

@ -145,8 +145,7 @@ export const renameAsset = (assetPath: string) => {
/// #if !MOBILE
getAllModels().asset.forEach(item => {
if (item.path === assetPath) {
item.path = response.data.newPath;
item.parent.updateTitle(getDisplayName(response.data.newPath));
item.update(response.data.newPath);
}
});
/// #endif