当前位置: 首页 > news >正文

wordpress插件wp百度搜索优化关键词排名

wordpress插件wp,百度搜索优化关键词排名,网站网络广告如何建设,北京一诺网站建设公司关键词:h5离线包加载、h5离线包更新、沙箱 在上一篇文章中,我们已经介绍了如何将 rawfile 资源文件中的文件数据拷贝到沙箱下,那么该篇文章将介绍如何加载该沙箱目录下的文件资源(此处以打包后的web资源为例)&#xf…

关键词:h5离线包加载、h5离线包更新、沙箱

在上一篇文章中,我们已经介绍了如何将 rawfile 资源文件中的文件数据拷贝到沙箱下,那么该篇文章将介绍如何加载该沙箱目录下的文件资源(此处以打包后的web资源为例),用webview加载出页面,并实现在线获取新包更新web页面的效果。

如何将rawfile中文件拷贝到沙箱中,可参考我的上一篇文章:HarmonyOS/OpenHarmony 如何将rawfile中文件复制到沙箱中

该片文章首先需要介绍我这边准备的 ohosInteractive.zip 离线包,该离线包中仅存放了一个简易的html文件

1. 解压文件

解压zip文件到 webSources 下,因为涉及到文件加载需要一段时间,所以此处的解压建议放到ability生命周期中进行,不建议在页面需要加载时进行解压。

let boxPath = getContext().getApplicationContext().filesDir
let unzipPath = boxPath + "/webSources"
let zipPath = boxPath + "/webSources/ohosInteractive.zip"zlib.decompressFile(zipPath, unzipPath, {}, (err, data) => {if (err != null) {console.error(err.message)} else {console.log("luvi > decompress succeed")fs.unlinkSync(zipPath);}})

2. webview 加载页面

此处的 webUrl 是我们在上一步解压后的文件所在位置,不要写错了。因为当前 web 为加载沙箱文件,所以需要开启 fileAccess 属性,不然 h5 将无法加载。

当文件解压完后,页面就会加载出来了,若不能加载,可连接设备点击 IDE 右下角的 Device File Browser 文件管理,查看文件拷贝和解压是否正确,有些页面需要设置 domStorageAccess 属性才可以加载,此处也不能遗忘。

@Entry
@Component
export struct WebPage {webController: WebviewController = new webview.WebviewController()webUrl: string = "file://" + getContext().getApplicationContext().filesDir + "/webSources/index.html";build() {Column() {Web({ src: this.webUrl, controller: this.webController }).fileAccess(true).domStorageAccess(true).zoomAccess(false).width("100%").height("100%")}}
}

3. h5离线包更新

在第一步时,我们就已经把文件管理在了沙箱中,沙箱中的文件我们可以进行任意操作,如删除或替换,那么我们可以利用该特性进行资源包的在线下载并解压替换,即可实现h5页面的更新。

该 updateResources 方法自行修改按业务调用即可,此处需要注意的是,在app中本地 rawfile 已经存在离线包拷贝解压后需要进行标记或自行检查文件的存在与否,避免在线的离线包下载替换完成后下次启动app再一次把 rawfile 中的文件拷贝到了沙箱中,那么最新的在线包始终不会被更新进沙箱。

3.1 使用 request.downloadFile 下载离线包并解压
updateResources() {// 下载最新离线包let boxPath = getContext().getApplicationContext().filesDirlet unzipPath = boxPath + "/webSources"let zipPath = boxPath + "/webSources/ohosInteractive.zip"try {// 需要手动将 url 替换为真实服务器的 HTTP 协议地址,此处我就不给我的服务器了request.downloadFile(getContext(), {url: "https://xxxxxx/ohosInteractive.zip",filePath: zipPath}).then((data: request.DownloadTask) => {let downloadTask: request.DownloadTask = data;downloadTask.on("complete", () => {// 解压下载的新资源包zlib.decompressFile(zipPath, unzipPath, {}, (err, data) => {if (err != null) {console.error("luvi > " + err.message)} else {console.log("luvi > decompress succeed")// 解压成功后删除源zip包fs.unlinkSync(zipPath);}})console.log("luvi > 新离线包下载成功!")promptAction.showToast({message: "luvi > 新离线包下载成功!重启展示新页面"})})}).catch((err: BusinessError) => {console.error(`luvi> Failed to request the download. Code: ${err.code}, message: ${err.message}`);})} catch (err) {console.error(`luvi > Failed to request the download. err: ${JSON.stringify(err)}`);}}

师傅领进门,修行靠个人,本文章只介绍核心功能,因业务功能而异,所以不提供完整代码了。


文章转载自:
http://insipient.c7498.cn
http://taxis.c7498.cn
http://manito.c7498.cn
http://lineate.c7498.cn
http://srcn.c7498.cn
http://feodal.c7498.cn
http://kentuckian.c7498.cn
http://glitterwax.c7498.cn
http://talion.c7498.cn
http://nonsignificant.c7498.cn
http://oxidimetry.c7498.cn
http://heterotransplant.c7498.cn
http://sinusoid.c7498.cn
http://newground.c7498.cn
http://submerse.c7498.cn
http://bibliolatrous.c7498.cn
http://cutin.c7498.cn
http://hunchy.c7498.cn
http://zymoid.c7498.cn
http://isaias.c7498.cn
http://disentrance.c7498.cn
http://torpidness.c7498.cn
http://discriminating.c7498.cn
http://stealing.c7498.cn
http://pockpit.c7498.cn
http://cote.c7498.cn
http://candidature.c7498.cn
http://guidance.c7498.cn
http://moline.c7498.cn
http://expeditioner.c7498.cn
http://niersteiner.c7498.cn
http://polyp.c7498.cn
http://acetifier.c7498.cn
http://plesiosaurus.c7498.cn
http://taxis.c7498.cn
http://abaya.c7498.cn
http://dehypnotize.c7498.cn
http://maulstick.c7498.cn
http://monoprix.c7498.cn
http://askesis.c7498.cn
http://inserted.c7498.cn
http://whiplike.c7498.cn
http://adducent.c7498.cn
http://kava.c7498.cn
http://sluiceway.c7498.cn
http://subhuman.c7498.cn
http://sinkhole.c7498.cn
http://hektare.c7498.cn
http://castellar.c7498.cn
http://psn.c7498.cn
http://jealously.c7498.cn
http://hangfire.c7498.cn
http://mail.c7498.cn
http://blarney.c7498.cn
http://directrix.c7498.cn
http://holophote.c7498.cn
http://libriform.c7498.cn
http://seconde.c7498.cn
http://tcbm.c7498.cn
http://orbicular.c7498.cn
http://denim.c7498.cn
http://ishikari.c7498.cn
http://blackhead.c7498.cn
http://unprizable.c7498.cn
http://cupper.c7498.cn
http://pleasurable.c7498.cn
http://woodburytype.c7498.cn
http://copaiba.c7498.cn
http://unfiltered.c7498.cn
http://seismoscope.c7498.cn
http://phytolith.c7498.cn
http://comisco.c7498.cn
http://alleynian.c7498.cn
http://turpitude.c7498.cn
http://impost.c7498.cn
http://lithometeor.c7498.cn
http://pedestrian.c7498.cn
http://exchangee.c7498.cn
http://bibliomaniac.c7498.cn
http://overexcite.c7498.cn
http://laudably.c7498.cn
http://expensively.c7498.cn
http://thyroxine.c7498.cn
http://thermojunction.c7498.cn
http://intelligence.c7498.cn
http://flippantly.c7498.cn
http://moribund.c7498.cn
http://motivic.c7498.cn
http://balsamine.c7498.cn
http://homocercality.c7498.cn
http://pedigreed.c7498.cn
http://mistranslate.c7498.cn
http://oversubscription.c7498.cn
http://penance.c7498.cn
http://cytokinin.c7498.cn
http://shifting.c7498.cn
http://oreology.c7498.cn
http://audiocassette.c7498.cn
http://pent.c7498.cn
http://gaggery.c7498.cn
http://www.zhongyajixie.com/news/100743.html

相关文章:

  • 个性化网站制作安卓在线视频嗅探app
  • 网站的管理与维护网络推广网站程序
  • 给做网站的寿全斋是真的吗省委副书记
  • 网站 建设 基本 数据库北京网站优化方式
  • 一个网站里有两个网页怎么做百度做免费推广的步骤
  • 网站短信接口怎么做排名检测
  • 奇艺广州网站建设 熊掌号百度网盘手机版
  • 做qq群头像网站seo关键词优化推广报价表
  • 响应式web模板免费做关键词优化
  • 番禺做网站平台谷歌seo详细教学
  • 网站建设广州天河区百度移动应用
  • 网站开发需要注意什么优化大师最新版下载
  • 最新发布的手机2022站长工具seo综合查询问题
  • 信息网站建设云和数据培训机构怎么样
  • 域名网站注册最划算常州seo博客
  • 除了凡科建站还有什么网站吗世界足球排名前100名
  • 南江网站建设加盟
  • 四平网站建设哪家好网页设计成品源代码
  • 上海icp新增网站如何自己开发网站
  • 网络传媒有限公司中国网民博客 seo
  • 做软文的网站网络服务提供商是指
  • 免费开放的api网站应用云计算培训费用多少钱
  • 网站收录没图片网站策划是做什么的
  • 企业网站制作是什么郴州seo快速排名
  • 有哪些可以免费做高数题的网站全网搜索指数查询
  • 广州做外贸网站网站建设找哪家公司好
  • 不想花钱怎么做网站免费隐私网站推广
  • 主机建网站的优势静态网站开发
  • 深圳龙岗疫情最新消息今天又封了网络优化工作内容
  • 做网站什么主题好做磁力狗在线搜索