xugenyuan

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 {
Logger.info(TAG, 'register success');
})
this.netCon.on('netAvailable', (data: connection.NetHandle) => {
Logger.info(TAG, 'netAvailable, data is: ' + JSON.stringify(data))
Logger.infoOptimize(TAG, () => {
return 'netAvailable, data is: ' + JSON.stringify(data)
})
})
this.netCon.on('netBlockStatusChange', (data: connection.NetBlockStatusInfo) => {
Logger.info(TAG, 'netBlockStatusChange, data is: ' + JSON.stringify(data))
// TODO 网络阻塞,是否创建新的网络、提示
})
this.netCon.on('netCapabilitiesChange', (data: connection.NetCapabilityInfo) => {
Logger.info(TAG, 'netCapabilitiesChange, data is: ' + JSON.stringify(data))
Logger.infoOptimize(TAG, () => {
return 'netCapabilitiesChange, data is: ' + JSON.stringify(data)
})
this.parseData(data)
// 可能多次通知
EmitterUtils.sendEvent(EmitterEventId.NETWORK_CONNECTED, JSON.stringify(this.networkType))
})
this.netCon.on('netConnectionPropertiesChange', (data: connection.NetConnectionPropertyInfo) => {
Logger.info(TAG, 'netConnectionPropertiesChange, data is: ' + JSON.stringify(data))
Logger.infoOptimize(TAG, () => {
return 'netConnectionPropertiesChange, data is: ' + JSON.stringify(data)
})
})
this.netCon.on('netUnavailable', ((data: void) => {
... ...
... ... @@ -10,8 +10,22 @@ const TAG: string = 'AppUtils';
*/
export class AppUtils {
private static buildVersion: string = ''
private static buildProductName: string = ''
private static buildBuildModeName: string = ''
static {
AppUtils.buildVersion = BuildProfile.BUILD_VERSION;
AppUtils.buildProductName = BuildProfile.PRODUCT_NAME;
AppUtils.buildBuildModeName = BuildProfile.BUILD_MODE_NAME;
Logger.isDebug = !AppUtils.isProductRELEASE()
// Logger.isDebug = false
}
public static isProductRELEASE() {
if (AppUtils.buildProductName == "productRELEASE" && AppUtils.buildBuildModeName == "release") {
return true
}
return false
}
// 全局应用context
... ...
... ... @@ -118,7 +118,9 @@ export class KVStoreHelper {
return;
}
success(data)
Logger.debug(TAG, `Succeeded in getting data. Data:${data}`);
Logger.debugOptimize(TAG, () => {
return `Succeeded in getting data. Data:${data}`
});
});
} catch (e) {
success(def)
... ...
... ... @@ -20,7 +20,7 @@ enum LogLevel {
*/
export class Logger {
private static domain: number = 0xFF00;
private static prefix: string = 'SightApp';
private static prefix: string = 'RMRB';
private static format: string = `%{public}s, %{public}s`;
private static format_ext: string = `%{public}s`;
/**
... ... @@ -28,6 +28,7 @@ export class Logger {
*/
private static CHUNK_SIZE: number = 3500;
static isDebug: boolean = true;
static isCloseOptimzied: boolean = true;
/**
* constructor.
... ... @@ -35,7 +36,7 @@ export class Logger {
* @param Prefix Identifies the log tag.
* @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
*/
constructor(prefix: string = 'SightApp', domain: number = 0xFF00) {
constructor(prefix: string = 'RMRB', domain: number = 0xFF00) {
Logger.prefix = prefix;
Logger.domain = domain;
}
... ... @@ -47,6 +48,16 @@ export class Logger {
Logger.logContent(LogLevel.DEBUG, ...args)
}
static debugOptimize(tag: string, func: () => string) {
if (!Logger.isDebug || Logger.isCloseOptimzied) {
return
}
let param: string[] = []
param.push(tag)
param.push(func())
Logger.logContent(LogLevel.DEBUG, ...param)
}
static info(...args: string[]) {
if (!Logger.isDebug) {
return
... ... @@ -54,6 +65,16 @@ export class Logger {
Logger.logContent(LogLevel.INFO, ...args)
}
static infoOptimize(tag: string, func: () => string) {
if (!Logger.isDebug || Logger.isCloseOptimzied) {
return
}
let param: string[] = []
param.push(tag)
param.push(func())
Logger.logContent(LogLevel.INFO, ...param)
}
static warn(...args: string[]) {
if (!Logger.isDebug) {
return
... ... @@ -61,13 +82,33 @@ export class Logger {
Logger.logContent(LogLevel.WARN, ...args)
}
static warnOptimize(tag: string, func: () => string) {
if (!Logger.isDebug || Logger.isCloseOptimzied) {
return
}
let param: string[] = []
param.push(tag)
param.push(func())
Logger.logContent(LogLevel.WARN, ...param)
}
static error(...args: string[]) {
if (!Logger.isDebug) {
if (!Logger.isDebug || Logger.isCloseOptimzied) {
return
}
Logger.logContent(LogLevel.ERROR, ...args)
}
static errorOptimize(tag: string, func: () => string) {
if (!Logger.isDebug || Logger.isCloseOptimzied) {
return
}
let param: string[] = []
param.push(tag)
param.push(func())
Logger.logContent(LogLevel.ERROR, ...param)
}
static fatal(...args: string[]) {
if (!Logger.isDebug) {
return
... ... @@ -75,6 +116,16 @@ export class Logger {
Logger.logContent(LogLevel.FATAL, ...args)
}
static fatalOptimize(tag: string, func: () => string) {
if (!Logger.isDebug || Logger.isCloseOptimzied) {
return
}
let param: string[] = []
param.push(tag)
param.push(func())
Logger.logContent(LogLevel.FATAL, ...param)
}
static isLoggable(level: LogLevel) {
if (!Logger.isDebug) {
return
... ... @@ -103,7 +154,7 @@ export class Logger {
let prefix = Logger.prefix
if (tag) {
prefix = tag
prefix += "-" + tag
}
switch (level) {
... ... @@ -129,7 +180,7 @@ export class Logger {
let prefix = Logger.prefix
if (tag) {
prefix = tag
prefix += "-" + tag
}
switch (level) {
... ...
... ... @@ -30,6 +30,8 @@ const instance: AxiosInstance = axios.create({
// withCredentials: true
});
const TAG = "HttpRequest"
// 添加请求拦截器
instance.interceptors.request.use(
(config: InternalAxiosRequestConfig) => {
... ... @@ -39,12 +41,14 @@ instance.interceptors.request.use(
}
// 公共请求参数
// config.params.key = key
Logger.debug('HttpRequest', 'request: ' + config.url)
Logger.debugOptimize(TAG, () => {
return 'request: ' + config.url
})
return config;
},
(error: AxiosError) => {
// 请求错误
console.log(`全局请求失败拦截,message:${error.message}`)
Logger.error(`全局请求失败拦截,message:${error.message}`)
return Promise.reject(error);
}
);
... ... @@ -88,13 +92,15 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r
// }
// const data: ResponseBean<any> = response.data
Logger.debug('HttpRequest', 'response ==============start=================')
Logger.debug('HttpRequest', 'response: ' + JSON.stringify(response.data))
Logger.debug('HttpRequest', 'response ==============end=================')
Logger.debug(TAG, 'response ==============start=================')
Logger.debugOptimize(TAG, () => {
return 'response: ' + JSON.stringify(response.data)
})
Logger.debug(TAG, 'response ==============end=================')
// 改造返回的数据,即将AxiosResponse的data返回,服务端返回的数据
return response.data;
} else {
console.log(`httpStatus:${response.status}-${response.status}!`)
Logger.error(TAG, `httpStatus:${response.status}-${response.status}!`)
// return Promise.reject(error);
return response.data;
}
... ... @@ -107,7 +113,7 @@ instance.interceptors.response.use(// 响应拦截器response类型就是Axios.r
if (error != null && error.response != null) {
let message = buildErrorMsg(error.response.status);
// 错误消息可以使用全局弹框展示出来
console.log(`httpStatus:${error.response?.status}-${message},请检查网络或联系管理员!`)
Logger.error(`httpStatus:${error.response?.status}-${message},请检查网络或联系管理员!`)
errorBean = buildError(error.response.status)
}
return Promise.reject(errorBean);
... ...
... ... @@ -33,7 +33,9 @@ export class AppLinkingManager {
this.onNewWant(want, true)
}
onNewWant(want: Want, startup: boolean = false) {
Logger.debug(TAG, "want: " + JSON.stringify(want))
Logger.debugOptimize(TAG, () => {
return "want: " + JSON.stringify(want)
})
let uri = want?.uri
if (!uri) {
return
... ...
... ... @@ -70,7 +70,9 @@ export struct WdWebComponent {
for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) {
let handleName = H5CallNativeType.JsCallTypeList[i];
let handle = (data: Message, f: Callback) => {
Logger.debug('registerHandlers handlerName: ' + JSON.stringify(data))
Logger.debugOptimize(TAG, () => {
return 'recivedData: ' + JSON.stringify(data)
})
this.defaultPerformJSCallNative(data, f)
this.defaultGetReceiveSubjectData(data, f)
};
... ...
... ... @@ -52,7 +52,9 @@ export class WebArticleEventHandler implements WebEvents {
url = url.replace("%(?![0-9a-fA-F]{2})", "%25")
.replace("\\+", "%2B");
url = decodeURIComponent(url)
Logger.debug(TAG, 'Web onLoadIntercept url: ' + url);
Logger.debugOptimize(TAG, () => {
return 'Web onLoadIntercept url: ' + url
});
if (url.startsWith(BridgeUtil.YY_RETURN_DATA)) {
this.webviewControl?.handlerReturnData(url)
return true
... ... @@ -70,7 +72,9 @@ export class WebArticleEventHandler implements WebEvents {
for (let i = 0; i < H5CallNativeType.JsCallTypeList.length; i++) {
let handleName = H5CallNativeType.JsCallTypeList[i];
let handle = (data: Message, f: Callback) => {
Logger.debug('registerHandlers handlerName: ' + JSON.stringify(data.data))
Logger.debugOptimize(TAG, () => {
return 'receivedData: ' + JSON.stringify(data.data)
})
if (this.currentPageOperateBlock) {
this.currentPageOperateBlock(data, f)
}
... ...
... ... @@ -16,13 +16,14 @@ import { Card19Component } from './cardview/Card19Component';
import { Card20Component } from './cardview/Card20Component';
import { Card21Component } from './cardview/Card21Component';
import { SearchContentComponent } from './cardview/SearchContentComponent';
import { DateTimeUtils } from 'wdKit/Index';
import { DateTimeUtils, Logger } from 'wdKit/Index';
import { TrackConstants, TrackingPageBrowse } from 'wdTracking/Index';
import { LiveBigImage02Component } from './cardview/LiveBigImage02Component';
import { LiveBigImage01Component } from './cardview/LiveBigImage01Component';
import { behindDivider } from './cardCommon/behindDivider'
import PageModel from '../viewmodel/PageModel';
const TAG = "CardParser"
/**
* card适配器,卡片样式汇总,依据ContentDTO#appStyle
* 卡片样式,最小单元样式布局
... ... @@ -42,7 +43,9 @@ export struct CardParser {
isNeedDivider:boolean = true
aboutToAppear(): void {
console.log('CardParser-', JSON.stringify(this.contentDTO))
Logger.debugOptimize(TAG, () => {
return JSON.stringify(this.contentDTO)
})
}
onPageShow() {
... ...
... ... @@ -43,7 +43,7 @@ export struct CarderInteraction {
this.likeBean['userHeaderUrl'] = this.contentDetailData.userInfo?.headPhotoUrl + ''
this.likeBean['channelId'] = this.contentDetailData.reLInfo?.channelId + ''
this.contentDTO.shareFlag = this.contentDTO.shareFlag ? this.contentDTO.shareFlag : '1'
console.log('是否显示分享',this.contentDTO.shareFlag)
Logger.debug(TAG, '是否显示分享',this.contentDTO.shareFlag)
// 内容用 点赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空
this.likesStyle = this.contentDetailData.likesStyle
this.openLikes = this.contentDetailData.openLikes == 1 ? true : false
... ...
... ... @@ -27,6 +27,7 @@ import {
import { LabelComponent } from './view/LabelComponent';
import { LiveHorizontalCardComponent } from './view/LiveHorizontalCardComponent';
import { behindDivider } from './cardCommon/behindDivider'
import { Logger } from 'wdKit';
/**
* comp适配器.
... ... @@ -46,7 +47,9 @@ export struct CompParser {
aboutToAppear(): void {
console.log('CompParser', JSON.stringify(this.compDTO))
Logger.debugOptimize('CompParser', () => {
return JSON.stringify(this.compDTO)
})
this.pageName = this.pageModel.pageInfo.name
// 轮播图屏蔽音频类型稿件
if (this.compDTO.compStyle === CompStyle.Zh_Carousel_Layout_01) {
... ...
import { ContentDTO, joinPeopleNum } from 'wdBean/Index'
import { DateTimeUtils } from 'wdKit/Index'
import { DateTimeUtils, Logger } from 'wdKit/Index'
import { LottieView } from '../../components/lottie/LottieView';
import { LiveModel } from '../../viewmodel/LiveModel'
import font from '@ohos.font';
import text from '@ohos.graphics.text';
const TAG = "CardMediaInfo"
/**
* 这里是样式卡中,右下角显示的音视频信息
* 目前已知:
... ... @@ -86,11 +87,13 @@ export struct CardMediaInfo {
*/
async getJoinPeopleNum() {
if (this.contentDTO.objectType !== '2') return;
console.log('getJoinPeopleNum-ContentDTO', JSON.stringify(this.contentDTO.objectId))
let liveIdList: string = this.contentDTO.objectId
let data: joinPeopleNum[] = await LiveModel.getJoinPeopleNum(liveIdList)
Logger.debugOptimize(TAG, () => {
return 'getJoinPeopleNum-ContentDTO' + JSON.stringify(this.contentDTO.objectId)
})
LiveModel.getJoinPeopleNum(this.contentDTO.objectId).then((data) => {
this.joinPeopleNum = data[0].pv;
console.log('getJoinPeopleNum ', this.joinPeopleNum)
Logger.debug(TAG, 'getJoinPeopleNum ' + this.joinPeopleNum)
})
}
build() {
... ...
... ... @@ -6,6 +6,8 @@ import { SearchShowRed, textItem, titleInitRes } from '../../utils/searchShowRed
import measure from '@ohos.measure'
import display from '@ohos.display';
const TAG = "CardSourceInfo"
@Reusable
@Component
export struct CardSourceInfo {
... ... @@ -171,25 +173,25 @@ export struct CardSourceInfo {
calcContentSpace() {
console.log('display-text ,', this.displayText)
// Logger.debug(TAG, 'display-text ' + this.displayText)
if (this.isLimited()) return;
const screenWidth = display.getDefaultDisplaySync().width
let leftSpace = screenWidth;
console.log('display-leftSpace ', leftSpace)
// Logger.debug(TAG, 'display-leftSpace ' + leftSpace)
const souceSize = this.getContentSize(this.displayText, 12);
const dotSize = 11;
if (this.contentDTO.cornerMark || this.contentDTO.corner) {
const cornerSize = this.getContentSize(this.contentDTO.cornerMark || this.contentDTO.corner, 12);
leftSpace = leftSpace - cornerSize
console.log('display-cornerMark ', cornerSize)
// Logger.debug(TAG, ('display-cornerMark ' + cornerSize)
}
if (this.showTime()) {
const timeSize = this.getContentSize(this.handleTimeStr(), 12);
leftSpace = leftSpace - dotSize - timeSize
console.log('display-showtime')
// Logger.debug(TAG, 'display-showtime')
}
if (!this.isEllipsisActive) {
... ... @@ -199,14 +201,14 @@ export struct CardSourceInfo {
commentSize = this.getContentSize(`${this.handlerNum(commentNum.toString())}评`, 12);
}
leftSpace = leftSpace - dotSize - commentSize
console.log('display-commentSize ', commentSize)
// Logger.debug(TAG, 'display-commentSize ' + commentSize)
}
if (leftSpace < souceSize) {
this.onlyShowCornerAndSource = true;
console.log('display-size 1')
// Logger.debug(TAG, 'display-size 1')
}
console.log('display-size 2,', leftSpace, souceSize, this.onlyShowCornerAndSource)
// Logger.debug(TAG, 'display-size 2,' + leftSpace + " " + souceSize + " " + this.onlyShowCornerAndSource)
}
build() {
... ...
... ... @@ -29,8 +29,10 @@ export struct Card6Component {
@State contentDTO: ContentDTO = new ContentDTO();
@State compIndex: number = 0;
async aboutToAppear(): Promise<void> {
console.log('Card6Component', JSON.stringify(this.contentDTO))
aboutToAppear() {
Logger.debugOptimize(TAG, () => {
return 'Card6Component' + JSON.stringify(this.contentDTO)
})
this.titleInit();
const curRouter = router.getState().name;
this.clicked = hasClicked(this.contentDTO.objectId, curRouter)
... ...
... ... @@ -160,10 +160,9 @@ export struct CommentCustomDialog {
// this.textInputController.stopEditing()
inputMethod.getController().hideTextInput((err: BusinessError) => {
if (err) {
Logger.error(TAG, (`Failed to hideTextInput: ${JSON.stringify(err)}`);
Logger.error(TAG, `Failed to hideTextInput: ${JSON.stringify(err)}`);
return;
}
// console.log('Succeeded in hiding text input.');
})
// this.showKeyboardOnFocus = false
// focusControl.requestFocus("textAreaId") // 弹起键盘
... ...
... ... @@ -50,7 +50,7 @@ export struct ZhSingleRow03 {
@State compIndex: number = 0;
resetMoreTips() {
console.log('resetMoreTips', this.moreWidth, this.initMoreWidth)
Logger.debug(TAG, 'resetMoreTips' + this.moreWidth + ' ' + this.initMoreWidth)
if (this.moreWidth < this.initMoreWidth * 2) {
this.moreTips = '查看更多';
}
... ...
... ... @@ -301,7 +301,7 @@ export struct PageComponent {
}
async aboutToAppear() {
aboutToAppear() {
// 选中tab,才请求数据。拦截大量接口请求
if (this.navIndex === this.currentTopNavSelectedIndex) {
this.getData();
... ... @@ -364,7 +364,7 @@ export struct PageComponent {
autoRefresh(this.pageModel, this.pageAdvModel)
}
async getData() {
getData() {
if (this.timer) {
clearTimeout(this.timer)
}
... ...
... ... @@ -20,7 +20,7 @@ export struct FirstTabTopSearchComponent {
private swiperController: SwiperController = new SwiperController()
navItem: BottomNavDTO = {} as BottomNavDTO
async aboutToAppear() {
aboutToAppear() {
this.getSearchHint()
}
... ...
... ... @@ -198,7 +198,9 @@ export class GetuiPush {
this.onNewWant(want, true)
}
onNewWant(want: Want, startup: boolean = false) {
Logger.debug(TAG, "want: " + JSON.stringify(want))
Logger.debugOptimize(TAG, () => {
return "want: " + JSON.stringify(want)
})
this.lastPushContent = undefined
let pushContent = PushContentParser.getPushLinkFromWant(want)
... ... @@ -441,7 +443,7 @@ export class GetuiPush {
bean["appVersion"] = AppUtils.getAppVersionName()
bean["platform"] = 3
HttpBizUtil.post<ResponseDTO<string>>(url, bean).then((data) => {
Logger.debug(TAG, "上传cid成功" + JSON.stringify(data))
Logger.debug(TAG, "上传cid成功")
}).catch((e: BusinessError) => {
Logger.debug(TAG, "上传cid失败" + JSON.stringify(e))
})
... ...
... ... @@ -5,6 +5,7 @@ import { SpConstants } from 'wdConstant/Index';
import { EmitterEventId, EmitterUtils, Logger, PermissionUtils, ResourcesUtils, SPHelper } from 'wdKit/Index';
import { ResponseDTO } from 'wdNetwork/Index';
const TAG = "HWLocationUtils"
/**
* 系统定位服务实现
* */
... ... @@ -21,7 +22,7 @@ export class HWLocationUtils {
maxAccuracy: 0
};
geoLocationManager.on('locationChange', requestInfo, (data) => {
Logger.debug('location :' + JSON.stringify(data))
Logger.debug(TAG, JSON.stringify(data))
})
}
... ... @@ -35,7 +36,7 @@ export class HWLocationUtils {
maxAccuracy: 0
};
geoLocationManager.on('locationChange', requestInfo, (data) => {
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}
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}
let record: Record<string, string | number> = {};
record['latitude'] = data.latitude
record['longitude'] = data.longitude
... ... @@ -75,13 +76,16 @@ export class HWLocationUtils {
try {
geoLocationManager.getCurrentLocation(requestInfo).then((result) => {
//{"latitude":31.8687047,"longitude":117.30152005,"altitude":0,"accuracy":5000,"speed":0,"timeStamp":1713331875766,"direction":0,"timeSinceBoot":588949694096931,"additions":"","additionSize":0}
Logger.debug('location' + JSON.stringify(result))
Logger.debugOptimize('location', () => {
return JSON.stringify(result)
})
HWLocationUtils.getReverseGeoCodeRequest(result.latitude, result.longitude)
})
.catch((error: number) => {
Logger.debug('location' + JSON.stringify(error))
Logger.error(TAG, JSON.stringify(error))
});
} catch (err) {
Logger.error(TAG, JSON.stringify(err))
}
}
... ... @@ -89,7 +93,7 @@ export class HWLocationUtils {
let requestInfo: geoLocationManager.GeoCodeRequest = { 'description': description };
geoLocationManager.getAddressesFromLocationName(requestInfo, (error, data) => {
if (data) {
Logger.debug('location :' + JSON.stringify(data))
Logger.debug(TAG, JSON.stringify(data))
}
//[{"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}]
})
... ... @@ -103,10 +107,12 @@ export class HWLocationUtils {
};
geoLocationManager.getAddressesFromLocation(requestInfo, async (error, data) => {
if (error) {
Logger.debug('location :' + JSON.stringify(error))
Logger.error(TAG, JSON.stringify(error))
}
if (data) {
Logger.debug('location :' + JSON.stringify(data))
Logger.debugOptimize(TAG, () => {
return JSON.stringify(data)
})
if (data[0] && data[0].administrativeArea && data[0].subAdministrativeArea) {
let cityName = data[0].subAdministrativeArea;
let name = await SPHelper.default.get(SpConstants.LOCATION_CITY_NAME, '') as string
... ... @@ -136,7 +142,7 @@ export class HWLocationUtils {
// geoLocationManager.off('locationChange')
return new Promise<boolean>((success, fail) => {
geoLocationManager.off("locationChange", (data) => {
Logger.debug('location :' + JSON.stringify(data))
Logger.debug(TAG, JSON.stringify(data))
success(true)
})
})
... ...
... ... @@ -63,7 +63,9 @@ export default class HuaweiAuth {
controller.executeRequest(authRequest).then((response: authentication.AuthorizationWithHuaweiIDResponse) => {
let anonymousPhone = response.data?.extraInfo?.quickLoginAnonymousPhone;
if (anonymousPhone) {
Logger.info(TAG, 'get anonymousPhone, ' + JSON.stringify(response));
Logger.infoOptimize(TAG, () => {
return 'get anonymousPhone, ' + JSON.stringify(response)
})
this._anonymousPhone = anonymousPhone as string
resolve(this._anonymousPhone)
return;
... ...
... ... @@ -16,6 +16,7 @@ import { LaunchPageModel } from './viewModel/LaunchPageModel';
import { JSON } from '@kit.ArkTS';
import { WebArticleEventHandler, WebPoolManager } from 'wdWebComponent';
import { BridgeWebViewControl } from 'wdJsBridge';
import { webview } from '@kit.ArkWeb';
const TAG = 'MainPage';
... ... @@ -40,8 +41,6 @@ struct MainPage {
aboutToAppear() {
StartupManager.sharedInstance().appReachMainPage()
this.breakpointSystem.register()
// Logger.info(TAG, `aboutToAppear `);
... ... @@ -64,7 +63,14 @@ struct MainPage {
}
setTimeout(() => {
// 这里延后,因为有可能是换端进入H5页面
setTimeout(() => {
StartupManager.sharedInstance().appReachMainPage()
}, 200)
webview.WebviewController.initializeWebEngine()
ComponentModule.preInitArticleWebTemplate(this.getUIContext())
}, 500)
}
... ...
... ... @@ -49,7 +49,9 @@ export class StartupManager {
// App启动
appOnCreate(want: Want, launchParam: AbilityConstant.LaunchParam, context: common.UIAbilityContext) {
Logger.debug(TAG, "App onCreate: " + `\nwant: ${want}\nlaunchParam: ${launchParam}`)
Logger.debugOptimize(TAG, () => {
return "App onCreate: " + `\nwant: ${want}\nlaunchParam: ${launchParam}`
})
this.context = context
// 设置图片文件数据缓存上限为200MB (200MB=200*1024*1024B=209715200B)
app.setImageFileCacheSize(209715200)
... ... @@ -161,7 +163,7 @@ export class StartupManager {
//TODO:
// 提前初始化webview
webview.WebviewController.initializeWebEngine()
// webview.WebviewController.initializeWebEngine()
initGlobalPlayerSettings(this.context!)
... ...