liyubing

Merge remote-tracking branch 'origin/main'

@@ -50,6 +50,13 @@ @@ -50,6 +50,13 @@
50 "compileSdkVersion": "5.0.0(12)", 50 "compileSdkVersion": "5.0.0(12)",
51 "compatibleSdkVersion": "5.0.0(12)", 51 "compatibleSdkVersion": "5.0.0(12)",
52 "runtimeOS": "HarmonyOS", 52 "runtimeOS": "HarmonyOS",
  53 + "buildOption": {
  54 + "arkOptions": {
  55 + "buildProfileFields": {
  56 + "BUILD_VERSION": ""
  57 + }
  58 + }
  59 + },
53 }, 60 },
54 { 61 {
55 "name": "productRELEASE", 62 "name": "productRELEASE",
@@ -57,6 +64,13 @@ @@ -57,6 +64,13 @@
57 "compileSdkVersion": "5.0.0(12)", 64 "compileSdkVersion": "5.0.0(12)",
58 "compatibleSdkVersion": "5.0.0(12)", 65 "compatibleSdkVersion": "5.0.0(12)",
59 "runtimeOS": "HarmonyOS", 66 "runtimeOS": "HarmonyOS",
  67 + "buildOption": {
  68 + "arkOptions": {
  69 + "buildProfileFields": {
  70 + "BUILD_VERSION": ""
  71 + }
  72 + }
  73 + }
60 } 74 }
61 ], 75 ],
62 "buildModeSet": [ 76 "buildModeSet": [
@@ -2,7 +2,9 @@ @@ -2,7 +2,9 @@
2 "apiType": "stageMode", 2 "apiType": "stageMode",
3 "buildOption": { 3 "buildOption": {
4 "arkOptions": { 4 "arkOptions": {
5 - // "apPath": "./modules.ap" /* Profile used for profile-guided optimization (PGO), a compiler optimization technique to improve app runtime performance. */ 5 + "buildProfileFields": {
  6 + "BUILD_TIME": ""
  7 + }
6 } 8 }
7 }, 9 },
8 "buildOptionSet": [ 10 "buildOptionSet": [
@@ -16,6 +18,9 @@ @@ -16,6 +18,9 @@
16 "./obfuscation-rules.txt" 18 "./obfuscation-rules.txt"
17 ] 19 ]
18 } 20 }
  21 + },
  22 + "buildProfileFields": {
  23 + "BUILD_TIME": ""
19 } 24 }
20 } 25 }
21 }, 26 },
1 import { hspTasks } from '@ohos/hvigor-ohos-plugin'; 1 import { hspTasks } from '@ohos/hvigor-ohos-plugin';
  2 +import { appTasks, OhosAppContext, OhosPluginId } from '@ohos/hvigor-ohos-plugin';
  3 +import { hvigor, getNode } from '@ohos/hvigor'
  4 +
  5 +// 获取根节点
  6 +const rootNode = getNode(__filename);
  7 +// 为根节点添加一个afterNodeEvaluate hook 在hook中修改根目录下的build-profile.json5的内容并使能
  8 +rootNode.afterNodeEvaluate(node => {
  9 + // 获取app插件的上下文对象
  10 + const appContext = node.getContext(OhosPluginId.OHOS_HSP_PLUGIN) as OhosHspContext;
  11 + // 通过上下文对象获取从根目录build-profile.json5文件中读出来的obj对象
  12 + const buildProfileOpt = appContext.getBuildProfileOpt();
  13 + buildProfileOpt['buildOption']['arkOptions']['buildProfileFields'] = {
  14 + "BUILD_VERSION": getBuildVersion(),
  15 + };
  16 + // 将obj对象设置回上下文对象以使能到构建的过程与结果中
  17 + appContext.setBuildProfileOpt(buildProfileOpt);
  18 +})
2 19
3 export default { 20 export default {
4 - system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */  
5 - plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ 21 + system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
  22 + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
6 } 23 }
  24 +
  25 +function getBuildVersion() {
  26 + // build时间作为版本
  27 + let now = new Date()
  28 + let year = now.getFullYear()
  29 + let month = ('0' + (now.getMonth() + 1)).slice(-2)
  30 + let day = ('0' + (now.getDate())).slice(-2)
  31 + let hours = ('0' + (now.getHours())).slice(-2)
  32 + let minutes = ('0' + (now.getMinutes())).slice(-2)
  33 + let str = year + month + day + hours + minutes
  34 + return str;
  35 +}
1 import bundleManager from '@ohos.bundle.bundleManager'; 1 import bundleManager from '@ohos.bundle.bundleManager';
2 import common from '@ohos.app.ability.common'; 2 import common from '@ohos.app.ability.common';
3 import { Logger } from './Logger'; 3 import { Logger } from './Logger';
  4 +import BuildProfile from 'BuildProfile';
4 5
5 const TAG: string = 'AppUtils'; 6 const TAG: string = 'AppUtils';
6 7
@@ -8,9 +9,14 @@ const TAG: string = 'AppUtils'; @@ -8,9 +9,14 @@ const TAG: string = 'AppUtils';
8 * 与应用相关属性或操作 9 * 与应用相关属性或操作
9 */ 10 */
10 export class AppUtils { 11 export class AppUtils {
  12 + private static buildVersion: string = ''
  13 + static {
  14 + AppUtils.buildVersion = BuildProfile.BUILD_VERSION;
  15 + }
  16 +
11 /** 17 /**
12 * 获取应用名称 18 * 获取应用名称
13 - * 即:咪咕视频 19 + * 即:人民日报
14 */ 20 */
15 static getAppName(context: common.Context): string { 21 static getAppName(context: common.Context): string {
16 // todo:获取到的是 $string:app_name 22 // todo:获取到的是 $string:app_name
@@ -20,7 +26,6 @@ export class AppUtils { @@ -20,7 +26,6 @@ export class AppUtils {
20 26
21 /** 27 /**
22 * 获取应用的包名 28 * 获取应用的包名
23 - * 即:com.cmcc.myapplication  
24 */ 29 */
25 static getPackageName(context: common.Context): string { 30 static getPackageName(context: common.Context): string {
26 return context.applicationInfo?.name; 31 return context.applicationInfo?.name;
@@ -60,7 +65,6 @@ export class AppUtils { @@ -60,7 +65,6 @@ export class AppUtils {
60 } 65 }
61 66
62 static getOSName() { 67 static getOSName() {
63 - // TODO: 待确认,暂时写死Android  
64 return "Harmony" 68 return "Harmony"
65 } 69 }
66 70
@@ -74,5 +78,12 @@ export class AppUtils { @@ -74,5 +78,12 @@ export class AppUtils {
74 } 78 }
75 return ''; 79 return '';
76 } 80 }
  81 +
  82 + /**
  83 + * 应用build版本,时间,如:'202405291450'
  84 + */
  85 + static getBuildVersion(): string {
  86 + return AppUtils.buildVersion;
  87 + }
77 } 88 }
78 89
@@ -40,9 +40,6 @@ instance.interceptors.request.use( @@ -40,9 +40,6 @@ instance.interceptors.request.use(
40 // 公共请求参数 40 // 公共请求参数
41 // config.params.key = key 41 // config.params.key = key
42 Logger.debug('HttpRequest', 'request: ' + config.url) 42 Logger.debug('HttpRequest', 'request: ' + config.url)
43 - // TODO 临时打印token,测试token失效。待删除  
44 - Logger.debug('HttpRequest', 'request token: ' + config?.headers?.get('RMRB-X-TOKEN'))  
45 - Logger.debug('HttpRequest', 'request cookie: ' + config?.headers?.get('cookie'))  
46 return config; 43 return config;
47 }, 44 },
48 (error: AxiosError) => { 45 (error: AxiosError) => {
@@ -16,7 +16,7 @@ export class HttpParams { @@ -16,7 +16,7 @@ export class HttpParams {
16 headers['plat'] = DeviceUtil.getPlat() 16 headers['plat'] = DeviceUtil.getPlat()
17 headers['Content-Type'] = 'application/json; charset=utf-8' 17 headers['Content-Type'] = 'application/json; charset=utf-8'
18 headers['device_id'] = DeviceUtil.clientId() 18 headers['device_id'] = DeviceUtil.clientId()
19 - headers['build_version'] = HttpParams.getVersion() 19 + headers['build_version'] = AppUtils.getBuildVersion()
20 headers['adcode'] = HttpUtils.getProvinceCode() 20 headers['adcode'] = HttpUtils.getProvinceCode()
21 headers['os_version'] = DeviceUtil.getOsVersion() 21 headers['os_version'] = DeviceUtil.getOsVersion()
22 headers['system'] = AppUtils.getOSName() 22 headers['system'] = AppUtils.getOSName()
@@ -80,9 +80,4 @@ export class HttpParams { @@ -80,9 +80,4 @@ export class HttpParams {
80 headers['city_dode'] = encodeURI(cityCode) 80 headers['city_dode'] = encodeURI(cityCode)
81 } 81 }
82 } 82 }
83 -  
84 - private static getVersion() {  
85 - // TODO build时间,待对接build生成属性  
86 - return '202401242103';  
87 - }  
88 } 83 }
@@ -47,7 +47,7 @@ export struct AboutPageUI { @@ -47,7 +47,7 @@ export struct AboutPageUI {
47 context.getApplicationContext(); 47 context.getApplicationContext();
48 let appVerion = AppUtils.getAppVersionName() 48 let appVerion = AppUtils.getAppVersionName()
49 if (StringUtils.isNotEmpty(appVerion)) { 49 if (StringUtils.isNotEmpty(appVerion)) {
50 - this.version = "版本号:" + appVerion 50 + this.version = "版本号:" + appVerion + '.' + AppUtils.getBuildVersion()
51 } 51 }
52 } 52 }
53 53
@@ -403,7 +403,8 @@ export struct DetailPlayShortVideoPage { @@ -403,7 +403,8 @@ export struct DetailPlayShortVideoPage {
403 this.playerController.firstPlay(this.contentDetailData.videoInfo[0].videoUrl, this.PageName, this.PageName, 403 this.playerController.firstPlay(this.contentDetailData.videoInfo[0].videoUrl, this.PageName, this.PageName,
404 this.pageParam); 404 this.pageParam);
405 } 405 }
406 - } 406 + },
  407 + liftVideo: $showCommentList,
407 }) 408 })
408 .width(this.playerWidth) 409 .width(this.playerWidth)
409 .height(this.playerHeight) 410 .height(this.playerHeight)
@@ -49,6 +49,9 @@ export struct WDPlayerRenderView { @@ -49,6 +49,9 @@ export struct WDPlayerRenderView {
49 @State videoHeight: number = 9 49 @State videoHeight: number = 9
50 @State videoRatio: number = 16 / 9 50 @State videoRatio: number = 16 / 9
51 @State selfSize: Size = new Size('100%', '100%'); 51 @State selfSize: Size = new Size('100%', '100%');
  52 +
  53 + // 是否上推视频中
  54 + @Link liftVideo: boolean
52 private enableAliPlayer = false 55 private enableAliPlayer = false
53 56
54 aboutToAppear() { 57 aboutToAppear() {
@@ -61,7 +64,7 @@ export struct WDPlayerRenderView { @@ -61,7 +64,7 @@ export struct WDPlayerRenderView {
61 64
62 this.playerController.onVideoSizeChange = (width: number, height: number) => { 65 this.playerController.onVideoSizeChange = (width: number, height: number) => {
63 // console.log(`WDPlayerRenderView onVideoSizeChange width:${width} videoTop:${height}`) 66 // console.log(`WDPlayerRenderView onVideoSizeChange width:${width} videoTop:${height}`)
64 - Logger.info(TAG, ` onVideoSizeChange width:${width} videoTop:${height}`) 67 + Logger.info(TAG, ` onVideoSizeChange width:${width} height:${height}`)
65 this.videoWidth = width; 68 this.videoWidth = width;
66 this.videoHeight = height; 69 this.videoHeight = height;
67 this.videoRatio = width / height 70 this.videoRatio = width / height
@@ -127,6 +130,21 @@ export struct WDPlayerRenderView { @@ -127,6 +130,21 @@ export struct WDPlayerRenderView {
127 130
128 if (info.size.width > 0 && info.size.height > 0) { 131 if (info.size.width > 0 && info.size.height > 0) {
129 132
  133 + if (!this.liftVideo) {
  134 + if (this.videoHeight > 0 && this.videoWidth > 0) {
  135 + this.xComponentController.setXComponentSurfaceRect({
  136 + surfaceWidth: info.size.width,
  137 + surfaceHeight: info.size.width / this.videoRatio,
  138 + });
  139 + return
  140 + }
  141 + this.xComponentController.setXComponentSurfaceRect({
  142 + surfaceWidth: info.size.width,
  143 + surfaceHeight: info.size.height,
  144 + });
  145 + return
  146 + }
  147 +
130 // 竖屏 148 // 竖屏
131 if (this.videoHeight > 0 && this.videoWidth > 0 && this.videoWidth < this.videoHeight) { 149 if (this.videoHeight > 0 && this.videoWidth > 0 && this.videoWidth < this.videoHeight) {
132 let ratio = this.videoWidth / this.videoHeight 150 let ratio = this.videoWidth / this.videoHeight