Skip to content

Commit 3b9df99

Browse files
author
hdx
committed
feat(performance): 支持 Harmony
1 parent d664f4d commit 3b9df99

File tree

1 file changed

+7
-12
lines changed
  • packages/uni-app-plus/src/x/api/performance

1 file changed

+7
-12
lines changed

packages/uni-app-plus/src/x/api/performance/index.ts

+7-12
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import type {
1515
PerformanceObserverOptions,
1616
} from '@dcloudio/uni-app-x/types/uni'
1717
import { onAfterRoute, onBeforeRoute, onPageReady } from '../route/performance'
18+
import { getNativeApp } from '../../framework/app/app'
1819

1920
// TODO
2021
const APP_LAUNCH = 'appLaunch'
@@ -28,15 +29,15 @@ const ENTRY_TYPE_NAVIGATION = 'navigation'
2829
const RENDER_TYPE_FIRST_LAYOUT = 'firstLayout'
2930
const RENDER_TYPE_FIRST_RENDER = 'firstRender'
3031

31-
const AppStartDuration = 1
32+
// const AppStartDuration = 1
3233
// const PageRenderDuration = 1
3334
// const PageLayoutDuration = 2
3435
// const PageRenderCount = 3
3536
// const PageLayoutCount = 4
3637
// const PageFirstRenderStartTime = 5
3738
// const PageFirstLayoutStartTime = 6
38-
const PageFirstPageRenderDuration = 7
39-
const PageFirstPageLayoutDuration = 8
39+
// const PageFirstPageRenderDuration = 7
40+
// const PageFirstPageLayoutDuration = 8
4041

4142
/// status machine
4243
class PerformanceEntryStatus {
@@ -120,10 +121,7 @@ class PerformanceEntryStatusLayout extends PerformanceEntryStatus {
120121
const innerPage = super.getCurrentInnerPage()
121122
if (innerPage != null) {
122123
// @ts-expect-error
123-
this._entryData.duration = nativePage.getDuration(
124-
innerPage.pageId,
125-
PageFirstPageLayoutDuration
126-
)
124+
this._entryData.duration = innerPage.getFirstPageLayoutDuration()
127125
}
128126
}
129127
}
@@ -146,10 +144,7 @@ class PerformanceEntryStatusRender extends PerformanceEntryStatus {
146144
const innerPage = super.getCurrentInnerPage()
147145
if (innerPage != null) {
148146
// @ts-expect-error
149-
this._entryData.duration = nativePage.getDuration(
150-
innerPage.pageId,
151-
PageFirstPageRenderDuration
152-
)
147+
this._entryData.duration = innerPage.getFirstPageRenderDuration()
153148
}
154149
}
155150
}
@@ -173,7 +168,7 @@ class PerformanceEntryStatusNavigation extends PerformanceEntryStatus {
173168
this._entryData.duration = Date.now() - this._entryData.startTime
174169
if (this._entryData.name == APP_LAUNCH) {
175170
// @ts-expect-error
176-
this._entryData.duration += nativePage.getDuration(AppStartDuration)
171+
this._entryData.duration += getNativeApp().getAppStartDuration()
177172
}
178173
}
179174
}

0 commit comments

Comments
 (0)