Quellcode durchsuchen

feat: 打印加载时间

TIANYONG vor 2 Monaten
Ursprung
Commit
8a2b4621e0

+ 1 - 1
osmd-extended

@@ -1 +1 @@
-Subproject commit a9750e2d69cdef62c365035e86f131586a25aa69
+Subproject commit 4ebb0ca539cdf162b77078d69830820764752a3d

+ 10 - 0
src/page-instrument/view-detail/index.tsx

@@ -117,6 +117,7 @@ export default defineComponent({
         }
       }
     };
+    console.time('开始加载')
     onBeforeMount(async () => {
       // console.time("渲染加载耗时");
       api_keepScreenLongLight();
@@ -151,6 +152,14 @@ export default defineComponent({
         }
       }
     };
+    window.onload = function() {
+      console.log('加载完成111')
+      let timing: any = performance.getEntriesByType('navigation')[0];
+      console.log(timing.domInteractive);
+      console.log(timing.fetchStart);
+      let diff = timing.domInteractive - timing.fetchStart;
+      console.log("TTI: " + diff);
+    };
     // console.log(route.params, query)
     onMounted(async () => {
       (window as any).appName = "colexiu";
@@ -172,6 +181,7 @@ export default defineComponent({
       //   getMusicInfo(values[0]);
       // });
       window.addEventListener('message', changePlay)
+      console.log('加载中22222')
       const guideInfoStore = localStorage.getItem('guideInfo') ? JSON.parse(localStorage.getItem('guideInfo')) : {};
       state.guideInfo = guideInfoStore
       try { 

+ 1 - 0
src/view/audio-list/index.tsx

@@ -564,6 +564,7 @@ export default defineComponent({
 				// 监听midi播放结束
 				api_cloudplayed(midiPlayEnd);
 			}
+			console.timeEnd('开始加载')
 		});
 		onUnmounted(() => {
 			api_remove_cloudplayed(midiPlayEnd);

+ 2 - 0
src/view/music-score/index.tsx

@@ -74,12 +74,14 @@ export default defineComponent({
 				downloadXmlStr.value = await fetch(state.xmlUrl).then((response) => response.text())
 			}
 			const xmlStr = downloadXmlStr.value;
+			console.time('解析xml')
 			const parseXmlInfo = getCustomInfo(xmlStr);
 			const xml = formatXML(parseXmlInfo.parsedXML);
 			musicData.score = state.isCombineRender ? xml : onlyVisible(xml, state.partIndex);
 			if (state.gradualTimes) {
 				state.gradual = getGradualLengthByXml(xml);
 			}
+			console.timeEnd('解析xml')
 		};
 
 		const init = async () => {

+ 4 - 1
src/view/selection/index.tsx

@@ -277,11 +277,14 @@ export default defineComponent({
 			}
 			return []
 		})
-
+		console.time('dom挂载')
 		onMounted(() => {
+			console.timeEnd('dom挂载')
 			selectData.notes = [];
 			selectData.staves = [];
+			console.time('添加dom时间')
 			calcNoteData();
+			console.timeEnd('添加dom时间')
 			const img: HTMLElement = document.querySelector('#cursorImg-0')!
 			if (metronomeData.cursorMode === 2){
 				img.classList.add('lineHide')