'use strict';

var pinia = require('pinia');
var core = require('@vueuse/core');
var index = require('../../base/useUploadFile/index.js');

const useUploadTaskStore = pinia.defineStore("uploadTaskS", () => {
  const { isLoading, uploadFile, cancelUpload, cancelAllUploads } = index.useUploadFile();
  const uploadResult = core.createEventHook();
  const uploadError = core.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
  };
});

exports.useUploadTaskStore = useUploadTaskStore;
//# sourceMappingURL=index.js.map
