()
| 98 | } |
| 99 | |
| 100 | function getHighestZIndexValue() { |
| 101 | try { |
| 102 | let maxZIndex = -Infinity |
| 103 | let foundAny = false |
| 104 | |
| 105 | const allElements = document.all || document.querySelectorAll('*') |
| 106 | |
| 107 | for (let i = 0; i < allElements.length; i++) { |
| 108 | const element = allElements[i] |
| 109 | |
| 110 | if (!element || element.nodeType !== 1) continue |
| 111 | |
| 112 | const styles = window.getComputedStyle(element) |
| 113 | |
| 114 | const position = styles.position |
| 115 | if (position === 'static') continue |
| 116 | |
| 117 | const zIndex = styles.zIndex |
| 118 | let zIndexValue |
| 119 | |
| 120 | if (zIndex === 'auto') { |
| 121 | zIndexValue = 0 |
| 122 | } else { |
| 123 | zIndexValue = parseInt(zIndex, 10) |
| 124 | if (isNaN(zIndexValue)) continue |
| 125 | } |
| 126 | |
| 127 | foundAny = true |
| 128 | |
| 129 | // 快速返回:如果找到很大的z-index,很可能就是最大值 |
| 130 | /* if (zIndexValue > 10000) { |
| 131 | return zIndexValue; |
| 132 | } */ |
| 133 | |
| 134 | if (zIndexValue > maxZIndex) { |
| 135 | maxZIndex = zIndexValue |
| 136 | } |
| 137 | } |
| 138 | return foundAny ? maxZIndex : 0 |
| 139 | } catch (error) { |
| 140 | console.warn('获取最高z-index时出错,返回默认值0:', error) |
| 141 | return 0 |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * 初始化引导 |
no outgoing calls
no test coverage detected