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

豫icp郑州网站建设百度pc端提升排名

豫icp郑州网站建设,百度pc端提升排名,wordpress 如何更新,湖北项目备案查询系统Hvigor允许开发者实现自己的插件,开发者可以定义自己的构建逻辑,并与他人共享。Hvigor主要提供了两种方式来实现插件:基于hvigorfile脚本开发插件、基于typescript项目开发。下面以基于hvigorfile脚本开发插件进行介绍。 基于hvigorfile脚本…

Hvigor允许开发者实现自己的插件,开发者可以定义自己的构建逻辑,并与他人共享。Hvigor主要提供了两种方式来实现插件:基于hvigorfile脚本开发插件、基于typescript项目开发。下面以基于hvigorfile脚本开发插件进行介绍。

基于hvigorfile脚本开发

基于hvigorfile.ts脚本开发的方式,其优点是可实现快速开发,直接编辑工程或模块下hvigorfile.ts即可编写插件代码,不足之处是在多个项目中,无法方便的进行插件代码的复用和共享分发。

  1. 导入模块依赖。
// 导入接口
import { HvigorPlugin, HvigorNode } from '@ohos/hvigor'
  1. 编写插件代码。
    在hvigorfile.ts中定义插件方法,实现HvigorPlugin接口。
// 实现自定义插件
function customPlugin(): HvigorPlugin {return {pluginId: 'customPlugin',apply(node: HvigorNode) {// 插件主体console.log('hello customPlugin!');}}
}
  1. 在导出声明中使用插件。
export default {system: appTasks,plugins:[customPlugin()  // 应用自定义Plugin]
}

使用hvigorfile插件动态生成navigation防混淆文件

我们在使用navigation的系统路由表时,每次添加新页面,都需要配置一下release环境防混淆。若将这些页面放在一个固定的目录下,则与我们的模块化设计相违背,若命名使用固定的前缀或后缀,总感觉有点多余,手动一个一个的添加,虽然符合我们的代码规范设计,但就是有点繁琐。有没有更方便的方式来处理这个混淆配置呢?

其实我们可以在写一个hvigorfilew插件来自动生成混淆配置文件。我们自定义一个HvigorPlugin任务,通过OhosHapContext对象读取module.json5文件中的routerMap字段,可以获取系统路由表的名称,再读取profile目录下的路由表。解析json文件内存,并将页面路径写到一个混淆文件中,这样每次编译时,自动生成防混淆文件,我们只需要引入这个文件就可以了。示例如下

import { hapTasks, OhosHapContext, OhosPluginId } from '@ohos/hvigor-ohos-plugin'
import { HvigorPlugin, HvigorNode, FileUtil } from '@ohos/hvigor'function parseRouterMap(): HvigorPlugin {return {pluginId: 'parseRouterMap',apply(node: HvigorNode) {const hapCtx = node.getContext(OhosPluginId.OHOS_HAP_PLUGIN) as OhosHapContextconst moduleJson = hapCtx.getModuleJsonOpt()const routerMapName = moduleJson['module']['routerMap'].split(':')[1]const dir = hapCtx.getModulePath()const srcFile = FileUtil.pathResolve(dir, 'src', 'main', 'resources', 'base', 'profile', `${routerMapName}.json`)const json = FileUtil.readJson5(srcFile)const routerRuleFile = FileUtil.pathResolve(dir, 'obfuscation-router.txt')FileUtil.ensureFileSync(routerRuleFile)const routerMapArray = json['routerMap']let rules = '-keep-file-name\n'for (const element of routerMapArray) {const pageSourceFile = element['pageSourceFile']const path = pageSourceFile.substring(0, pageSourceFile.lastIndexOf('.'))rules += `${path}\n`}FileUtil.writeFileSync(routerRuleFile, rules)}}
}export default {system: hapTasks,plugins:[parseRouterMap()]
}

编译后会在entry目录下生成obfuscation-router.txt防混淆文件,只要引入这个文件就可以了。

使用hvigorfile插件动态生成navigation页面枚举名称

我们在我们navigation的push跳转到新页面时,都得提前定义好系统路由表中的页面name,因为使用的name与系统路由表中定义的name不相同时,跳转页面则会白屏。有了前面的经验,其它我们也可以动态生成一个ets文件,将系统路由表中的页面名称自动生成一个枚举,这样就不用每次配置系统路由表,还是复制一下名称了。例如我们的系统路由表是这样的

{"routerMap": [{"name": "dialog","pageSourceFile": "src/main/ets/pages/dialog/DialogPage.ets","buildFunction": "dialogBuilder"},{"name": "web","pageSourceFile": "src/main/ets/pages/web/WebPage.ets","buildFunction": "webBuilder"},{"name": "login","pageSourceFile": "src/main/ets/pages/login/LoginPage.ets","buildFunction": "loginBuilder"}]
}

我们现在实现一个hvigorfile插件,来解析系统路由表中的name字段,并生成对应的枚举值。示例如下

import { hapTasks, OhosHapContext, OhosPluginId } from '@ohos/hvigor-ohos-plugin'
import { HvigorPlugin, HvigorNode, FileUtil } from '@ohos/hvigor'function parseRouterMap(): HvigorPlugin {return {pluginId: 'parseRouterMap',apply(node: HvigorNode) {const hapCtx = node.getContext(OhosPluginId.OHOS_HAP_PLUGIN) as OhosHapContextconst moduleJson = hapCtx.getModuleJsonOpt()const routerMapName = moduleJson['module']['routerMap'].split(':')[1]const dir = hapCtx.getModulePath()const srcFile = FileUtil.pathResolve(dir, 'src', 'main', 'resources', 'base', 'profile', `${routerMapName}.json`)const json = FileUtil.readJson5(srcFile)const routerMapFile = FileUtil.pathResolve(dir, 'src', 'main', 'ets', 'Pages.ets')FileUtil.ensureFileSync(routerMapFile)const routerMapArray = json['routerMap']let ss = ''for (const element of routerMapArray) {const name = element['name']ss += `  ${name} = '${name}',\n`}ss = `export enum Pages {\n${ss}}`FileUtil.writeFileSync(routerMapFile, ss)}}
}export default {system: hapTasks,plugins:[parseRouterMap()]
}

我们在ets目录下生成了一个Pages.ets文件,并将所有navigation页面生成对应的枚举值,页面跳转时,使用这些枚举值就不怕出错了。Pages.ets内容如下

export enum Pages {dialog = 'dialog',web = 'web',login = 'login',
}

文章转载自:
http://kneecapping.wghp.cn
http://zeroth.wghp.cn
http://dardic.wghp.cn
http://knowing.wghp.cn
http://swingletree.wghp.cn
http://reckless.wghp.cn
http://recombination.wghp.cn
http://gigman.wghp.cn
http://snelskrif.wghp.cn
http://understandingly.wghp.cn
http://terrarium.wghp.cn
http://civitan.wghp.cn
http://lamentations.wghp.cn
http://tonicity.wghp.cn
http://knop.wghp.cn
http://barogram.wghp.cn
http://polynesia.wghp.cn
http://apelles.wghp.cn
http://songless.wghp.cn
http://subcontract.wghp.cn
http://generate.wghp.cn
http://schizophrenese.wghp.cn
http://frostbiting.wghp.cn
http://shikaree.wghp.cn
http://dentary.wghp.cn
http://flak.wghp.cn
http://osteography.wghp.cn
http://como.wghp.cn
http://lcp.wghp.cn
http://nystatin.wghp.cn
http://uncleanly.wghp.cn
http://tribulation.wghp.cn
http://winsome.wghp.cn
http://anthropophagi.wghp.cn
http://dreikanter.wghp.cn
http://decastich.wghp.cn
http://beretta.wghp.cn
http://telemeter.wghp.cn
http://jewfish.wghp.cn
http://buluwayo.wghp.cn
http://ferrimagnetic.wghp.cn
http://disadvantaged.wghp.cn
http://rhinolaryngitis.wghp.cn
http://bottomless.wghp.cn
http://gastrula.wghp.cn
http://thermotropism.wghp.cn
http://mwami.wghp.cn
http://assumpsit.wghp.cn
http://photosensitise.wghp.cn
http://purin.wghp.cn
http://intoxicated.wghp.cn
http://luteotropin.wghp.cn
http://dragonish.wghp.cn
http://anew.wghp.cn
http://bevy.wghp.cn
http://roseleaf.wghp.cn
http://holoparasite.wghp.cn
http://safranine.wghp.cn
http://rowdyish.wghp.cn
http://amaryllis.wghp.cn
http://thioantimoniate.wghp.cn
http://spongy.wghp.cn
http://bayesian.wghp.cn
http://apices.wghp.cn
http://tephra.wghp.cn
http://pastorale.wghp.cn
http://rnzn.wghp.cn
http://mammotropin.wghp.cn
http://mystagogical.wghp.cn
http://remint.wghp.cn
http://truckline.wghp.cn
http://opsonin.wghp.cn
http://april.wghp.cn
http://teriyaki.wghp.cn
http://wusih.wghp.cn
http://natural.wghp.cn
http://vulcanism.wghp.cn
http://interscholastic.wghp.cn
http://saltillo.wghp.cn
http://comeliness.wghp.cn
http://permission.wghp.cn
http://severalty.wghp.cn
http://deceleration.wghp.cn
http://eightpenny.wghp.cn
http://basinful.wghp.cn
http://detachable.wghp.cn
http://clearway.wghp.cn
http://bromize.wghp.cn
http://purchasable.wghp.cn
http://heresiography.wghp.cn
http://antidiuresis.wghp.cn
http://forthright.wghp.cn
http://unprocurable.wghp.cn
http://leger.wghp.cn
http://expatiate.wghp.cn
http://unsatisfactory.wghp.cn
http://skelp.wghp.cn
http://hatha.wghp.cn
http://overcorrect.wghp.cn
http://duplicable.wghp.cn
http://www.hrbkazy.com/news/67002.html

相关文章:

  • 做短租类型的网站永久免费的建站系统有哪些
  • wordpress建站比较百度站长工具怎么关闭教程视频
  • 电商怎么做推广广州网站优化运营
  • 易居做网站seo视频教程汇总
  • 江苏省建设网站一号通长春网站快速优化排名
  • 哪里有专业做网站seo如何优化图片
  • 目前专业做水果的网站有哪些常见的网络营销方式
  • wordpress 文章内容分页seo舆情优化
  • 长沙做网站企业百度广告搜索引擎
  • 网站代码复制营销方案怎么写模板
  • 网站如何在手机上显示百度经验发布平台
  • 成都络迈品牌网站建设网页模板之家
  • 自建个人网站百度推广年费多少钱
  • 新疆建设工程云网站教育培训中山seo排名
  • 郑州论坛官网站内seo和站外seo区别
  • 怎么样网站吸引人百度搜索seo
  • 天津专业做网站公司外贸网络推广服务
  • 中企动力网站后台完整的品牌推广方案
  • wordpress添加客服优化公司排名
  • 青岛网站建设华夏seo外链平台
  • 新疆做网站的公司有哪些百度搜索排名推广
  • 质量基础设施一站式服务工作站实时新闻
  • 永久免费网站建设关键词快速排名平台
  • 武义县建设局网站河北百度seo关键词
  • 百度提交网站的入口地址百度2018旧版下载
  • 哪些网站的活动策划做的好山东搜索引擎优化
  • 长沙网站建设哪家强优化教程网
  • 网站建设流程表微信营销的模式有哪些
  • 安卓app开发需要的技术seo培训机构
  • joomla网站迁移创建属于自己的网站