mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
💄 修复file_size不存在导致的hint异常
This commit is contained in:
@@ -31,7 +31,7 @@ interface TpCustomEmoticon {
|
|||||||
size: {
|
size: {
|
||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
file_size: number;
|
file_size?: number;
|
||||||
};
|
};
|
||||||
is_available: boolean;
|
is_available: boolean;
|
||||||
hash: string;
|
hash: string;
|
||||||
@@ -69,15 +69,20 @@ function getImageUrl(): string {
|
|||||||
async function download(): Promise<void> {
|
async function download(): Promise<void> {
|
||||||
const image = props.data.insert.custom_emoticon.url;
|
const image = props.data.insert.custom_emoticon.url;
|
||||||
if (buffer.value === null) buffer.value = await getImageBuffer(image);
|
if (buffer.value === null) buffer.value = await getImageBuffer(image);
|
||||||
const size = bytesToSize(props.data.insert.custom_emoticon.size.file_size);
|
let size = 0;
|
||||||
if (buffer.value.byteLength > 80000000) {
|
if (props.data.insert.custom_emoticon.size.file_size) {
|
||||||
showSnackbar.warn(`图片过大(${size}),无法下载到本地`);
|
size = props.data.insert.custom_emoticon.size.file_size;
|
||||||
|
} else {
|
||||||
|
size = buffer.value.byteLength;
|
||||||
|
}
|
||||||
|
if (size > 80000000) {
|
||||||
|
showSnackbar.warn(`图片过大(${bytesToSize(size)}),无法下载到本地`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const format = image.split(".").pop();
|
const format = image.split(".").pop();
|
||||||
const title = props.data.insert.custom_emoticon.hash;
|
const title = props.data.insert.custom_emoticon.hash;
|
||||||
await saveCanvasImg(buffer.value, props.data.insert.custom_emoticon.hash, format);
|
await saveCanvasImg(buffer.value, props.data.insert.custom_emoticon.hash, format);
|
||||||
showSnackbar.success(`已保存${title}.${format}到本地,大小为${size}`);
|
showSnackbar.success(`已保存${title}.${format}到本地,大小为${bytesToSize(size)}`);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="css" scoped>
|
<style lang="css" scoped>
|
||||||
|
|||||||
Reference in New Issue
Block a user