Skip to content

Commit c3f02eb

Browse files
committed
fix: 🐛 修改图片跨域问题
1 parent baf1175 commit c3f02eb

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/utils/data/getImgToBase64.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,15 @@ export const getImgToBase64 = (
6868
url: string,
6969
options?: ImgOptions,
7070
): Promise<string> => {
71-
const { type } = options ?? {};
72-
73-
if (!options || type === ImgType.APNG) return getImgBase64ByFetch(url);
71+
if (options && options?.type === ImgType.APNG) return getImgBase64ByFetch(url);
7472

7573
return getImgBase64ByCanvas(url, options);
7674
};
7775

78-
async function getImgBase64ByCanvas(url: string, options: ImgOptions): Promise<string> {
76+
async function getImgBase64ByCanvas(
77+
url: string,
78+
options: ImgOptions,
79+
): Promise<string> {
7980
const { type = ImgType.PNG, quality = 1 } = options;
8081
let canvas = document.createElement('canvas');
8182
const ctx = canvas.getContext('2d');

0 commit comments

Comments
 (0)