Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
zhangbo1_wd
2024-06-12 18:27:24 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
048302ff10807a728a9e46704c52eb4e9147006e
048302ff
1 parent
86d16739
编译新增build_version字段。
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
11 deletions
sight_harmony/build-profile.json5
sight_harmony/commons/wdKit/build-profile.json5
sight_harmony/commons/wdKit/hvigorfile.ts
sight_harmony/commons/wdKit/src/main/ets/utils/AppUtils.ets
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpCommonParams.ets
sight_harmony/features/wdComponent/src/main/ets/components/setting/AboutPageUI.ets
sight_harmony/build-profile.json5
View file @
048302f
...
...
@@ -50,6 +50,13 @@
"compileSdkVersion"
:
"5.0.0(12)"
,
"compatibleSdkVersion"
:
"5.0.0(12)"
,
"runtimeOS"
:
"HarmonyOS"
,
"buildOption"
:
{
"arkOptions"
:
{
"buildProfileFields"
:
{
"BUILD_VERSION"
:
""
}
}
},
}
,
{
"name"
:
"productRELEASE"
,
...
...
@@ -57,6 +64,13 @@
"compileSdkVersion"
:
"5.0.0(12)"
,
"compatibleSdkVersion"
:
"5.0.0(12)"
,
"runtimeOS"
:
"HarmonyOS"
,
"buildOption"
:
{
"arkOptions"
:
{
"buildProfileFields"
:
{
"BUILD_VERSION"
:
""
}
}
}
}
],
"buildModeSet"
:
[
...
...
sight_harmony/commons/wdKit/build-profile.json5
View file @
048302f
...
...
@@ -2,7 +2,9 @@
"apiType"
:
"stageMode"
,
"buildOption"
:
{
"arkOptions"
:
{
//
"apPath"
:
"./modules.ap"
/*
Profile
used
for
profile-guided
optimization
(PGO)
,
a
compiler
optimization
technique
to
improve
app
runtime
performance.
*/
"buildProfileFields"
:
{
"BUILD_TIME"
:
""
}
}
},
"buildOptionSet"
:
[
...
...
@@ -16,6 +18,9 @@
"./obfuscation-rules.txt"
]
}
},
"buildProfileFields"
:
{
"BUILD_TIME"
:
""
}
}
},
...
...
sight_harmony/commons/wdKit/hvigorfile.ts
View file @
048302f
import
{
hspTasks
}
from
'@ohos/hvigor-ohos-plugin'
;
import
{
appTasks
,
OhosAppContext
,
OhosPluginId
}
from
'@ohos/hvigor-ohos-plugin'
;
import
{
hvigor
,
getNode
}
from
'@ohos/hvigor'
// 获取根节点
const
rootNode
=
getNode
(
__filename
);
// 为根节点添加一个afterNodeEvaluate hook 在hook中修改根目录下的build-profile.json5的内容并使能
rootNode
.
afterNodeEvaluate
(
node
=>
{
// 获取app插件的上下文对象
const
appContext
=
node
.
getContext
(
OhosPluginId
.
OHOS_HSP_PLUGIN
)
as
OhosHspContext
;
// 通过上下文对象获取从根目录build-profile.json5文件中读出来的obj对象
const
buildProfileOpt
=
appContext
.
getBuildProfileOpt
();
buildProfileOpt
[
'buildOption'
][
'arkOptions'
][
'buildProfileFields'
]
=
{
"BUILD_VERSION"
:
getBuildVersion
(),
};
// 将obj对象设置回上下文对象以使能到构建的过程与结果中
appContext
.
setBuildProfileOpt
(
buildProfileOpt
);
})
export
default
{
system
:
hspTasks
,
/* Built-in plugin of Hvigor. It cannot be modified. */
plugins
:[]
/* Custom plugin to extend the functionality of Hvigor. */
plugins
:
[]
/* Custom plugin to extend the functionality of Hvigor. */
}
function
getBuildVersion
()
{
// build时间作为版本
let
now
=
new
Date
()
let
year
=
now
.
getFullYear
()
let
month
=
(
'0'
+
(
now
.
getMonth
()
+
1
)).
slice
(
-
2
)
let
day
=
(
'0'
+
(
now
.
getDate
())).
slice
(
-
2
)
let
hours
=
(
'0'
+
(
now
.
getHours
())).
slice
(
-
2
)
let
minutes
=
(
'0'
+
(
now
.
getMinutes
())).
slice
(
-
2
)
let
str
=
year
+
month
+
day
+
hours
+
minutes
return
str
;
}
\ No newline at end of file
...
...
sight_harmony/commons/wdKit/src/main/ets/utils/AppUtils.ets
View file @
048302f
import bundleManager from '@ohos.bundle.bundleManager';
import common from '@ohos.app.ability.common';
import { Logger } from './Logger';
import BuildProfile from 'BuildProfile';
const TAG: string = 'AppUtils';
...
...
@@ -8,9 +9,14 @@ const TAG: string = 'AppUtils';
* 与应用相关属性或操作
*/
export class AppUtils {
private static buildVersion: string = ''
static {
AppUtils.buildVersion = BuildProfile.BUILD_VERSION;
}
/**
* 获取应用名称
* 即:
咪咕视频
* 即:
人民日报
*/
static getAppName(context: common.Context): string {
// todo:获取到的是 $string:app_name
...
...
@@ -20,7 +26,6 @@ export class AppUtils {
/**
* 获取应用的包名
* 即:com.cmcc.myapplication
*/
static getPackageName(context: common.Context): string {
return context.applicationInfo?.name;
...
...
@@ -74,5 +79,12 @@ export class AppUtils {
}
return '';
}
/**
* 应用build版本,时间,如:'202405291450'
*/
static getBuildVersion(): string {
return AppUtils.buildVersion;
}
}
...
...
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpCommonParams.ets
View file @
048302f
...
...
@@ -16,7 +16,7 @@ export class HttpParams {
headers['plat'] = DeviceUtil.getPlat()
headers['Content-Type'] = 'application/json; charset=utf-8'
headers['device_id'] = DeviceUtil.clientId()
headers['build_version'] =
HttpParams.get
Version()
headers['build_version'] =
AppUtils.getBuild
Version()
headers['adcode'] = HttpUtils.getProvinceCode()
headers['os_version'] = DeviceUtil.getOsVersion()
headers['system'] = AppUtils.getOSName()
...
...
@@ -80,9 +80,4 @@ export class HttpParams {
headers['city_dode'] = encodeURI(cityCode)
}
}
private static getVersion() {
// TODO build时间,待对接build生成属性
return '202401242103';
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/setting/AboutPageUI.ets
View file @
048302f
...
...
@@ -47,7 +47,7 @@ export struct AboutPageUI {
context.getApplicationContext();
let appVerion = AppUtils.getAppVersionName()
if (StringUtils.isNotEmpty(appVerion)) {
this.version = "版本号:" + appVerion
this.version = "版本号:" + appVerion
+ '.' + AppUtils.getBuildVersion()
}
}
...
...
Please
register
or
login
to post a comment