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

啥是东莞网站制作公司昆山市住房和城乡建设局网站

啥是东莞网站制作公司,昆山市住房和城乡建设局网站,搞软件开发工资高吗,备案名称网站名称找了一圈发现官方的文档都是最新的,3.2很多API都不支持,比如获取OhosAppContext,通过OhosAppContext来获取应用版本号,最终是通过读取app.json5的文件内容来读取版本号,最终修改entry下的hvigorfile.ts如下&#xff0c…

找了一圈发现官方的文档都是最新的,3.2很多API都不支持,比如获取OhosAppContext,通过OhosAppContext来获取应用版本号,最终是通过读取app.json5的文件内容来读取版本号,最终修改entry下的hvigorfile.ts如下,执行./hvigorw assembleHap,或者编译打包就可以生成新的hap名字了

import { hapTasks } from '@ohos/hvigor-ohos-plugin';
import fs from 'fs'
import { HvigorNode, HvigorPlugin, HvigorTaskContext } from "@ohos/hvigor";
import { OhosAppContext, OhosPluginId } from '@ohos/hvigor-ohos-plugin';
import { AppJson } from "@ohos/hvigor-ohos-plugin/src/options/configure/app-json-options";const getDate = () => {return new Date().toISOString().split('T')[0]; // 返回 YYYY-MM-DD 格式
};export function rename(): HvigorPlugin {return {pluginId: 'renameHapPlugin',apply(node: HvigorNode) {// 插件主体node.registerTask({// 任务名称name: 'renameHapTask',// 重命名任务在default@SignHap任务执行完成后执行dependencies: ['default@SignHap'],// 重命名任务在default@assembleHap任务执行完成前执行postDependencies: ['assembleHap'],run: (taskContext: HvigorTaskContext) => {console.log(`开始执行重命名任务`)// 获取模块名const moduleName = taskContext.moduleName// 获取模块路径const modulePath = taskContext.modulePath// 假设我们在entry目录的hvigorfile.ts文件调用插件,那拿到的模块名就是entry,模块路径就是entry模块的绝对路径。console.log(`模块名:${moduleName}`)console.log(`模块路径:${modulePath}`)// hap所在路径const originSignFilePath = `${modulePath}/build/default/outputs/default/${moduleName}-default-signed.hap`const originUnsignFilePath = `${modulePath}/build/default/outputs/default/${moduleName}-default-unsigned.hap`console.log(`原签名文件路径:${originSignFilePath}`)console.log(`原未签名文件路径:${originUnsignFilePath}`)// 新文件所在的目录const targetFileDir = `${modulePath}/build/default/outputs/default/target`// 创建目录fs.mkdir(targetFileDir, { recursive: true }, (err) => {console.log(`目录创建失败:{err}`)})// 获取父节点// const parentNode = node.getParentNode()// // 获取OhosAppContext// const appContext = parentNode?.getContext(OhosPluginId.OHOS_APP_PLUGIN) as OhosAppContext// 获取项目名// 获取AppScope目录下app.json文件里面的json// const appOptObj: AppJson.AppOptObj = appContext.getAppJsonOpt()const appJsonPath = './AppScope/app.json5';const content = fs.readFileSync(appJsonPath, 'utf8');const appJson = JSON.parse(content);// 只获取版本号const versionName = appJson.app.description;console.log(`app.json5获取的版本号:${versionName}`)// const versionName = versionconsole.log(`版本:${versionName}`)const date = getDate()// 新文件路径const targetSignFilePath = `${modulePath}/build/default/outputs/default/target/${versionName}_${date}-signed.hap`const targetUnsignFilePath = `${modulePath}/build/default/outputs/default/target/${versionName}_${date}-default-unsigned.hap`// 复制文件if (fs.existsSync(originSignFilePath)) {// 原文件存在才复制fs.copyFileSync(originSignFilePath, targetSignFilePath)// fs.unlink(originSignFilePath, (err: BusinessError) => {// })}if (fs.existsSync(originUnsignFilePath)) {// 原文件存在才复制fs.copyFileSync(originUnsignFilePath, targetUnsignFilePath)// fs.unlink(originUnsignFilePath, (err: BusinessError) => {// })}console.log(`重命名任务执行完成`)}})// const hapContext = node.getContext(OhosPluginId.OHOS_HAP_PLUGIN) as OhosHapContext;// const buildProfile = appContext.getBuildProfileOpt()//// buildProfile.app.products[0].output.artifactName = 'TestartifactName.0.0.1';//// appContext.setBuildProfileOpt(buildProfile);}}
}export default {system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */plugins: [rename()]         /* Custom plugin to extend the functionality of Hvigor. */
}
http://www.yayakq.cn/news/182263/

相关文章:

  • 锐速做网站联盟营销网站有哪些
  • 深圳建设工程交易网站官网学院网站建设的作用
  • 怎么做自助购物网站重庆网站托管外包公司哪家好
  • 石家庄网站建设智美wordpress调用菜单的代码
  • 山东省建设厅举报网站哈尔滨做网站价格
  • 阿里网站seo浏览不良网页的危害
  • 报考建设八大员官方网站宁夏枸杞网站建设方案
  • 十大网站平台网站关键词越多越好吗
  • 新塘网站seo优化如何将自己做的网站变成中文
  • 网站建设个人主页图linux 做网站数据库
  • 江西通威公路建设集团有限公司网站深圳网站建设制作优化
  • 深圳外贸网站公司南宁品牌网站建设
  • 17网站一起做网店广珠海教育局系统网站
  • 玉环市建设规划局网站wordpress主题大全
  • 网站源码修复杭州网络游戏公司排名
  • 高端婚纱摄影网站html制作新闻页面代码
  • 模板网站怎么用接go语言网站开发
  • 网站如何去分析大学校园网站建设的
  • 电脑版网站转手机版怎么做个人网站建站系统
  • 智能建站源码百度域名怎么注册
  • 网站设置为默认主页慈城旅游网站建设策划书
  • 深圳市住房和建设局网站住房保障网站分类有哪几类
  • 免费做初级会计试题网站有哪些asp做微网站设计
  • 网站进不去怎么解决做汽车价格的网站建设
  • 做播放器电影网站需要多少钱6口碑好的网站定制公司
  • 常州哪有做网站wordpress 登录后跳转
  • 个人网站备案需要多久做网站年入百万
  • 开发国外优惠卷网站如何做推广seo主管招聘
  • 公司企业网站模板wordpress 后台登陆美化
  • 三只松鼠的网站建设wechat下载app