24 lines
541 B
JavaScript
24 lines
541 B
JavaScript
let popupInstance = null;
|
|
|
|
export function registerImageCompressPopup(instance) {
|
|
popupInstance = instance;
|
|
}
|
|
|
|
export function openImageCompressModal({ path, size }) {
|
|
if (!popupInstance || typeof popupInstance.open !== 'function') {
|
|
console.warn('image-compress-popup 未注册,将直接使用原图');
|
|
return Promise.resolve({
|
|
path,
|
|
size,
|
|
usedCompress: false,
|
|
});
|
|
}
|
|
|
|
return popupInstance.open({ path, size }).then((result) => {
|
|
if (!result) {
|
|
return null;
|
|
}
|
|
return result;
|
|
});
|
|
}
|