• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com专业计算机教程网站
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure
您的位置:首页 > 网页设计 >HBuilder教程 > HBuilder MUI 远程文件缓存到本地

HBuilder MUI 远程文件缓存到本地

作者:教程 字体:[增加 减小] 来源:互联网 时间:2017-05-31

本文主要包含hbuilder mui,hbuilder mui视频教程,hbuilder mui教程,hbuilder mui api,hbuilder mui app等相关知识,教程希望在学习及工作中可以帮助到您
"); </div> 本文对plus.download做了简单的封装。通过common.cache.getFIle获取图片本地链接。 下载的代码块中没有指定下载的文件名及扩展名,我使用的是云服务器,获取的链接是没有文件扩展名的,故而没有做详细的限制。

  1. (function(com){ 
  2.      
  3.     var hashCode = function(str) { 
  4.         var hash = 0; 
  5.         if (!str || str.length == 0) return hash; 
  6.         for (i = 0; i < str.length; i++) { 
  7.             char = str.charCodeAt(i); 
  8.             hash = ((hash << 5) - hash) + char; 
  9.             hash = hash & hash; // Convert to 32bit integer 
  10.         } 
  11.         return hash; 
  12.     }; 
  13.     com.hashCode=hashCode; 
  14.     /** 
  15.      *存储当前下载路径www.bcty365.com
  16.      */ 
  17.     var cache = {}; 
  18.     cache.getFile = function(netPath, cb) { 
  19.         var filePathCache = getLocalFileCache(netPath); 
  20.         if (filePathCache) { 
  21.             return cb(filePathCache); 
  22.         } else { 
  23.             Filedownload(netPath, function(localPath) { 
  24.                 return cb(localPath); 
  25.             }); 
  26.         } 
  27.     }; 
  28.  
  29.     //下载 
  30.     var Filedownload = function(netPath, callback) { 
  31.         var dtask = plus.downloader.createDownload(netPath, {}, function(d, status) { 
  32.             // 下载完成 
  33.             if (status == 200) { 
  34.                 plus.io.resolveLocalFileSystemURL(d.filename, function(entry) { 
  35.                     setLocalFileCache(netPath, entry.toLocalURL()); 
  36.                     callback(entry.toLocalURL()); //获取当前下载路径 
  37.                 }); 
  38.             } 
  39.         }); 
  40.         dtask.start(); 
  41.     }; 
  42.  
  43.     function getLocalFileCache(netPath) { 
  44.         var FILE_CACHE_KEY = "filePathCache_" + common.hashCode(netPath); 
  45.         var localUrlObj = myStorage.getItem(FILE_CACHE_KEY); 
  46.         return localUrlObj; 
  47.     } 
  48.  

您可能想查找下面的文章:

  • MUI Hbuilder设置模拟器运行APP项目图文教程
  • MUI APP 项目收到Appstore的警告邮件
  • HBuilder mui页面怎么跳转到Android原生界面?
  • HBuilder mui框架开发的App如何查询App的uid
  • mui H5游戏平台完整源码
  • mui app在线更新
  • HBuilder打包mui app Android签名证书的生成
  • MUI H5+ app自动更新思路与实现
  • hbuilder mui IOS 平台离线打包定位插件配置
  • HBuilder mui 页面传参终极版

相关文章

  • 2017-05-31Hbuilder MUI 如何监听scroll事件?
  • 2017-05-31MUI实现百度地图定位功能
  • 2017-05-31mui 双首页secondwebview配置的使用
  • 2017-05-31Hbuilder MUI 注册短信验证60秒后重新发送
  • 2017-05-31MUI页面跳转调用原生等待框的解决方案
  • 2017-05-31Hbuilder MUI如何动态添加class属性?
  • 2017-05-31iOS平台-Native.js获取包名
  • 2017-05-31hbuilder 支付宝和微信支付插件配置
  • 2017-05-31mui uploader上传服务器端代分享(net版)
  • 2017-05-31mui css 多行文本的溢出显示省略号(移动端)

文章分类

  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure

最近更新的内容

    • MUI - 预加载
    • mui项目开发中Android原生界面跳转到5+ html页面呢?
    • 打包运行的移动APP项目,运行的时候是否依赖手机的浏览器?
    • HBuilder mui 页面初始化
    • MUI初始化滚动区域
    • iOS平台-Native.js获取包名
    • HBuilder mui ajax
    • mui 图片实现瀑布流显示
    • MUI 拍照或选取照片上传作为头像
    • Mui3.2.0中ajax设置headers为{'Content-Type': 'application/json'}发起post请求,后端接收不到数据的解决方案(php为例)

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有