通用评论 vedio

Upload.js.map 7.8KB

1
  1. {"version":3,"sources":["../../../src/components/Editor/Upload.js"],"names":["client","window","OSS","Wrapper","accessKeyId","oss","access_key_id","accessKeySecret","access_key_secret","stsToken","security_token","endpoint","OSS_ENDPOINT","bucket","OSS_BUCKET","uploadPath","path","file","format","shortid","generate","type","split","UploadToOss","url","Promise","resolve","reject","multipartUpload","then","data","catch","error","App","props","state","previewVisible","previewImage","handleCancel","bind","handlePreview","handleChange","customRequest","app","sOssSts","setState","thumbUrl","fileList","onChangeFileList","info","onProgress","percent","reader","FileReader","readAsDataURL","onloadend","DRIVER_LICENSE_PATH","onSuccess","onUpload","name","uid","msg","e","message","ERROR_DEFAULT","showError","onError","response","maxUpload","uploadButton","intl","get","length","width","React","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AAEA;;;;AACA;;;;AACA;;;;AACA;;AAMA;;;;AACA;;;;;;;;;;AAEA,IAAMA,SAAS,SAATA,MAAS,MAAO;AACpB,SAAO,IAAIC,OAAOC,GAAP,CAAWC,OAAf,CAAuB;AAC5BC,iBAAaC,IAAIC,aADW;AAE5BC,qBAAiBF,IAAIG,iBAFO;AAG5BC,cAAUJ,IAAIK,cAHc;AAI5BC,cAAUC,sBAJkB,EAIJ;AACxBC,YAAQC;AALoB,GAAvB,CAAP;AAOD,CARD;;AAUA,IAAMC,aAAa,SAAbA,UAAa,CAACC,IAAD,EAAOC,IAAP,EAAgB;AACjC,SAAUD,IAAV,SAAkB,uBAAQE,MAAR,CAAe,UAAf,CAAlB,SAAgDC,kBAAQC,QAAR,EAAhD,SACEH,KAAKI,IAAL,CAAUC,KAAV,CAAgB,GAAhB,EAAqB,CAArB,CADF;AAGD,CAJD;;AAMA,IAAMC,cAAc,SAAdA,WAAc,CAAClB,GAAD,EAAMW,IAAN,EAAYC,IAAZ,EAAqB;AACvC,MAAMO,MAAMT,WAAWC,IAAX,EAAiBC,IAAjB,CAAZ;AACA,SAAO,IAAIQ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AKE,uBAAW,KAAKF,aALlB;AAME,sBAAU,KAAKC;AANjB;AAQGM,mBAASyB,MAAT,IAAmBJ,SAAnB,GAA+B,IAA/B,GAAsCC;AARzC,SADF;AAWE;AAAA;AAAA;AACE,qBAASjC,cADX;AAEE,oBAAQ,IAFV;AAGE,sBAAU,KAAKE;AAHjB;AAKE,iDAAK,KAAI,QAAT,EAAkB,OAAO,EAAEmC,OAAO,MAAT,EAAzB,EAA4C,KAAKpC,YAAjD;AALF;AAXF,OADF;AAqBD;;;;EAzFeqC,gBAAMC,S;;kBA4FT,uBAAQ1C,GAAR,C","file":"Upload.js","sourcesContent":["import React from \"react\";\r\nimport { Upload, Icon, Modal, message } from \"antd\";\r\nimport dayjs from \"dayjs\";\r\nimport shortid from \"shortid\";\r\nimport intl from \"react-intl-universal\";\r\nimport {\r\n OSS_ENDPOINT,\r\n OSS_BUCKET,\r\n DRIVER_LICENSE_PATH,\r\n ERROR_DEFAULT\r\n} from \"../../constant\";\r\nimport Comment from \"../../Comment\";\r\nimport \"./Upload.css\";\r\n\r\nconst client = oss => {\r\n return new window.OSS.Wrapper({\r\n accessKeyId: oss.access_key_id,\r\n accessKeySecret: oss.access_key_secret,\r\n stsToken: oss.security_token,\r\n endpoint: OSS_ENDPOINT, //常量,你可以自己定义\r\n bucket: OSS_BUCKET\r\n });\r\n};\r\n\r\nconst uploadPath = (path, file) => {\r\n return `${path}/${dayjs().format(\"YYYYMMDD\")}/${shortid.generate()}.${\r\n file.type.split(\"/\")[1]\r\n }`;\r\n};\r\n\r\nconst UploadToOss = (oss, path, file) => {\r\n const url = uploadPath(path, file);\r\n return new Promise((resolve, reject) => {\r\n client(oss)\r\n .multipartUpload(url, file)\r\n .then(data => {\r\n resolve(data);\r\n })\r\n .catch(error => {\r\n reject(error);\r\n });\r\n });\r\n};\r\n\r\nclass App extends React.Component {\r\n constructor(props) {\r\n super(props);\r\n this.state = {\r\n previewVisible: false,\r\n previewImage: \"\"\r\n };\r\n this.handleCancel = this.handleCancel.bind(this);\r\n this.handlePreview = this.handlePreview.bind(this);\r\n this.handleChange = this.handleChange.bind(this);\r\n this.customRequest = this.customRequest.bind(this);\r\n }\r\n\r\n componentDidMount() {\r\n this.props.app.sOssSts();\r\n }\r\n\r\n handleCancel() {\r\n this.setState({ previewVisible: false });\r\n }\r\n\r\n handlePreview(file) {\r\n this.setState({\r\n previewImage: file.url || file.thumbUrl,\r\n previewVisible: true\r\n });\r\n }\r\n\r\n handleChange({ fileList }) {\r\n this.props.onChangeFileList(fileList);\r\n }\r\n\r\n customRequest(info) {\r\n const { file } = info;\r\n info.onProgress({ percent: 10 });\r\n let reader = new FileReader();\r\n reader.readAsDataURL(info.file);\r\n reader.onloadend = () => {\r\n info.onProgress({ percent: 20 });\r\n // DRIVER_LICENSE_PATH oss 的存储路径位置\r\n UploadToOss(this.props.app.oss, DRIVER_LICENSE_PATH, file)\r\n .then(data => {\r\n info.onProgress({ percent: 100 });\r\n info.onSuccess();\r\n this.props.onUpload({ path: data.name, uid: file.uid });\r\n })\r\n .catch(e => {\r\n const msg = e.message || ERROR_DEFAULT;\r\n if (this.props.showError) {\r\n message.error(msg);\r\n }\r\n if (this.props.onError) {\r\n this.props.onError(msg, { response: e.response });\r\n }\r\n info.onError(e);\r\n });\r\n };\r\n }\r\n\r\n render() {\r\n const { previewVisible, previewImage } = this.state;\r\n const { fileList, maxUpload } = this.props;\r\n const uploadButton = (\r\n <div>\r\n <Icon type=\"plus\" />\r\n <div className=\"ant-upload-text\">{intl.get(\"editor.uploadBtn\")}</div>\r\n </div>\r\n );\r\n return (\r\n <div>\r\n <Upload\r\n accept=\"image/jpg,image/jpeg,image/png,image/bmp\"\r\n listType=\"picture-card\"\r\n fileList={fileList}\r\n customRequest={this.customRequest}\r\n onPreview={this.handlePreview}\r\n onChange={this.handleChange}\r\n >\r\n {fileList.length >= maxUpload ? null : uploadButton}\r\n </Upload>\r\n <Modal\r\n visible={previewVisible}\r\n footer={null}\r\n onCancel={this.handleCancel}\r\n >\r\n <img alt=\"upload\" style={{ width: \"100%\" }} src={previewImage} />\r\n </Modal>\r\n </div>\r\n );\r\n }\r\n}\r\n\r\nexport default Comment(App);\r\n"]}