ref |> 启动性能优化
1、log性能优化 2、启动web相关初始化延迟 Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
Showing
23 changed files
with
176 additions
and
59 deletions
| @@ -48,20 +48,26 @@ export class NetworkManager { | @@ -48,20 +48,26 @@ export class NetworkManager { | ||
| 48 | Logger.info(TAG, 'register success'); | 48 | Logger.info(TAG, 'register success'); |
| 49 | }) | 49 | }) |
| 50 | this.netCon.on('netAvailable', (data: connection.NetHandle) => { | 50 | this.netCon.on('netAvailable', (data: connection.NetHandle) => { |
| 51 | - Logger.info(TAG, 'netAvailable, data is: ' + JSON.stringify(data)) | 51 | + Logger.infoOptimize(TAG, () => { |
| 52 | + return 'netAvailable, data is: ' + JSON.stringify(data) | ||
| 53 | + }) | ||
| 52 | }) | 54 | }) |
| 53 | this.netCon.on('netBlockStatusChange', (data: connection.NetBlockStatusInfo) => { | 55 | this.netCon.on('netBlockStatusChange', (data: connection.NetBlockStatusInfo) => { |
| 54 | Logger.info(TAG, 'netBlockStatusChange, data is: ' + JSON.stringify(data)) | 56 | Logger.info(TAG, 'netBlockStatusChange, data is: ' + JSON.stringify(data)) |
| 55 | // TODO 网络阻塞,是否创建新的网络、提示 | 57 | // TODO 网络阻塞,是否创建新的网络、提示 |
| 56 | }) | 58 | }) |
| 57 | this.netCon.on('netCapabilitiesChange', (data: connection.NetCapabilityInfo) => { | 59 | this.netCon.on('netCapabilitiesChange', (data: connection.NetCapabilityInfo) => { |
| 58 | - Logger.info(TAG, 'netCapabilitiesChange, data is: ' + JSON.stringify(data)) | 60 | + Logger.infoOptimize(TAG, () => { |
| 61 | + return 'netCapabilitiesChange, data is: ' + JSON.stringify(data) | ||
| 62 | + }) | ||
| 59 | this.parseData(data) | 63 | this.parseData(data) |
| 60 | // 可能多次通知 | 64 | // 可能多次通知 |
| 61 | EmitterUtils.sendEvent(EmitterEventId.NETWORK_CONNECTED, JSON.stringify(this.networkType)) | 65 | EmitterUtils.sendEvent(EmitterEventId.NETWORK_CONNECTED, JSON.stringify(this.networkType)) |
| 62 | }) | 66 | }) |
| 63 | this.netCon.on('netConnectionPropertiesChange', (data: connection.NetConnectionPropertyInfo) => { | 67 | this.netCon.on('netConnectionPropertiesChange', (data: connection.NetConnectionPropertyInfo) => { |
| 64 | - Logger.info(TAG, 'netConnectionPropertiesChange, data is: ' + JSON.stringify(data)) | 68 | + Logger.infoOptimize(TAG, () => { |
| 69 | + return 'netConnectionPropertiesChange, data is: ' + JSON.stringify(data) | ||
| 70 | + }) | ||
| 65 | }) | 71 | }) |
| 66 | 72 | ||
| 67 | this.netCon.on('netUnavailable', ((data: void) => { | 73 | this.netCon.on('netUnavailable', ((data: void) => { |
| @@ -10,8 +10,22 @@ const TAG: string = 'AppUtils'; | @@ -10,8 +10,22 @@ const TAG: string = 'AppUtils'; | ||
| 10 | */ | 10 | */ |
| 11 | export class AppUtils { | 11 | export class AppUtils { |
| 12 | private static buildVersion: string = '' | 12 | private static buildVersion: string = '' |
| 13 | + private static buildProductName: string = '' | ||
| 14 | + private static buildBuildModeName: string = '' | ||
| 13 | static { | 15 | static { |
| 14 | AppUtils.buildVersion = BuildProfile.BUILD_VERSION; | 16 | AppUtils.buildVersion = BuildProfile.BUILD_VERSION; |
| 17 | + AppUtils.buildProductName = BuildProfile.PRODUCT_NAME; | ||
| 18 | + AppUtils.buildBuildModeName = BuildProfile.BUILD_MODE_NAME; | ||
| 19 | + | ||
| 20 | + Logger.isDebug = !AppUtils.isProductRELEASE() | ||
| 21 | + // Logger.isDebug = false | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + public static isProductRELEASE() { | ||
| 25 | + if (AppUtils.buildProductName == "productRELEASE" && AppUtils.buildBuildModeName == "release") { | ||
| 26 | + return true | ||
| 27 | + } | ||
| 28 | + return false | ||
| 15 | } | 29 | } |
| 16 | 30 | ||
| 17 | // 全局应用context | 31 | // 全局应用context |
| @@ -118,7 +118,9 @@ export class KVStoreHelper { | @@ -118,7 +118,9 @@ export class KVStoreHelper { | ||
| 118 | return; | 118 | return; |
| 119 | } | 119 | } |
| 120 | success(data) | 120 | success(data) |
| 121 | - Logger.debug(TAG, `Succeeded in getting data. Data:${data}`); | 121 | + Logger.debugOptimize(TAG, () => { |
| 122 | + return `Succeeded in getting data. Data:${data}` | ||
| 123 | + }); | ||
| 122 | }); | 124 | }); |
| 123 | } catch (e) { | 125 | } catch (e) { |
| 124 | success(def) | 126 | success(def) |
| @@ -20,7 +20,7 @@ enum LogLevel { | @@ -20,7 +20,7 @@ enum LogLevel { | ||
| 20 | */ | 20 | */ |
| 21 | export class Logger { | 21 | export class Logger { |
| 22 | private static domain: number = 0xFF00; | 22 | private static domain: number = 0xFF00; |
| 23 | - private static prefix: string = 'SightApp'; | 23 | + private static prefix: string = 'RMRB'; |
| 24 | private static format: string = `%{public}s, %{public}s`; | 24 | private static format: string = `%{public}s, %{public}s`; |
| 25 | private static format_ext: string = `%{public}s`; | 25 | private static format_ext: string = `%{public}s`; |
| 26 | /** | 26 | /** |
| @@ -28,6 +28,7 @@ export class Logger { | @@ -28,6 +28,7 @@ export class Logger { | ||
| 28 | */ | 28 | */ |
| 29 | private static CHUNK_SIZE: number = 3500; | 29 | private static CHUNK_SIZE: number = 3500; |
| 30 | static isDebug: boolean = true; | 30 | static isDebug: boolean = true; |
| 31 | + static isCloseOptimzied: boolean = true; | ||
| 31 | 32 | ||
| 32 | /** | 33 | /** |
| 33 | * constructor. | 34 | * constructor. |
| @@ -35,7 +36,7 @@ export class Logger { | @@ -35,7 +36,7 @@ export class Logger { | ||
| 35 | * @param Prefix Identifies the log tag. | 36 | * @param Prefix Identifies the log tag. |
| 36 | * @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF. | 37 | * @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF. |
| 37 | */ | 38 | */ |
| 38 | - constructor(prefix: string = 'SightApp', domain: number = 0xFF00) { | 39 | + constructor(prefix: string = 'RMRB', domain: number = 0xFF00) { |
| 39 | Logger.prefix = prefix; | 40 | Logger.prefix = prefix; |
| 40 | Logger.domain = domain; | 41 | Logger.domain = domain; |
| 41 | } | 42 | } |
| @@ -47,6 +48,16 @@ export class Logger { | @@ -47,6 +48,16 @@ export class Logger { | ||
| 47 | Logger.logContent(LogLevel.DEBUG, ...args) | 48 | Logger.logContent(LogLevel.DEBUG, ...args) |
| 48 | } | 49 | } |
| 49 | 50 | ||
| 51 | + static debugOptimize(tag: string, func: () => string) { | ||
| 52 | + if (!Logger.isDebug || Logger.isCloseOptimzied) { | ||
| 53 | + return | ||
| 54 | + } | ||
| 55 | + let param: string[] = [] | ||
| 56 | + param.push(tag) | ||
| 57 | + param.push(func()) | ||
| 58 | + Logger.logContent(LogLevel.DEBUG, ...param) | ||
| 59 | + } | ||
| 60 | + | ||
| 50 | static info(...args: string[]) { | 61 | static info(...args: string[]) { |
| 51 | if (!Logger.isDebug) { | 62 | if (!Logger.isDebug) { |
| 52 | return | 63 | return |
| @@ -54,6 +65,16 @@ export class Logger { | @@ -54,6 +65,16 @@ export class Logger { | ||
| 54 | Logger.logContent(LogLevel.INFO, ...args) | 65 | Logger.logContent(LogLevel.INFO, ...args) |
| 55 | } | 66 | } |
| 56 | 67 | ||
| 68 | + static infoOptimize(tag: string, func: () => string) { | ||
| 69 | + if (!Logger.isDebug || Logger.isCloseOptimzied) { | ||
| 70 | + return | ||
| 71 | + } | ||
| 72 | + let param: string[] = [] | ||
| 73 | + param.push(tag) | ||
| 74 | + param.push(func()) | ||
| 75 | + Logger.logContent(LogLevel.INFO, ...param) | ||
| 76 | + } | ||
| 77 | + | ||
| 57 | static warn(...args: string[]) { | 78 | static warn(...args: string[]) { |
| 58 | if (!Logger.isDebug) { | 79 | if (!Logger.isDebug) { |
| 59 | return | 80 | return |
| @@ -61,13 +82,33 @@ export class Logger { | @@ -61,13 +82,33 @@ export class Logger { | ||
| 61 | Logger.logContent(LogLevel.WARN, ...args) | 82 | Logger.logContent(LogLevel.WARN, ...args) |
| 62 | } | 83 | } |
| 63 | 84 | ||
| 85 | + static warnOptimize(tag: string, func: () => string) { | ||
| 86 | + if (!Logger.isDebug || Logger.isCloseOptimzied) { | ||
| 87 | + return | ||
| 88 | + } | ||
| 89 | + let param: string[] = [] | ||
| 90 | + param.push(tag) | ||
| 91 | + param.push(func()) | ||
| 92 | + Logger.logContent(LogLevel.WARN, ...param) | ||
| 93 | + } | ||
| 94 | + | ||
| 64 | static error(...args: string[]) { | 95 | static error(...args: string[]) { |
| 65 | - if (!Logger.isDebug) { | 96 | + if (!Logger.isDebug || Logger.isCloseOptimzied) { |
| 66 | return | 97 | return |
| 67 | } | 98 | } |
| 68 | Logger.logContent(LogLevel.ERROR, ...args) | 99 | Logger.logContent(LogLevel.ERROR, ...args) |
| 69 | } | 100 | } |
| 70 | 101 | ||
| 102 | + static errorOptimize(tag: string, func: () => string) { | ||
| 103 | + if (!Logger.isDebug || Logger.isCloseOptimzied) { | ||
| 104 | + return | ||
| 105 | + } | ||
| 106 | + let param: string[] = [] | ||
| 107 | + param.push(tag) | ||
| 108 | + param.push(func()) | ||
| 109 | + Logger.logContent(LogLevel.ERROR, ...param) | ||
| 110 | + } | ||
| 111 | + | ||
| 71 | static fatal(...args: string[]) { | 112 | static fatal(...args: string[]) { |
| 72 | if (!Logger.isDebug) { | 113 | if (!Logger.isDebug) { |
| 73 | return | 114 | return |
| @@ -75,6 +116,16 @@ export class Logger { | @@ -75,6 +116,16 @@ export class Logger { | ||
| 75 | Logger.logContent(LogLevel.FATAL, ...args) | 116 | Logger.logContent(LogLevel.FATAL, ...args) |
| 76 | } | 117 | } |
| 77 | 118 | ||
| 119 | + static fatalOptimize(tag: string, func: () => string) { | ||
| 120 | + if (!Logger.isDebug || Logger.isCloseOptimzied) { | ||
| 121 | + return | ||
| 122 | + } | ||
| 123 | + let param: string[] = [] | ||
| 124 | + param.push(tag) | ||
| 125 | + param.push(func()) | ||
| 126 | + Logger.logContent(LogLevel.FATAL, ...param) | ||
| 127 | + } | ||
| 128 | + | ||
| 78 | static isLoggable(level: LogLevel) { | 129 | static isLoggable(level: LogLevel) { |
| 79 | if (!Logger.isDebug) { | 130 | if (!Logger.isDebug) { |
| 80 | return | 131 | return |
| @@ -103,7 +154,7 @@ export class Logger { | @@ -103,7 +154,7 @@ export class Logger { | ||
| 103 | 154 | ||
| 104 | let prefix = Logger.prefix | 155 | let prefix = Logger.prefix |
| 105 | if (tag) { | 156 | if (tag) { |
| 106 | - prefix = tag | 157 | + prefix += "-" + tag |
| 107 | } | 158 | } |
| 108 | 159 | ||
| 109 | switch (level) { | 160 | switch (level) { |
| @@ -129,7 +180,7 @@ export class Logger { | @@ -129,7 +180,7 @@ export class Logger { | ||
| 129 | 180 | ||
| 130 | let prefix = Logger.prefix | 181 | let prefix = Logger.prefix |
| 131 | if (tag) { | 182 | if (tag) { |
| 132 | - prefix = tag | 183 | + prefix += "-" + tag |
| 133 | } | 184 | } |
| 134 | 185 | ||
| 135 | switch (level) { | 186 | switch (level) { |
| @@ -30,6 +30,8 @@ const instance: AxiosInstance = axios.create({ | @@ -30,6 +30,8 @@ const instance: AxiosInstance = axios.create({ | ||
| 30 | // withCredentials: true | 30 | // withCredentials: true |
| 31 | }); | 31 | }); |
| 32 | 32 | ||
| 33 | +const TAG = "HttpRequest" | ||
| 34 | + | ||
| 33 | // 添加请求拦截器 | 35 | // 添加请求拦截器 |
| 34 | instance.interceptors.request.use( | 36 | instance.interceptors.request.use( |
| 35 | (config: InternalAxiosRequestConfig) => { | 37 | (config: InternalAxiosRequestConfig) => { |
| @@ -39,12 +41,14 @@ instance.interceptors.request.use( | @@ -39,12 +41,14 @@ instance.interceptors.request.use( | ||
| 39 | } | 41 | } |
| 40 | // 公共请求参数 | 42 | // 公共请求参数 |
| 41 | // config.params.key = key | 43 | // config.params.key = key |
| 42 | - Logger.debug('HttpRequest', 'request: ' + config.url) | 44 | + Logger.debugOptimize(TAG, () => { |
| 45 | + return 'request: ' + config.url | ||
| 46 | + }) | ||
| 43 | return config; | 47 | return config; |
| 44 | }, | 48 | }, |
| 45 | (error: AxiosError) => { | 49 | (error: AxiosError) => { |
| 46 | // 请求错误 | 50 | // 请求错误 |
| 47 | - console.log(`全局请求失败拦截,message:${error.message}`) | 51 | + Logger.error(`全局请求失败拦截,message:${error.message}`) |
| 48 | return Promise.reject(error); | 52 | return Promise.reject(error); |
| 49 | } | 53 | } |
| 50 | ); | 54 | ); |
| @@ -88,13 +92,15 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r | @@ -88,13 +92,15 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r | ||
| 88 | // } | 92 | // } |
| 89 | // const data: ResponseBean<any> = response.data | 93 | // const data: ResponseBean<any> = response.data |
| 90 | 94 | ||
| 91 | - Logger.debug('HttpRequest', 'response ==============start=================') | ||
| 92 | - Logger.debug('HttpRequest', 'response: ' + JSON.stringify(response.data)) | ||
| 93 | - Logger.debug('HttpRequest', 'response ==============end=================') | 95 | + Logger.debug(TAG, 'response ==============start=================') |
| 96 | + Logger.debugOptimize(TAG, () => { | ||
| 97 | + return 'response: ' + JSON.stringify(response.data) | ||
| 98 | + }) | ||
| 99 | + Logger.debug(TAG, 'response ==============end=================') | ||
| 94 | // 改造返回的数据,即将AxiosResponse的data返回,服务端返回的数据 | 100 | // 改造返回的数据,即将AxiosResponse的data返回,服务端返回的数据 |
| 95 | return response.data; | 101 | return response.data; |
| 96 | } else { | 102 | } else { |
| 97 | - console.log(`httpStatus:${response.status}-${response.status}!`) | 103 | + Logger.error(TAG, `httpStatus:${response.status}-${response.status}!`) |
| 98 | // return Promise.reject(error); | 104 | // return Promise.reject(error); |
| 99 | return response.data; | 105 | return response.data; |
| 100 | } | 106 | } |
| @@ -107,7 +113,7 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r | @@ -107,7 +113,7 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r | ||
| 107 | if (error != null && error.response != null) { | 113 | if (error != null && error.response != null) { |
| 108 | let message = buildErrorMsg(error.response.status); | 114 | let message = buildErrorMsg(error.response.status); |
| 109 | // 错误消息可以使用全局弹框展示出来 | 115 | // 错误消息可以使用全局弹框展示出来 |
| 110 | - console.log(`httpStatus:${error.response?.status}-${message},请检查网络或联系管理员!`) | 116 | + Logger.error(`httpStatus:${error.response?.status}-${message},请检查网络或联系管理员!`) |
| 111 | errorBean = buildError(error.response.status) | 117 | errorBean = buildError(error.response.status) |
| 112 | } | 118 | } |
| 113 | return Promise.reject(errorBean); | 119 | return Promise.reject(errorBean); |
| @@ -33,7 +33,9 @@ export class AppLinkingManager { | @@ -33,7 +33,9 @@ export class AppLinkingManager { | ||
| 33 | this.onNewWant(want, true) | 33 | this.onNewWant(want, true) |
| 34 | } | 34 | } |
| 35 | onNewWant(want: Want, startup: boolean = false) { | 35 | onNewWant(want: Want, startup: boolean = false) { |
| 36 | - Logger.debug(TAG, "want: " + JSON.stringify(want)) | 36 | + Logger.debugOptimize(TAG, () => { |
| 37 | + return "want: " + JSON.stringify(want) | ||
| 38 | + }) | ||
| 37 | let uri = want?.uri | 39 | let uri = want?.uri |
| 38 | if (!uri) { | 40 | if (!uri) { |
| 39 | return | 41 | return |
| @@ -70,7 +70,9 @@ export struct WdWebComponent { | @@ -70,7 +70,9 @@ export struct WdWebComponent { | ||
| 70 | for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) { | 70 | for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) { |
| 71 | let handleName = H5CallNativeType.JsCallTypeList[i]; | 71 | let handleName = H5CallNativeType.JsCallTypeList[i]; |
| 72 | let handle = (data: Message, f: Callback) => { | 72 | let handle = (data: Message, f: Callback) => { |
| 73 | - Logger.debug('registerHandlers handlerName: ' + JSON.stringify(data)) | 73 | + Logger.debugOptimize(TAG, () => { |
| 74 | + return 'recivedData: ' + JSON.stringify(data) | ||
| 75 | + }) | ||
| 74 | this.defaultPerformJSCallNative(data, f) | 76 | this.defaultPerformJSCallNative(data, f) |
| 75 | this.defaultGetReceiveSubjectData(data, f) | 77 | this.defaultGetReceiveSubjectData(data, f) |
| 76 | }; | 78 | }; |
| @@ -52,7 +52,9 @@ export class WebArticleEventHandler implements WebEvents { | @@ -52,7 +52,9 @@ export class WebArticleEventHandler implements WebEvents { | ||
| 52 | url = url.replace("%(?![0-9a-fA-F]{2})", "%25") | 52 | url = url.replace("%(?![0-9a-fA-F]{2})", "%25") |
| 53 | .replace("\\+", "%2B"); | 53 | .replace("\\+", "%2B"); |
| 54 | url = decodeURIComponent(url) | 54 | url = decodeURIComponent(url) |
| 55 | - Logger.debug(TAG, 'Web onLoadIntercept url: ' + url); | 55 | + Logger.debugOptimize(TAG, () => { |
| 56 | + return 'Web onLoadIntercept url: ' + url | ||
| 57 | + }); | ||
| 56 | if (url.startsWith(BridgeUtil.YY_RETURN_DATA)) { | 58 | if (url.startsWith(BridgeUtil.YY_RETURN_DATA)) { |
| 57 | this.webviewControl?.handlerReturnData(url) | 59 | this.webviewControl?.handlerReturnData(url) |
| 58 | return true | 60 | return true |
| @@ -70,7 +72,9 @@ export class WebArticleEventHandler implements WebEvents { | @@ -70,7 +72,9 @@ export class WebArticleEventHandler implements WebEvents { | ||
| 70 | for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) { | 72 | for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) { |
| 71 | let handleName = H5CallNativeType.JsCallTypeList[i]; | 73 | let handleName = H5CallNativeType.JsCallTypeList[i]; |
| 72 | let handle = (data: Message, f: Callback) => { | 74 | let handle = (data: Message, f: Callback) => { |
| 73 | - Logger.debug('registerHandlers handlerName: ' + JSON.stringify(data.data)) | 75 | + Logger.debugOptimize(TAG, () => { |
| 76 | + return 'receivedData: ' + JSON.stringify(data.data) | ||
| 77 | + }) | ||
| 74 | if (this.currentPageOperateBlock) { | 78 | if (this.currentPageOperateBlock) { |
| 75 | this.currentPageOperateBlock(data, f) | 79 | this.currentPageOperateBlock(data, f) |
| 76 | } | 80 | } |
| @@ -16,13 +16,14 @@ import { Card19Component } from './cardview/Card19Component'; | @@ -16,13 +16,14 @@ import { Card19Component } from './cardview/Card19Component'; | ||
| 16 | import { Card20Component } from './cardview/Card20Component'; | 16 | import { Card20Component } from './cardview/Card20Component'; |
| 17 | import { Card21Component } from './cardview/Card21Component'; | 17 | import { Card21Component } from './cardview/Card21Component'; |
| 18 | import { SearchContentComponent } from './cardview/SearchContentComponent'; | 18 | import { SearchContentComponent } from './cardview/SearchContentComponent'; |
| 19 | -import { DateTimeUtils } from 'wdKit/Index'; | 19 | +import { DateTimeUtils, Logger } from 'wdKit/Index'; |
| 20 | import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index'; | 20 | import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index'; |
| 21 | import { LiveBigImage02Component } from './cardview/LiveBigImage02Component'; | 21 | import { LiveBigImage02Component } from './cardview/LiveBigImage02Component'; |
| 22 | import { LiveBigImage01Component } from './cardview/LiveBigImage01Component'; | 22 | import { LiveBigImage01Component } from './cardview/LiveBigImage01Component'; |
| 23 | import { behindDivider } from './cardCommon/behindDivider' | 23 | import { behindDivider } from './cardCommon/behindDivider' |
| 24 | import PageModel from '../viewmodel/PageModel'; | 24 | import PageModel from '../viewmodel/PageModel'; |
| 25 | 25 | ||
| 26 | +const TAG = "CardParser" | ||
| 26 | /** | 27 | /** |
| 27 | * card适配器,卡片样式汇总,依据ContentDTO#appStyle | 28 | * card适配器,卡片样式汇总,依据ContentDTO#appStyle |
| 28 | * 卡片样式,最小单元样式布局 | 29 | * 卡片样式,最小单元样式布局 |
| @@ -42,7 +43,9 @@ export struct CardParser { | @@ -42,7 +43,9 @@ export struct CardParser { | ||
| 42 | isNeedDivider:boolean = true | 43 | isNeedDivider:boolean = true |
| 43 | 44 | ||
| 44 | aboutToAppear(): void { | 45 | aboutToAppear(): void { |
| 45 | - console.log('CardParser-', JSON.stringify(this.contentDTO)) | 46 | + Logger.debugOptimize(TAG, () => { |
| 47 | + return JSON.stringify(this.contentDTO) | ||
| 48 | + }) | ||
| 46 | } | 49 | } |
| 47 | 50 | ||
| 48 | onPageShow() { | 51 | onPageShow() { |
| @@ -43,7 +43,7 @@ export struct CarderInteraction { | @@ -43,7 +43,7 @@ export struct CarderInteraction { | ||
| 43 | this.likeBean['userHeaderUrl'] = this.contentDetailData.userInfo?.headPhotoUrl + '' | 43 | this.likeBean['userHeaderUrl'] = this.contentDetailData.userInfo?.headPhotoUrl + '' |
| 44 | this.likeBean['channelId'] = this.contentDetailData.reLInfo?.channelId + '' | 44 | this.likeBean['channelId'] = this.contentDetailData.reLInfo?.channelId + '' |
| 45 | this.contentDTO.shareFlag = this.contentDTO.shareFlag ? this.contentDTO.shareFlag : '1' | 45 | this.contentDTO.shareFlag = this.contentDTO.shareFlag ? this.contentDTO.shareFlag : '1' |
| 46 | - console.log('是否显示分享',this.contentDTO.shareFlag) | 46 | + Logger.debug(TAG, '是否显示分享',this.contentDTO.shareFlag) |
| 47 | // 内容用 点赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空 | 47 | // 内容用 点赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空 |
| 48 | this.likesStyle = this.contentDetailData.likesStyle | 48 | this.likesStyle = this.contentDetailData.likesStyle |
| 49 | this.openLikes = this.contentDetailData.openLikes == 1 ? true : false | 49 | this.openLikes = this.contentDetailData.openLikes == 1 ? true : false |
| @@ -27,6 +27,7 @@ import { | @@ -27,6 +27,7 @@ import { | ||
| 27 | import { LabelComponent } from './view/LabelComponent'; | 27 | import { LabelComponent } from './view/LabelComponent'; |
| 28 | import { LiveHorizontalCardComponent } from './view/LiveHorizontalCardComponent'; | 28 | import { LiveHorizontalCardComponent } from './view/LiveHorizontalCardComponent'; |
| 29 | import { behindDivider } from './cardCommon/behindDivider' | 29 | import { behindDivider } from './cardCommon/behindDivider' |
| 30 | +import { Logger } from 'wdKit'; | ||
| 30 | 31 | ||
| 31 | /** | 32 | /** |
| 32 | * comp适配器. | 33 | * comp适配器. |
| @@ -46,7 +47,9 @@ export struct CompParser { | @@ -46,7 +47,9 @@ export struct CompParser { | ||
| 46 | 47 | ||
| 47 | aboutToAppear(): void { | 48 | aboutToAppear(): void { |
| 48 | 49 | ||
| 49 | - console.log('CompParser', JSON.stringify(this.compDTO)) | 50 | + Logger.debugOptimize('CompParser', () => { |
| 51 | + return JSON.stringify(this.compDTO) | ||
| 52 | + }) | ||
| 50 | this.pageName = this.pageModel.pageInfo.name | 53 | this.pageName = this.pageModel.pageInfo.name |
| 51 | // 轮播图屏蔽音频类型稿件 | 54 | // 轮播图屏蔽音频类型稿件 |
| 52 | if (this.compDTO.compStyle === CompStyle.Zh_Carousel_Layout_01) { | 55 | if (this.compDTO.compStyle === CompStyle.Zh_Carousel_Layout_01) { |
| 1 | import { ContentDTO, joinPeopleNum } from 'wdBean/Index' | 1 | import { ContentDTO, joinPeopleNum } from 'wdBean/Index' |
| 2 | -import { DateTimeUtils } from 'wdKit/Index' | 2 | +import { DateTimeUtils, Logger } from 'wdKit/Index' |
| 3 | import { LottieView } from '../../components/lottie/LottieView'; | 3 | import { LottieView } from '../../components/lottie/LottieView'; |
| 4 | import { LiveModel } from '../../viewmodel/LiveModel' | 4 | import { LiveModel } from '../../viewmodel/LiveModel' |
| 5 | import font from '@ohos.font'; | 5 | import font from '@ohos.font'; |
| 6 | import text from '@ohos.graphics.text'; | 6 | import text from '@ohos.graphics.text'; |
| 7 | 7 | ||
| 8 | +const TAG = "CardMediaInfo" | ||
| 8 | /** | 9 | /** |
| 9 | * 这里是样式卡中,右下角显示的音视频信息 | 10 | * 这里是样式卡中,右下角显示的音视频信息 |
| 10 | * 目前已知: | 11 | * 目前已知: |
| @@ -86,11 +87,13 @@ export struct CardMediaInfo { | @@ -86,11 +87,13 @@ export struct CardMediaInfo { | ||
| 86 | */ | 87 | */ |
| 87 | async getJoinPeopleNum() { | 88 | async getJoinPeopleNum() { |
| 88 | if (this.contentDTO.objectType !== '2') return; | 89 | if (this.contentDTO.objectType !== '2') return; |
| 89 | - console.log('getJoinPeopleNum-ContentDTO', JSON.stringify(this.contentDTO.objectId)) | ||
| 90 | - let liveIdList: string = this.contentDTO.objectId | ||
| 91 | - let data: joinPeopleNum[] = await LiveModel.getJoinPeopleNum(liveIdList) | 90 | + Logger.debugOptimize(TAG, () => { |
| 91 | + return 'getJoinPeopleNum-ContentDTO' + JSON.stringify(this.contentDTO.objectId) | ||
| 92 | + }) | ||
| 93 | + LiveModel.getJoinPeopleNum(this.contentDTO.objectId).then((data) => { | ||
| 92 | this.joinPeopleNum = data[0].pv; | 94 | this.joinPeopleNum = data[0].pv; |
| 93 | - console.log('getJoinPeopleNum ', this.joinPeopleNum) | 95 | + Logger.debug(TAG, 'getJoinPeopleNum ' + this.joinPeopleNum) |
| 96 | + }) | ||
| 94 | } | 97 | } |
| 95 | 98 | ||
| 96 | build() { | 99 | build() { |
| @@ -6,6 +6,8 @@ import { SearchShowRed, textItem, titleInitRes } from '../../utils/searchShowRed | @@ -6,6 +6,8 @@ import { SearchShowRed, textItem, titleInitRes } from '../../utils/searchShowRed | ||
| 6 | import measure from '@ohos.measure' | 6 | import measure from '@ohos.measure' |
| 7 | import display from '@ohos.display'; | 7 | import display from '@ohos.display'; |
| 8 | 8 | ||
| 9 | +const TAG = "CardSourceInfo" | ||
| 10 | + | ||
| 9 | @Reusable | 11 | @Reusable |
| 10 | @Component | 12 | @Component |
| 11 | export struct CardSourceInfo { | 13 | export struct CardSourceInfo { |
| @@ -171,25 +173,25 @@ export struct CardSourceInfo { | @@ -171,25 +173,25 @@ export struct CardSourceInfo { | ||
| 171 | 173 | ||
| 172 | calcContentSpace() { | 174 | calcContentSpace() { |
| 173 | 175 | ||
| 174 | - console.log('display-text ,', this.displayText) | 176 | + // Logger.debug(TAG, 'display-text ' + this.displayText) |
| 175 | if (this.isLimited()) return; | 177 | if (this.isLimited()) return; |
| 176 | 178 | ||
| 177 | const screenWidth = display.getDefaultDisplaySync().width | 179 | const screenWidth = display.getDefaultDisplaySync().width |
| 178 | let leftSpace = screenWidth; | 180 | let leftSpace = screenWidth; |
| 179 | - console.log('display-leftSpace ', leftSpace) | 181 | + // Logger.debug(TAG, 'display-leftSpace ' + leftSpace) |
| 180 | const souceSize = this.getContentSize(this.displayText, 12); | 182 | const souceSize = this.getContentSize(this.displayText, 12); |
| 181 | const dotSize = 11; | 183 | const dotSize = 11; |
| 182 | 184 | ||
| 183 | if (this.contentDTO.cornerMark || this.contentDTO.corner) { | 185 | if (this.contentDTO.cornerMark || this.contentDTO.corner) { |
| 184 | const cornerSize = this.getContentSize(this.contentDTO.cornerMark || this.contentDTO.corner, 12); | 186 | const cornerSize = this.getContentSize(this.contentDTO.cornerMark || this.contentDTO.corner, 12); |
| 185 | leftSpace = leftSpace - cornerSize | 187 | leftSpace = leftSpace - cornerSize |
| 186 | - console.log('display-cornerMark ', cornerSize) | 188 | + // Logger.debug(TAG, ('display-cornerMark ' + cornerSize) |
| 187 | } | 189 | } |
| 188 | 190 | ||
| 189 | if (this.showTime()) { | 191 | if (this.showTime()) { |
| 190 | const timeSize = this.getContentSize(this.handleTimeStr(), 12); | 192 | const timeSize = this.getContentSize(this.handleTimeStr(), 12); |
| 191 | leftSpace = leftSpace - dotSize - timeSize | 193 | leftSpace = leftSpace - dotSize - timeSize |
| 192 | - console.log('display-showtime') | 194 | + // Logger.debug(TAG, 'display-showtime') |
| 193 | } | 195 | } |
| 194 | 196 | ||
| 195 | if (!this.isEllipsisActive) { | 197 | if (!this.isEllipsisActive) { |
| @@ -199,14 +201,14 @@ export struct CardSourceInfo { | @@ -199,14 +201,14 @@ export struct CardSourceInfo { | ||
| 199 | commentSize = this.getContentSize(`${this.handlerNum(commentNum.toString())}评`, 12); | 201 | commentSize = this.getContentSize(`${this.handlerNum(commentNum.toString())}评`, 12); |
| 200 | } | 202 | } |
| 201 | leftSpace = leftSpace - dotSize - commentSize | 203 | leftSpace = leftSpace - dotSize - commentSize |
| 202 | - console.log('display-commentSize ', commentSize) | 204 | + // Logger.debug(TAG, 'display-commentSize ' + commentSize) |
| 203 | } | 205 | } |
| 204 | 206 | ||
| 205 | if (leftSpace < souceSize) { | 207 | if (leftSpace < souceSize) { |
| 206 | this.onlyShowCornerAndSource = true; | 208 | this.onlyShowCornerAndSource = true; |
| 207 | - console.log('display-size 1') | 209 | + // Logger.debug(TAG, 'display-size 1') |
| 208 | } | 210 | } |
| 209 | - console.log('display-size 2,', leftSpace, souceSize, this.onlyShowCornerAndSource) | 211 | + // Logger.debug(TAG, 'display-size 2,' + leftSpace + " " + souceSize + " " + this.onlyShowCornerAndSource) |
| 210 | } | 212 | } |
| 211 | 213 | ||
| 212 | build() { | 214 | build() { |
| @@ -29,8 +29,10 @@ export struct Card6Component { | @@ -29,8 +29,10 @@ export struct Card6Component { | ||
| 29 | @State contentDTO: ContentDTO = new ContentDTO(); | 29 | @State contentDTO: ContentDTO = new ContentDTO(); |
| 30 | @State compIndex: number = 0; | 30 | @State compIndex: number = 0; |
| 31 | 31 | ||
| 32 | - async aboutToAppear(): Promise<void> { | ||
| 33 | - console.log('Card6Component', JSON.stringify(this.contentDTO)) | 32 | + aboutToAppear() { |
| 33 | + Logger.debugOptimize(TAG, () => { | ||
| 34 | + return 'Card6Component' + JSON.stringify(this.contentDTO) | ||
| 35 | + }) | ||
| 34 | this.titleInit(); | 36 | this.titleInit(); |
| 35 | const curRouter = router.getState().name; | 37 | const curRouter = router.getState().name; |
| 36 | this.clicked = hasClicked(this.contentDTO.objectId, curRouter) | 38 | this.clicked = hasClicked(this.contentDTO.objectId, curRouter) |
| @@ -160,10 +160,9 @@ export struct CommentCustomDialog { | @@ -160,10 +160,9 @@ export struct CommentCustomDialog { | ||
| 160 | // this.textInputController.stopEditing() | 160 | // this.textInputController.stopEditing() |
| 161 | inputMethod.getController().hideTextInput((err: BusinessError) => { | 161 | inputMethod.getController().hideTextInput((err: BusinessError) => { |
| 162 | if (err) { | 162 | if (err) { |
| 163 | - Logger.error(TAG, (`Failed to hideTextInput: ${JSON.stringify(err)}`); | 163 | + Logger.error(TAG, `Failed to hideTextInput: ${JSON.stringify(err)}`); |
| 164 | return; | 164 | return; |
| 165 | } | 165 | } |
| 166 | - // console.log('Succeeded in hiding text input.'); | ||
| 167 | }) | 166 | }) |
| 168 | // this.showKeyboardOnFocus = false | 167 | // this.showKeyboardOnFocus = false |
| 169 | // focusControl.requestFocus("textAreaId") // 弹起键盘 | 168 | // focusControl.requestFocus("textAreaId") // 弹起键盘 |
| @@ -50,7 +50,7 @@ export struct ZhSingleRow03 { | @@ -50,7 +50,7 @@ export struct ZhSingleRow03 { | ||
| 50 | @State compIndex: number = 0; | 50 | @State compIndex: number = 0; |
| 51 | 51 | ||
| 52 | resetMoreTips() { | 52 | resetMoreTips() { |
| 53 | - console.log('resetMoreTips', this.moreWidth, this.initMoreWidth) | 53 | + Logger.debug(TAG, 'resetMoreTips' + this.moreWidth + ' ' + this.initMoreWidth) |
| 54 | if (this.moreWidth < this.initMoreWidth * 2) { | 54 | if (this.moreWidth < this.initMoreWidth * 2) { |
| 55 | this.moreTips = '查看更多'; | 55 | this.moreTips = '查看更多'; |
| 56 | } | 56 | } |
| @@ -301,7 +301,7 @@ export struct PageComponent { | @@ -301,7 +301,7 @@ export struct PageComponent { | ||
| 301 | 301 | ||
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | - async aboutToAppear() { | 304 | + aboutToAppear() { |
| 305 | // 选中tab,才请求数据。拦截大量接口请求 | 305 | // 选中tab,才请求数据。拦截大量接口请求 |
| 306 | if (this.navIndex === this.currentTopNavSelectedIndex) { | 306 | if (this.navIndex === this.currentTopNavSelectedIndex) { |
| 307 | this.getData(); | 307 | this.getData(); |
| @@ -364,7 +364,7 @@ export struct PageComponent { | @@ -364,7 +364,7 @@ export struct PageComponent { | ||
| 364 | autoRefresh(this.pageModel, this.pageAdvModel) | 364 | autoRefresh(this.pageModel, this.pageAdvModel) |
| 365 | } | 365 | } |
| 366 | 366 | ||
| 367 | - async getData() { | 367 | + getData() { |
| 368 | if (this.timer) { | 368 | if (this.timer) { |
| 369 | clearTimeout(this.timer) | 369 | clearTimeout(this.timer) |
| 370 | } | 370 | } |
| @@ -20,7 +20,7 @@ export struct FirstTabTopSearchComponent { | @@ -20,7 +20,7 @@ export struct FirstTabTopSearchComponent { | ||
| 20 | private swiperController: SwiperController = new SwiperController() | 20 | private swiperController: SwiperController = new SwiperController() |
| 21 | navItem: BottomNavDTO = {} as BottomNavDTO | 21 | navItem: BottomNavDTO = {} as BottomNavDTO |
| 22 | 22 | ||
| 23 | - async aboutToAppear() { | 23 | + aboutToAppear() { |
| 24 | this.getSearchHint() | 24 | this.getSearchHint() |
| 25 | } | 25 | } |
| 26 | 26 |
| @@ -198,7 +198,9 @@ export class GetuiPush { | @@ -198,7 +198,9 @@ export class GetuiPush { | ||
| 198 | this.onNewWant(want, true) | 198 | this.onNewWant(want, true) |
| 199 | } | 199 | } |
| 200 | onNewWant(want: Want, startup: boolean = false) { | 200 | onNewWant(want: Want, startup: boolean = false) { |
| 201 | - Logger.debug(TAG, "want: " + JSON.stringify(want)) | 201 | + Logger.debugOptimize(TAG, () => { |
| 202 | + return "want: " + JSON.stringify(want) | ||
| 203 | + }) | ||
| 202 | 204 | ||
| 203 | this.lastPushContent = undefined | 205 | this.lastPushContent = undefined |
| 204 | let pushContent = PushContentParser.getPushLinkFromWant(want) | 206 | let pushContent = PushContentParser.getPushLinkFromWant(want) |
| @@ -441,7 +443,7 @@ export class GetuiPush { | @@ -441,7 +443,7 @@ export class GetuiPush { | ||
| 441 | bean["appVersion"] = AppUtils.getAppVersionName() | 443 | bean["appVersion"] = AppUtils.getAppVersionName() |
| 442 | bean["platform"] = 3 | 444 | bean["platform"] = 3 |
| 443 | HttpBizUtil.post<ResponseDTO<string>>(url, bean).then((data) => { | 445 | HttpBizUtil.post<ResponseDTO<string>>(url, bean).then((data) => { |
| 444 | - Logger.debug(TAG, "上传cid成功" + JSON.stringify(data)) | 446 | + Logger.debug(TAG, "上传cid成功") |
| 445 | }).catch((e: BusinessError) => { | 447 | }).catch((e: BusinessError) => { |
| 446 | Logger.debug(TAG, "上传cid失败" + JSON.stringify(e)) | 448 | Logger.debug(TAG, "上传cid失败" + JSON.stringify(e)) |
| 447 | }) | 449 | }) |
| @@ -5,6 +5,7 @@ import { SpConstants } from 'wdConstant/Index'; | @@ -5,6 +5,7 @@ import { SpConstants } from 'wdConstant/Index'; | ||
| 5 | import { EmitterEventId, EmitterUtils, Logger, PermissionUtils, ResourcesUtils, SPHelper } from 'wdKit/Index'; | 5 | import { EmitterEventId, EmitterUtils, Logger, PermissionUtils, ResourcesUtils, SPHelper } from 'wdKit/Index'; |
| 6 | import { ResponseDTO } from 'wdNetwork/Index'; | 6 | import { ResponseDTO } from 'wdNetwork/Index'; |
| 7 | 7 | ||
| 8 | +const TAG = "HWLocationUtils" | ||
| 8 | /** | 9 | /** |
| 9 | * 系统定位服务实现 | 10 | * 系统定位服务实现 |
| 10 | * */ | 11 | * */ |
| @@ -21,7 +22,7 @@ export class HWLocationUtils { | @@ -21,7 +22,7 @@ export class HWLocationUtils { | ||
| 21 | maxAccuracy: 0 | 22 | maxAccuracy: 0 |
| 22 | }; | 23 | }; |
| 23 | geoLocationManager.on('locationChange', requestInfo, (data) => { | 24 | geoLocationManager.on('locationChange', requestInfo, (data) => { |
| 24 | - Logger.debug('location :' + JSON.stringify(data)) | 25 | + Logger.debug(TAG, JSON.stringify(data)) |
| 25 | }) | 26 | }) |
| 26 | } | 27 | } |
| 27 | 28 | ||
| @@ -35,7 +36,7 @@ export class HWLocationUtils { | @@ -35,7 +36,7 @@ export class HWLocationUtils { | ||
| 35 | maxAccuracy: 0 | 36 | maxAccuracy: 0 |
| 36 | }; | 37 | }; |
| 37 | geoLocationManager.on('locationChange', requestInfo, (data) => { | 38 | geoLocationManager.on('locationChange', requestInfo, (data) => { |
| 38 | - Logger.debug('location :' + JSON.stringify(data)) //{"latitude":31.86870096,"longitude":117.3015341,"altitude":0,"accuracy":5000,"speed":0,"timeStamp":1713332445643,"direction":0,"timeSinceBoot":589519570869240,"additions":"","additionSize":0} | 39 | + Logger.debug(TAG, JSON.stringify(data)) //{"latitude":31.86870096,"longitude":117.3015341,"altitude":0,"accuracy":5000,"speed":0,"timeStamp":1713332445643,"direction":0,"timeSinceBoot":589519570869240,"additions":"","additionSize":0} |
| 39 | let record: Record<string, string | number> = {}; | 40 | let record: Record<string, string | number> = {}; |
| 40 | record['latitude'] = data.latitude | 41 | record['latitude'] = data.latitude |
| 41 | record['longitude'] = data.longitude | 42 | record['longitude'] = data.longitude |
| @@ -75,13 +76,16 @@ export class HWLocationUtils { | @@ -75,13 +76,16 @@ export class HWLocationUtils { | ||
| 75 | try { | 76 | try { |
| 76 | geoLocationManager.getCurrentLocation(requestInfo).then((result) => { | 77 | geoLocationManager.getCurrentLocation(requestInfo).then((result) => { |
| 77 | //{"latitude":31.8687047,"longitude":117.30152005,"altitude":0,"accuracy":5000,"speed":0,"timeStamp":1713331875766,"direction":0,"timeSinceBoot":588949694096931,"additions":"","additionSize":0} | 78 | //{"latitude":31.8687047,"longitude":117.30152005,"altitude":0,"accuracy":5000,"speed":0,"timeStamp":1713331875766,"direction":0,"timeSinceBoot":588949694096931,"additions":"","additionSize":0} |
| 78 | - Logger.debug('location' + JSON.stringify(result)) | 79 | + Logger.debugOptimize('location', () => { |
| 80 | + return JSON.stringify(result) | ||
| 81 | + }) | ||
| 79 | HWLocationUtils.getReverseGeoCodeRequest(result.latitude, result.longitude) | 82 | HWLocationUtils.getReverseGeoCodeRequest(result.latitude, result.longitude) |
| 80 | }) | 83 | }) |
| 81 | .catch((error: number) => { | 84 | .catch((error: number) => { |
| 82 | - Logger.debug('location' + JSON.stringify(error)) | 85 | + Logger.error(TAG, JSON.stringify(error)) |
| 83 | }); | 86 | }); |
| 84 | } catch (err) { | 87 | } catch (err) { |
| 88 | + Logger.error(TAG, JSON.stringify(err)) | ||
| 85 | } | 89 | } |
| 86 | } | 90 | } |
| 87 | 91 | ||
| @@ -89,7 +93,7 @@ export class HWLocationUtils { | @@ -89,7 +93,7 @@ export class HWLocationUtils { | ||
| 89 | let requestInfo: geoLocationManager.GeoCodeRequest = { 'description': description }; | 93 | let requestInfo: geoLocationManager.GeoCodeRequest = { 'description': description }; |
| 90 | geoLocationManager.getAddressesFromLocationName(requestInfo, (error, data) => { | 94 | geoLocationManager.getAddressesFromLocationName(requestInfo, (error, data) => { |
| 91 | if (data) { | 95 | if (data) { |
| 92 | - Logger.debug('location :' + JSON.stringify(data)) | 96 | + Logger.debug(TAG, JSON.stringify(data)) |
| 93 | } | 97 | } |
| 94 | //[{"latitude":31.898204927828598,"longitude":117.29702564819466,"locale":"zh","placeName":"安徽省合肥市瑶海区白龙路与北二环路辅路交叉口南20米","countryCode":"CN","countryName":"中国","administrativeArea":"安徽省","subAdministrativeArea":"合肥市","locality":"合肥市","subLocality":"瑶海区","roadName":"白龙路与北二环路辅路","subRoadName":"20","premises":"20","postalCode":"","phoneNumber":"18756071597","addressUrl":"","descriptionsSize":0,"isFromMock":false}] | 98 | //[{"latitude":31.898204927828598,"longitude":117.29702564819466,"locale":"zh","placeName":"安徽省合肥市瑶海区白龙路与北二环路辅路交叉口南20米","countryCode":"CN","countryName":"中国","administrativeArea":"安徽省","subAdministrativeArea":"合肥市","locality":"合肥市","subLocality":"瑶海区","roadName":"白龙路与北二环路辅路","subRoadName":"20","premises":"20","postalCode":"","phoneNumber":"18756071597","addressUrl":"","descriptionsSize":0,"isFromMock":false}] |
| 95 | }) | 99 | }) |
| @@ -103,10 +107,12 @@ export class HWLocationUtils { | @@ -103,10 +107,12 @@ export class HWLocationUtils { | ||
| 103 | }; | 107 | }; |
| 104 | geoLocationManager.getAddressesFromLocation(requestInfo, async (error, data) => { | 108 | geoLocationManager.getAddressesFromLocation(requestInfo, async (error, data) => { |
| 105 | if (error) { | 109 | if (error) { |
| 106 | - Logger.debug('location :' + JSON.stringify(error)) | 110 | + Logger.error(TAG, JSON.stringify(error)) |
| 107 | } | 111 | } |
| 108 | if (data) { | 112 | if (data) { |
| 109 | - Logger.debug('location :' + JSON.stringify(data)) | 113 | + Logger.debugOptimize(TAG, () => { |
| 114 | + return JSON.stringify(data) | ||
| 115 | + }) | ||
| 110 | if (data[0] && data[0].administrativeArea && data[0].subAdministrativeArea) { | 116 | if (data[0] && data[0].administrativeArea && data[0].subAdministrativeArea) { |
| 111 | let cityName = data[0].subAdministrativeArea; | 117 | let cityName = data[0].subAdministrativeArea; |
| 112 | let name = await SPHelper.default.get(SpConstants.LOCATION_CITY_NAME, '') as string | 118 | let name = await SPHelper.default.get(SpConstants.LOCATION_CITY_NAME, '') as string |
| @@ -136,7 +142,7 @@ export class HWLocationUtils { | @@ -136,7 +142,7 @@ export class HWLocationUtils { | ||
| 136 | // geoLocationManager.off('locationChange') | 142 | // geoLocationManager.off('locationChange') |
| 137 | return new Promise<boolean>((success, fail) => { | 143 | return new Promise<boolean>((success, fail) => { |
| 138 | geoLocationManager.off("locationChange", (data) => { | 144 | geoLocationManager.off("locationChange", (data) => { |
| 139 | - Logger.debug('location :' + JSON.stringify(data)) | 145 | + Logger.debug(TAG, JSON.stringify(data)) |
| 140 | success(true) | 146 | success(true) |
| 141 | }) | 147 | }) |
| 142 | }) | 148 | }) |
| @@ -63,7 +63,9 @@ export default class HuaweiAuth { | @@ -63,7 +63,9 @@ export default class HuaweiAuth { | ||
| 63 | controller.executeRequest(authRequest).then((response: authentication.AuthorizationWithHuaweiIDResponse) => { | 63 | controller.executeRequest(authRequest).then((response: authentication.AuthorizationWithHuaweiIDResponse) => { |
| 64 | let anonymousPhone = response.data?.extraInfo?.quickLoginAnonymousPhone; | 64 | let anonymousPhone = response.data?.extraInfo?.quickLoginAnonymousPhone; |
| 65 | if (anonymousPhone) { | 65 | if (anonymousPhone) { |
| 66 | - Logger.info(TAG, 'get anonymousPhone, ' + JSON.stringify(response)); | 66 | + Logger.infoOptimize(TAG, () => { |
| 67 | + return 'get anonymousPhone, ' + JSON.stringify(response) | ||
| 68 | + }) | ||
| 67 | this._anonymousPhone = anonymousPhone as string | 69 | this._anonymousPhone = anonymousPhone as string |
| 68 | resolve(this._anonymousPhone) | 70 | resolve(this._anonymousPhone) |
| 69 | return; | 71 | return; |
| @@ -16,6 +16,7 @@ import { LaunchPageModel } from './viewModel/LaunchPageModel'; | @@ -16,6 +16,7 @@ import { LaunchPageModel } from './viewModel/LaunchPageModel'; | ||
| 16 | import { JSON } from '@kit.ArkTS'; | 16 | import { JSON } from '@kit.ArkTS'; |
| 17 | import { WebArticleEventHandler, WebPoolManager } from 'wdWebComponent'; | 17 | import { WebArticleEventHandler, WebPoolManager } from 'wdWebComponent'; |
| 18 | import { BridgeWebViewControl } from 'wdJsBridge'; | 18 | import { BridgeWebViewControl } from 'wdJsBridge'; |
| 19 | +import { webview } from '@kit.ArkWeb'; | ||
| 19 | 20 | ||
| 20 | const TAG = 'MainPage'; | 21 | const TAG = 'MainPage'; |
| 21 | 22 | ||
| @@ -40,8 +41,6 @@ struct MainPage { | @@ -40,8 +41,6 @@ struct MainPage { | ||
| 40 | 41 | ||
| 41 | aboutToAppear() { | 42 | aboutToAppear() { |
| 42 | 43 | ||
| 43 | - StartupManager.sharedInstance().appReachMainPage() | ||
| 44 | - | ||
| 45 | this.breakpointSystem.register() | 44 | this.breakpointSystem.register() |
| 46 | 45 | ||
| 47 | // Logger.info(TAG, `aboutToAppear `); | 46 | // Logger.info(TAG, `aboutToAppear `); |
| @@ -64,7 +63,14 @@ struct MainPage { | @@ -64,7 +63,14 @@ struct MainPage { | ||
| 64 | } | 63 | } |
| 65 | 64 | ||
| 66 | setTimeout(() => { | 65 | setTimeout(() => { |
| 66 | + // 这里延后,因为有可能是换端进入H5页面 | ||
| 67 | + setTimeout(() => { | ||
| 68 | + StartupManager.sharedInstance().appReachMainPage() | ||
| 69 | + }, 200) | ||
| 70 | + | ||
| 71 | + webview.WebviewController.initializeWebEngine() | ||
| 67 | ComponentModule.preInitArticleWebTemplate(this.getUIContext()) | 72 | ComponentModule.preInitArticleWebTemplate(this.getUIContext()) |
| 73 | + | ||
| 68 | }, 500) | 74 | }, 500) |
| 69 | } | 75 | } |
| 70 | 76 |
| @@ -49,7 +49,9 @@ export class StartupManager { | @@ -49,7 +49,9 @@ export class StartupManager { | ||
| 49 | 49 | ||
| 50 | // App启动 | 50 | // App启动 |
| 51 | appOnCreate(want: Want, launchParam: AbilityConstant.LaunchParam, context: common.UIAbilityContext) { | 51 | appOnCreate(want: Want, launchParam: AbilityConstant.LaunchParam, context: common.UIAbilityContext) { |
| 52 | - Logger.debug(TAG, "App onCreate: " + `\nwant: ${want}\nlaunchParam: ${launchParam}`) | 52 | + Logger.debugOptimize(TAG, () => { |
| 53 | + return "App onCreate: " + `\nwant: ${want}\nlaunchParam: ${launchParam}` | ||
| 54 | + }) | ||
| 53 | this.context = context | 55 | this.context = context |
| 54 | // 设置图片文件数据缓存上限为200MB (200MB=200*1024*1024B=209715200B) | 56 | // 设置图片文件数据缓存上限为200MB (200MB=200*1024*1024B=209715200B) |
| 55 | app.setImageFileCacheSize(209715200) | 57 | app.setImageFileCacheSize(209715200) |
| @@ -161,7 +163,7 @@ export class StartupManager { | @@ -161,7 +163,7 @@ export class StartupManager { | ||
| 161 | 163 | ||
| 162 | //TODO: | 164 | //TODO: |
| 163 | // 提前初始化webview | 165 | // 提前初始化webview |
| 164 | - webview.WebviewController.initializeWebEngine() | 166 | + // webview.WebviewController.initializeWebEngine() |
| 165 | 167 | ||
| 166 | initGlobalPlayerSettings(this.context!) | 168 | initGlobalPlayerSettings(this.context!) |
| 167 | 169 |
-
Please register or login to post a comment