zan-upload
Advanced tools
Comparing version 5.1.1 to 5.2.0
@@ -25,2 +25,6 @@ 'use strict'; | ||
var _searchInput = require('zent/lib/search-input'); | ||
var _searchInput2 = _interopRequireDefault(_searchInput); | ||
var _zanPcAjax = require('zan-pc-ajax'); | ||
@@ -70,9 +74,23 @@ | ||
_this.getCache = function () { | ||
var data = _local_storage2['default'].getItem(_this.localStorgeKey); | ||
if (data) { | ||
data = JSON.parse(data); | ||
_this.setState(data); | ||
} | ||
return new Promise(function (resolve) { | ||
var data = _local_storage2['default'].getItem(_this.localStorgeKey); | ||
if (data) { | ||
data = JSON.parse(data); | ||
_this.setState(data, function () { | ||
resolve(); | ||
}); | ||
} | ||
}); | ||
}; | ||
_this.handleSearchChange = function (evt) { | ||
_this.setState({ | ||
keyword: evt.target.value | ||
}); | ||
}; | ||
_this.handleSearch = function (evt) { | ||
_this.getMediaList(1, evt.target.value); | ||
}; | ||
_this.state = { | ||
@@ -96,4 +114,3 @@ mediaList: [], | ||
value: function componentWillMount() { | ||
this.getCache(); | ||
this.getMediaList(); | ||
this.getCache().then(this.getMediaList); | ||
this.getCategoryList(); | ||
@@ -107,2 +124,3 @@ } | ||
var page = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; | ||
var keyword = arguments[1]; | ||
var options = this.props.options; | ||
@@ -112,2 +130,5 @@ var categoryId = this.state.categoryId; | ||
var pageSize = options.type === 'voice' ? VOICE_PAGE_SIZE : IMAGE_PAGE_SIZE; | ||
if (typeof keyword === 'undefined') { | ||
keyword = this.state.keyword; | ||
} | ||
return (0, _zanPcAjax2['default'])({ | ||
@@ -121,3 +142,4 @@ url: options.mediaListUrl, | ||
mediaType: options.type, | ||
categoryId: categoryId | ||
categoryId: categoryId, | ||
keyword: keyword | ||
} | ||
@@ -128,3 +150,4 @@ }).then(function (data) { | ||
currPageNo: data.currPageNo, | ||
mediaList: data.dataList || [] | ||
mediaList: data.dataList || [], | ||
keyword: keyword | ||
}, _this2.setCache); | ||
@@ -164,3 +187,4 @@ }); | ||
categoryList = _state.categoryList, | ||
categoryId = _state.categoryId; | ||
categoryId = _state.categoryId, | ||
keyword = _state.keyword; | ||
@@ -176,2 +200,8 @@ return _react2['default'].createElement( | ||
onChange: this.setCategoryId.bind(this) | ||
}), | ||
_react2['default'].createElement(_searchInput2['default'], { | ||
className: 'search-input', | ||
value: keyword, | ||
onChange: this.handleSearchChange, | ||
onPressEnter: this.handleSearch | ||
}) | ||
@@ -178,0 +208,0 @@ ); |
@@ -43,2 +43,6 @@ 'use strict'; | ||
var _FileInput = require('./components/FileInput'); | ||
var _FileInput2 = _interopRequireDefault(_FileInput); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
@@ -58,5 +62,2 @@ | ||
var FileInput = _upload2['default'].FileInput; | ||
var TabPanel = _tabs2['default'].TabPanel; | ||
@@ -164,2 +165,10 @@ | ||
value: function renderUploadComponent(uploadOptions) { | ||
var _this2 = this; | ||
var onSuccess = uploadOptions.onSuccess; | ||
uploadOptions.onSuccess = function (data) { | ||
_this2.showUpload(false); | ||
onSuccess(data); | ||
}; | ||
return _react2['default'].createElement(_upload2['default'], _extends({ | ||
@@ -217,3 +226,3 @@ withoutPopup: true, | ||
), | ||
uploadOptions.localOnly && uploadOptions.maxAmount === 1 ? _react2['default'].createElement(FileInput, uploadOptions) : '' | ||
uploadOptions.localOnly && uploadOptions.maxAmount === 1 ? _react2['default'].createElement(_FileInput2['default'], uploadOptions) : '' | ||
), | ||
@@ -228,3 +237,2 @@ _react2['default'].createElement( | ||
{ | ||
title: this.typeName + '\u9009\u62E9', | ||
visible: visible, | ||
@@ -236,3 +244,7 @@ className: dialogClassName, | ||
_tabs2['default'], | ||
{ activeId: activeId, onTabChange: this.onTabChange }, | ||
{ | ||
type: 'slider', | ||
activeId: activeId, | ||
onTabChange: this.onTabChange | ||
}, | ||
this.renderMaterialsPopup(uploadOptions), | ||
@@ -239,0 +251,0 @@ _react2['default'].createElement( |
{ | ||
"name": "zan-upload", | ||
"version": "5.1.1", | ||
"version": "5.2.0", | ||
"description": "这是一个React组件", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -306,1 +306,6 @@ ## zan-upload | ||
- 修复获取线上图片的bug | ||
#### 5.1.2 (2017-11-29) | ||
- 增加列表的搜索功能 | ||
- 素材银行样式优化 |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
813035
13
22552
311