🐛 处理拓展解析异常

This commit is contained in:
BTMuli
2025-11-15 20:36:50 +08:00
parent d74e7a7a31
commit 3366efaadd
2 changed files with 16 additions and 8 deletions

View File

@@ -129,11 +129,11 @@ function getImageTitle(): string {
function getImageExt(): string {
if (props.data.attributes && props.data.attributes.ext) return props.data.attributes.ext;
if (typeof props.data.insert.image === "string") {
const arr = props.data.insert.image.split(".");
return arr[arr.length - 1];
if (typeof props.data.insert.image !== "string") {
return props.data.insert.image.format;
}
return props.data.insert.image.format;
const arr = oriUrl.value.split(".");
return arr[arr.length - 1];
}
</script>
<style lang="scss" scoped>

View File

@@ -73,10 +73,7 @@ const format = defineModel<string>("format", { default: "png" });
const bgMode = ref<number>(0); // 0: transparent, 1: black, 2: white
const isOriSize = ref<boolean>(false);
const buffer = shallowRef<Uint8Array | null>(null);
const oriLink = computed<string>(() => {
const image = props.image.insert.image;
return typeof image === "string" ? image : image.url;
});
const oriLink = computed<string>(() => miniImgUrl());
const showCopy = computed<boolean>(() => {
// 只能显示 png/jpg/jpeg/webp 格式的复制按钮
return ["png", "jpg", "jpeg", "webp"].includes(format.value.toLowerCase());
@@ -124,6 +121,17 @@ async function onDownload(): Promise<void> {
await saveCanvasImg(buffer.value, fileName, format.value);
await showLoading.end();
}
function miniImgUrl(): string {
let url: string;
if (typeof props.image.insert.image === "string") {
url = props.image.insert.image;
} else {
url = props.image.insert.image.url;
}
const link = new URL(url);
return `${link.origin}${link.pathname}`;
}
</script>
<style lang="css" scoped>
.tpoi-box {