touchui-api
Advanced tools
+26
-12
@@ -19,2 +19,8 @@ // 文件临时路径 | ||
| } | ||
| function isAndroid() { | ||
| return !!navigator.userAgent.match(/android/i); | ||
| } | ||
| function isIos() { | ||
| return !!navigator.userAgent.match(/iPhone|iPad|iPod/i); | ||
| } | ||
| // 通用返回处理 | ||
@@ -62,4 +68,9 @@ function callback(data, successData, failData) { | ||
| // 从用户地址转换 | ||
| function fromUserPath(path) { | ||
| return path.replace('file://', '') | ||
| function fromUserPath(path, absolute) { | ||
| var path = path.replace('file://', '') | ||
| if(!absolute) { | ||
| path = plus.io.convertAbsoluteFileSystem(path) | ||
| } | ||
| return path | ||
| } | ||
@@ -72,3 +83,3 @@ // 获取持久存储目录对象 | ||
| }, function(error) { | ||
| if(error.code === 12) { | ||
| if(error.code === isAndroid() ? 12 : 1) { | ||
| plus.io.resolveLocalFileSystemURL(BASEPATH, function(entry) { | ||
@@ -372,2 +383,3 @@ entry.getDirectory(SAVEDFILEPATH.replace(BASEPATH, ''), { | ||
| api.uploadFile = function(data) { | ||
| console.log(data) | ||
| var url = data.url | ||
@@ -893,3 +905,3 @@ var filePath = data.filePath | ||
| }, function(error) { | ||
| if(error.code === 12) { | ||
| if(error.code === isAndroid() ? 12 : 1) { | ||
| plus.io.resolveLocalFileSystemURL(BASEPATH, function(entry) { | ||
@@ -911,10 +923,12 @@ entry.getDirectory(TEMPFILEPATH.replace(BASEPATH, ''), { | ||
| }) | ||
| module.exports = api | ||
| // 修复console | ||
| if(isIos()) { | ||
| window.console.log = window.console.warn = window.console.error = function() { | ||
| for(var index = 0; index < arguments.length; index++) { | ||
| var element = arguments[index]; | ||
| console.dir(element) | ||
| } | ||
| } | ||
| } | ||
| api.startRecord({ | ||
| success: function(res) { | ||
| console.log(res) | ||
| }, | ||
| }) | ||
| api.stopRecord() | ||
| module.exports = api |
+1
-1
| { | ||
| "name": "touchui-api", | ||
| "version": "0.0.2", | ||
| "version": "0.0.3", | ||
| "description": "touchui api", | ||
@@ -5,0 +5,0 @@ "main": "api.js", |
29989
1.7%917
1.55%