dsh-model-doctor 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client/index.js +8 -3
- package/package.json +1 -1
package/lib/client/index.js
CHANGED
|
@@ -746,6 +746,8 @@ window.__ModuleLoader__.load({
|
|
|
746
746
|
|
|
747
747
|
let reportSignature = ''
|
|
748
748
|
let reportAt = 0
|
|
749
|
+
/** 最近一次写入的报告是否包含「菜单已打开」的现场。 */
|
|
750
|
+
let lastReportHadMenu = false
|
|
749
751
|
|
|
750
752
|
function describe(el) {
|
|
751
753
|
if (el === null || el === undefined) return null
|
|
@@ -754,16 +756,19 @@ window.__ModuleLoader__.load({
|
|
|
754
756
|
return { tag: el.tagName, role: el.getAttribute('role') ?? '', cls, text }
|
|
755
757
|
}
|
|
756
758
|
|
|
757
|
-
function reportDiagnostics(state,
|
|
759
|
+
function reportDiagnostics(state, menuVisible = false) {
|
|
758
760
|
if (doctor === null) return
|
|
759
761
|
const { at, ...rest } = state
|
|
760
762
|
const signature = JSON.stringify(rest)
|
|
761
763
|
const now = Date.now()
|
|
762
|
-
|
|
763
|
-
|
|
764
|
+
const isError = typeof state.error === 'string'
|
|
765
|
+
// 报告里已经留下「菜单打开」的现场时,不要被随后「菜单关闭」的空扫描覆盖(错误除外)
|
|
766
|
+
if (!menuVisible && !isError && lastReportHadMenu) return
|
|
767
|
+
if (!isError && signature === reportSignature && now - reportAt < (menuVisible ? 5000 : 1200)) return
|
|
764
768
|
if (now - reportAt < 400) return
|
|
765
769
|
reportSignature = signature
|
|
766
770
|
reportAt = now
|
|
771
|
+
lastReportHadMenu = menuVisible
|
|
767
772
|
void doctor.clientReport(state)
|
|
768
773
|
}
|
|
769
774
|
|
package/package.json
CHANGED