小程序 native 组件 web 端实现, 没有小程序代码依赖,可用于普通移动端页面
npm install && gulp test
open http://localhost:8080/bundle
npm install && gulp
open http://localhost:3000/example/
import {
fileManage,
downloadFile,
uploadFile,
...
} from 'wept-sdk'
页面上引入 example/style.css
-
compass
罗盘模块,提供watch
和unwatch
方法let id = compass.watch(direction => { // direction 为面对的方向度数 }) Compass.unwatch(id)
-
actionSheet
模块,返回 promiseactionSheet({ itemList: ['a', 'b', 'c'], itemColor: '#000000' }).then(res => { if(res.cancel) { // user cancel } else { console.log(res.tapIndex) // index from 0 } })
-
DatePicker
模块,日期选择let picker = new DatePicker({ range: { start: '2016-01-01', end: '2018-01-01' } }) picker.show() picker.hide() picker.on('select', val => { console.log(val) // yyyy-mm-dd })
-
fileManage
模块,本地文件管理,使用 IndexDB// save to db fileManage.save(tempFilePath).then(savedPath => { }) fileManage.getFileList().then(arr => { // list of file info }) fileManage.getFileInfo(savedPath).then(info => { // info.size // info.createTime }) fileManage.remove(savedPath).then(() => { // remove from db })
-
imageInfo
模块,获取图片大小ImageInfo(tempFilePath).then(obj => { // obj.width // obj.height })
-
modal
模块, 弹出窗口modal({ title: '', content: '', imgUrl: '' }).then(confirm => { if (confirm) { } else { } })
-
mask
模块,透明遮罩,返回隐藏函数let hide = mask() hide()
-
Picker
模块,弹出选择组件let picker = new Picker({ array: ['a', 'b', 'c'], current: 2 }) picker.show() picker.hide() picker.on('select', index => { // selected index }) picker.on('hide', () => { // on picker hide })
-
record
模块,提供录音功能, 需要全局Recorder
对象支持record.startRecord({ fail: function(err) { }, success: function(url) { // object url for wav file } }) record.stopRecord()
-
storage
模块,提供缓存支持,使用 localStoragestorage.set(key, value, dataType) storage.get(key) storage.remove(key) storage.clear() let obj = storage.getAll() // each key of obj contains data & dataType let info = storage.info() // info.keys // info.limitSize // info.currentSize
-
Timepicker
模块,时间选择功能let picker = new TimePicker({ current: '11:11' }) picker.show() picker.hide() picker.on('select', str => { // selected time string mm:ss }) picker.on('cancel', () => { // on picker cancel })
-
toast
模块,轻提醒组件toast.show({ duration: 1000, icon: 'waiting', title: 'wait', mask: true }) toast.hide()
-
motion
模块motion.watch(res => { //res.x //res.y //res.z }) motion.unwatch()
-
voice
模块voice.play(url).then(res => { }, err => { }) voice.pause() voice.stop()
-
music
模块let obj = music.getStatus() music.on('error', e => { }) music.play() music.pause() music.seek() music.stop()
-
uploadFile
模块uploadFile({ filePath: url, url: '/' name: 'file', headers: {}, formData: {} }).then(res => { console.log(res) done() })
-
downloadFile
模块downloadFile(url, headers, '/remoteProxy').then(res => { // res.statusCode // res.tempFilePath }, err => { // request error // err.status for statusCode })
-
notice
模块notice('This is error', { type: 'error', // success, error or info sticky: true, // true or false duration: 3000 })
-
spin
模块// attach spin to node spin(node, { size: 32, // default 32 width: 4, // line width default 4 duration: 1000, // animation duration in milisecond color: '#ffffff' // color in rrggbb format })
-
ImagesPreview
模块let current = urls[0] let preview = new ImagesPreview(urls, {}) preview.show() preview.active(current)
-
imagePicker
模块imagePicker({ multiple: true // default true }).then(arr => { // array contains image ObjectURL and image size })
-
videoPicker
模块videoPicker().then(obj => { // obj.duration duration in seconds // obj.size byte length of video // obj.height video height // obj.width video width // obj.url ObjectURL of video })
Copyright 2016 chemzqm@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.