zhengyiming
2025-02-11 d4afc7562a9e2eab52e552834dd7c4c653da6c01
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import Taro from '@tarojs/taro';
 
export const fetchOssImage = (fileList) => {
  if (fileList.length === 0) {
    return new Promise<string[]>((resolve, _reject) => {
      resolve([]);
    });
  }
 
  let promises: Array<Promise<string>> = [];
  fileList.forEach((fileUrl) => {
    const promise = Taro.getImageInfo({ src: fileUrl }).then((res) => res.path);
    promises.push(promise);
  });
 
  return new Promise<string[]>((resolve, _reject) => {
    Promise.all(promises).then((res) => {
      promises = [];
      resolve(res);
    });
  });
};