|
楼主 |
发表于 2020-2-27 11:15:09
|
显示全部楼层
将上述fileApi.js文件里面代码修改如下,在APP里面打开是跳转到本机自带浏览器打开图片的,APP里面是不能直接打开图片??而且为什么this._isLocalFile(url)方法会返回false??
- /**
- * fileEntry
- * fullPath: "/test"
- * name: "test"
- * toURL():"filesystem:http://192.168.1.49:8080/temporary/test"
- *
- * 浏览本地文件需要传url为 toURL之后的
- */
- browse:function(url,fileName, option){
- var dtd = $.Deferred();
- var self = this;
- if(Browser.isX5App){
- if(this._isLocalFile(url)){
- alert('isLocalFile : url '+url);
- if(Browser.isAndroid){
- window.open(url,"_system");
- dtd.resolve(url);
- }else if(Browser.isIOS){
- window.open(url, '_blank', 'toolbarposition=top,location=no,enableViewportScale=yes');
- dtd.resolve(url);
- }
- }else{
- url = this._toFullUrl(url);
- alert('else : url '+url);
- /*this.download(url, fileName,option).done(function(nativeUrl){
- self.browse(nativeUrl).done(function(url){
- dtd.resolve(url);
- }).fail(function(err){
- dtd.reject(err);
- });
- }).fail(function(err){
- dtd.reject(err);
- });*/
- plugins.toast.showShortBottom("正在载入文件,请稍候。。。。");
- // handleDocumentWithURL(function(){
- // window.open(url,"_system");
- // dtd.resolve(url);
- // },function(err){
- // dtd.reject(err);
- // },url);
- window.open(url,"_system");
- dtd.resolve(url);
- }
- }else{
- //TODO:支持浏览器中filesystem的文件浏览
- if(justep.Browser.isWeChat){
- var fileBrowseNode = $('<div style="z-index:9999;position:absolute;top:0;bottom:0;left:0;right:0;background-color:white;"></div>');
- var closeBtn = $('<i class="icon-chevron-left" style="position:absolute;z-index:3;left:25px;width:50px;top:10px;height:36px;"/>').on('click',function(){
- fileBrowseNode.remove();
- }).appendTo(fileBrowseNode);
- var fileFrame = $('<iframe src="'+url+'" style="width:100%;height:100%;padding-top:46px;position:absolute;background-color:white;border:none;"></iframe>').appendTo(fileBrowseNode);
- fileBrowseNode.appendTo('body');
- dtd.resolve(url);
- }else{
- window.open(url, '_blank');
- dtd.resolve(url);
- }
- }
- return dtd.promise();
- },
复制代码 |
|