import { defineStore } from 'pinia';
import { createEventHook } from '@vueuse/core';
import { useUploadFile } from '../../base/useUploadFile/index.mjs';

const useUploadTaskStore = defineStore("uploadTaskS", () => {
  const { isLoading, uploadFile, cancelUpload, cancelAllUploads } = useUploadFile();
  const uploadResult = createEventHook();
  const uploadError = createEventHook();
  const uploadFileTask = async (file, options) => {
    try {
      const data = await uploadFile(file, options);
      uploadResult.trigger({ ...data, file });
      return data;
    } catch (error) {
      uploadError.trigger(error);
      return error;
    }
  };
  return {
    // 事件监听器
    uploadResult: uploadResult.on,
    uploadError: uploadError.on,
    // 主要方法
    uploadFileTask,
    cancelUpload,
    cancelAllUploads,
    isLoading
  };
});

export { useUploadTaskStore };
//# sourceMappingURL=index.mjs.map
