import {createApplicationService} from "../Application/service/createApplicationService"; import {createApplicationServiceManager} from "../Application/service/createApplicationServiceManager"; import {ImageService, ImageServicePreviewOption} from "./ImageService"; import {$file} from "../$file"; import {imageCompress} from "../$message/image.service.utils"; export const useImage = createApplicationService( 'image', createApplicationServiceManager({ name: 'image', Service: ImageService }), (getManager) => { const preview = (urls: string | (string | null | undefined)[], current?: number) => { let option: ImageServicePreviewOption = { urls: !!urls && Array.isArray(urls) ? urls : [urls], current: current == null ? 0 : current, }; getManager().then(manager => manager.service(option)); }; return { $image: { choose: $file.chooseImage, compress: imageCompress, preview, } }; } ); export default useImage;