Vanessa 2025-05-24 17:41:06 +08:00
parent 668e5826e2
commit 8ba7a703ed
5 changed files with 6 additions and 6 deletions

View file

@ -86,7 +86,7 @@ export class Asset extends Model {
}
private render() {
const type = this.path.substr(this.path.lastIndexOf(".")).toLowerCase();
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>`;
} else if (Constants.SIYUAN_ASSETS_AUDIO.includes(type)) {

View file

@ -74,7 +74,7 @@ export const openFileById = async (options: {
};
export const openAsset = (app: App, assetPath: string, page: number | string, position?: string) => {
const suffix = pathPosix().extname(assetPath.split("?page")[0]);
const suffix = pathPosix().extname(assetPath).split("?")[0];
if (!Constants.SIYUAN_ASSETS_EXTS.includes(suffix)) {
return;
}
@ -421,7 +421,7 @@ const switchEditor = (editor: Editor, options: IOpenFileOptions, allModels: IMod
const newTab = (options: IOpenFileOptions) => {
let tab: Tab;
if (options.assetPath) {
const suffix = pathPosix().extname(options.assetPath.split("?page")[0]);
const suffix = pathPosix().extname(options.assetPath).split("?")[0];
if (Constants.SIYUAN_ASSETS_EXTS.includes(suffix)) {
let icon = "iconPDF";
if (Constants.SIYUAN_ASSETS_IMAGE.includes(suffix)) {

View file

@ -727,7 +727,7 @@ export const openMenu = (app: App, src: string, onlyMenu: boolean, showAccelerat
});
/// #else
if (isLocalPath(src)) {
if (Constants.SIYUAN_ASSETS_EXTS.includes(pathPosix().extname(src)) &&
if (Constants.SIYUAN_ASSETS_EXTS.includes(pathPosix().extname(src).split("?")[0]) &&
(!src.endsWith(".pdf") ||
(src.endsWith(".pdf") && !src.startsWith("file://")))
) {

View file

@ -99,7 +99,7 @@ export class Preview {
openBy(linkAddress, "folder");
} else if (event.shiftKey) {
openBy(linkAddress, "app");
} else if (Constants.SIYUAN_ASSETS_EXTS.includes(pathPosix().extname((linkAddress.split("?page")[0])))) {
} else if (Constants.SIYUAN_ASSETS_EXTS.includes(pathPosix().extname((linkAddress).split("?")[0]))) {
openAsset(protyle.app, linkAddress.split("?page")[0], parseInt(getSearch("page", linkAddress)));
}
/// #endif

View file

@ -74,7 +74,7 @@ export const openNewWindowById = async (id: string | string[], options: windowOp
export const openAssetNewWindow = (assetPath: string, options: windowOptions = {}) => {
/// #if !BROWSER
const suffix = pathPosix().extname(assetPath.split("?page")[0]);
const suffix = pathPosix().extname(assetPath).split("?")[0];
if (Constants.SIYUAN_ASSETS_EXTS.includes(suffix)) {
let docIcon = "iconPDF";
if (Constants.SIYUAN_ASSETS_IMAGE.includes(suffix)) {