zan-upload
Advanced tools
Comparing version
@@ -38,2 +38,3 @@ 'use strict'; | ||
contentType: 'multipart/form-data; charset=UTF-8', | ||
timeout: options.timeout, | ||
onUploadProgress: function onUploadProgress(evt) { | ||
@@ -40,0 +41,0 @@ options.onProgress(evt.loaded * 100 / evt.total); |
@@ -154,3 +154,6 @@ 'use strict'; | ||
'div', | ||
{ className: triggerClassName, onClick: this.showUpload.bind(this, true) }, | ||
{ | ||
className: triggerClassName, | ||
onClick: this.showUpload.bind(this, true) | ||
}, | ||
children || Node && _react2['default'].createElement(Node, null) || _react2['default'].createElement( | ||
@@ -200,6 +203,3 @@ 'span', | ||
TabPanel, | ||
{ | ||
tab: '\u6211\u7684' + this.typeName, | ||
id: 'materials' | ||
}, | ||
{ tab: '\u6211\u7684' + this.typeName, id: 'materials' }, | ||
_react2['default'].createElement(_MaterialsPopup2['default'], { | ||
@@ -234,6 +234,3 @@ prefix: prefix + '-upload', | ||
TabPanel, | ||
{ | ||
tab: '\u672C\u5730\u4E0A\u4F20', | ||
id: 'upload' | ||
}, | ||
{ tab: '\u672C\u5730\u4E0A\u4F20', id: 'upload' }, | ||
_react2['default'].createElement(_UploadPopup2['default'], { | ||
@@ -309,2 +306,3 @@ prefix: prefix + '-upload', | ||
silent: false, | ||
timeout: 60 * 1000, | ||
kdtId: (window._global || {}).kdt_id || 0 // eslint-disable-line | ||
@@ -311,0 +309,0 @@ }; |
{ | ||
"name": "zan-upload", | ||
"version": "4.2.3", | ||
"version": "4.2.5", | ||
"description": "这是一个React组件", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -252,2 +252,3 @@ ## zan-upload | ||
| auto | 是否自动弹出 | boolean | `false` | 否 | | ||
| timeout | 上传超时毫秒数 | number | `60 * 1000` | 否 | | ||
| mediaListUrl | 自定义素材银行列表url [GET] | string | `'//materials.youzan.com/media/mediaList.json'` | 否 | | ||
@@ -254,0 +255,0 @@ | categoryListUrl | 自定义素材银行分组列表url [GET] | string | `'//materials.youzan.com/category/categoryList.json'` | 否 | |
@@ -20,2 +20,3 @@ import { Notify } from 'zent'; | ||
contentType: 'multipart/form-data; charset=UTF-8', | ||
timeout: options.timeout, | ||
onUploadProgress(evt) { | ||
@@ -22,0 +23,0 @@ options.onProgress(evt.loaded * 100 / evt.total); |
@@ -16,6 +16,5 @@ /** | ||
const noop = (res) => res; | ||
const noop = res => res; | ||
class Upload extends Component { | ||
constructor(props) { | ||
@@ -68,6 +67,3 @@ super(props); | ||
let { | ||
visible, | ||
activeId | ||
} = this.state; | ||
let { visible, activeId } = this.state; | ||
@@ -83,13 +79,23 @@ let Node = trigger; | ||
className = classnames([dialogClassName, { | ||
inline | ||
}]); | ||
className = classnames([ | ||
dialogClassName, | ||
{ | ||
inline | ||
} | ||
]); | ||
return ( | ||
<div className={className}> | ||
<div className={triggerClassName} onClick={this.showUpload.bind(this, true)}> | ||
{children || Node && <Node /> || <span>+</span>} | ||
{uploadOptions.localOnly && uploadOptions.maxAmount === 1 ? <FileInput {...uploadOptions} /> : ''} | ||
<div | ||
className={triggerClassName} | ||
onClick={this.showUpload.bind(this, true)} | ||
> | ||
{children || (Node && <Node />) || <span>+</span>} | ||
{uploadOptions.localOnly && uploadOptions.maxAmount === 1 | ||
? <FileInput {...uploadOptions} /> | ||
: ''} | ||
</div> | ||
<p className={`${prefix}-upload-tips`}>{tips}</p> | ||
<p className={`${prefix}-upload-tips`}> | ||
{tips} | ||
</p> | ||
<Dialog | ||
@@ -101,10 +107,8 @@ title={`${this.typeName}选择`} | ||
> | ||
{ | ||
materials ? ( | ||
<Tabs activeId={activeId} onTabChange={this.onTabChange}> | ||
{materials | ||
? <Tabs activeId={activeId} onTabChange={this.onTabChange}> | ||
{this.renderMaterialsPopup(uploadOptions)} | ||
{this.renderUploadPopup(uploadOptions)} | ||
</Tabs> | ||
) : this.renderUploadPopup(uploadOptions) | ||
} | ||
: this.renderUploadPopup(uploadOptions)} | ||
</Dialog> | ||
@@ -119,20 +123,13 @@ </div> | ||
renderMaterialsPopup(options) { | ||
const { | ||
prefix, | ||
className, | ||
materials | ||
} = this.props; | ||
return materials ? ( | ||
<TabPanel | ||
tab={`我的${this.typeName}`} | ||
id="materials" | ||
> | ||
<MaterialsPopup | ||
prefix={`${prefix}-upload`} | ||
options={options} | ||
className={className} | ||
showUploadPopup={this.showUpload} | ||
/> | ||
</TabPanel> | ||
) : ''; | ||
const { prefix, className, materials } = this.props; | ||
return materials | ||
? <TabPanel tab={`我的${this.typeName}`} id="materials"> | ||
<MaterialsPopup | ||
prefix={`${prefix}-upload`} | ||
options={options} | ||
className={className} | ||
showUploadPopup={this.showUpload} | ||
/> | ||
</TabPanel> | ||
: ''; | ||
} | ||
@@ -144,8 +141,3 @@ | ||
renderUploadPopup(options) { | ||
let { | ||
prefix, | ||
accept, | ||
className, | ||
materials | ||
} = this.props; | ||
let { prefix, accept, className, materials } = this.props; | ||
@@ -156,8 +148,13 @@ if (options.type === 'voice') { | ||
return materials ? ( | ||
<TabPanel | ||
tab="本地上传" | ||
id="upload" | ||
> | ||
<UploadPopup | ||
return materials | ||
? <TabPanel tab="本地上传" id="upload"> | ||
<UploadPopup | ||
prefix={`${prefix}-upload`} | ||
options={options} | ||
accept={accept} | ||
className={className} | ||
showUploadPopup={this.showUpload} | ||
/> | ||
</TabPanel> | ||
: <UploadPopup | ||
prefix={`${prefix}-upload`} | ||
@@ -168,13 +165,3 @@ options={options} | ||
showUploadPopup={this.showUpload} | ||
/> | ||
</TabPanel> | ||
) : ( | ||
<UploadPopup | ||
prefix={`${prefix}-upload`} | ||
options={options} | ||
accept={accept} | ||
className={className} | ||
showUploadPopup={this.showUpload} | ||
/> | ||
); | ||
/>; | ||
} | ||
@@ -187,8 +174,6 @@ | ||
showUpload = (visible = true) => { | ||
let { | ||
localOnly, | ||
maxAmount | ||
} = this.props; | ||
let { localOnly, maxAmount } = this.props; | ||
if (!localOnly || maxAmount !== 1) { // 直接打开本地文件 | ||
if (!localOnly || maxAmount !== 1) { | ||
// 直接打开本地文件 | ||
this.setState({ | ||
@@ -198,3 +183,3 @@ visible | ||
} | ||
} | ||
}; | ||
} | ||
@@ -244,2 +229,3 @@ | ||
silent: false, | ||
timeout: 60 * 1000, | ||
kdtId: (window._global || {}).kdt_id || 0 // eslint-disable-line | ||
@@ -246,0 +232,0 @@ }; |
Sorry, the diff of this file is too big to display
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
818925
0.17%22618
0.11%259
0.39%4
33.33%