1、工程级目录build-profile.json5
{ "app": { "signingConfigs": [ { "name": "default", "type": "HarmonyOS", "material": { "storePassword": "000000196F3CD9CC858474C62B5903102CFAE25D806AC29DA9EB3202FD6414CD8A4A47F8222BF2B57E", "certpath": "C:/Users/vfuchong/.ohos/鸿蒙生产.cer", "keyAlias": "yxc123654", "keyPassword": "00000019858F695A8BBC666201620F3F3891DC51460652ED2495D8BB7FC2F731045FAA3D8A099D03FF", "profile": "C:/Users/vfuchong/.ohos/鸿蒙生产Release.p7b", "signAlg": "SHA256withECDSA", "storeFile": "C:/Users/vfuchong/.ohos/vfc.p12" } } ], "products": [ { "name": "default", "signingConfig": "default", "compatibleSdkVersion": "5.0.0(12)", "runtimeOS": "HarmonyOS", "buildOption": { "arkOptions": { "buildProfileFields": { "BASE_URL": 'https://vfcpay.com/' } }, "strictMode": { "caseSensitiveCheck": true, "useNormalizedOHMUrl": true } } }, { "name": "prod", "signingConfig": "default", "compatibleSdkVersion": "5.0.0(12)", "runtimeOS": "HarmonyOS", "buildOption": { "arkOptions": { "buildProfileFields": { "BASE_URL": 'https://hce.vfuchong.cn/' } }, "strictMode": { "caseSensitiveCheck": true, "useNormalizedOHMUrl": true } } } ], "buildModeSet": [ { "name": "debug", }, { "name": "release" } ] }, "modules": [ { "name": "entry", "srcPath": "./entry", "targets": [ { "name": "default", "applyToProducts": [ "default" ] }, { "name": "prod", "applyToProducts": [ "prod" ] } ] }, { "name": "library", "srcPath": "./library" } ] }
2、entry中 build-profiles.json5
{ "apiType": "stageMode", "buildOption": { "externalNativeOptions": { "abiFilters": ["arm64-v8a", "x86_64"] } }, "buildOptionSet": [ { "name": "release", "arkOptions": { "obfuscation": { "ruleOptions": { "enable": true, "files": [ "./obfuscation-rules.txt" ] } } } }, ], "targets": [ { "name": "default" }, { "name": "prod", } ] }
3 、生成文件
1 | hvigorw GenerateBuildProfile |
https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/ide-hvigor-get-build-profile-para-guide-V5
4、代码示例
import Config from '../../util/Config'; import { IndexComponent } from './IndexComponent'; // 确保路径正确 import { MyComponent } from './MyComponent'; // 确保路径正确 import BuildProfile from 'BuildProfile' @Builder export function HomeBuilder() { Home() } PersistentStorage.persistProp("user_id", undefined) @Entry @Component struct Home { @State selectedIndex: number = 0; pathStack: NavPathStack = new NavPathStack(); aboutToAppear(): void { console.log('1111111') console.log(BuildProfile.NEWS_DETAIL) console.log('2222222222') } build() { Navigation(this.pathStack) { Tabs({ barPosition: BarPosition.End ,index: this.selectedIndex}){ TabContent() { IndexComponent({pathStack:this.pathStack}); }.tabBar( new BottomTabBarStyle(this.selectedIndex === 0 ? $rawfile('index.png') : $rawfile('index2.png'), '首页') .labelStyle({ selectedColor: this.selectedIndex === 0 ? '#58b8fe':'#a4a4a4', unselectedColor: '#a4a4a4' }) ) TabContent(){ MyComponent({pathStack:this.pathStack}); }.tabBar( new BottomTabBarStyle(this.selectedIndex === 1 ? $rawfile('my.png') : $rawfile('my2.png'), '我的') .labelStyle({ selectedColor: this.selectedIndex === 1 ? '#58b8fe':'#a4a4a4', unselectedColor: '#a4a4a4' }) ) } .onChange((index: number) => { console.log('index:',index) this.selectedIndex = index }) } .titleMode(NavigationTitleMode.Mini).hideTitleBar(true) } }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
· 零经验选手,Compose 一天开发一款小游戏!
2021-11-01 phpstorm 实现本地与服务器代码同步