u
This commit is contained in:
1 parent
8eedf281fd
commit
35bc29f356
13 files changed
+675
-171
No files matched your search
@@ -1,15 +1,8 @@
|
||||
let zIndexBase = 1000
|
||||
const modalStack: number[] = [] // 当前打开的 Modal zIndex
|
||||
const freeZIndex: number[] = [] // 已关闭 Modal 可复用 zIndex
|
||||
|
||||
export function addModal() {
|
||||
let zIndex: number
|
||||
if (freeZIndex.length > 0) {
|
||||
zIndex = freeZIndex.pop()!
|
||||
}
|
||||
else {
|
||||
zIndex = ++zIndexBase
|
||||
}
|
||||
const zIndex = ++zIndexBase // 每次直接递增
|
||||
modalStack.push(zIndex)
|
||||
return zIndex
|
||||
}
|
||||
@@ -17,8 +10,7 @@ export function addModal() {
|
||||
export function removeModal(zIndex: number) {
|
||||
const idx = modalStack.indexOf(zIndex)
|
||||
if (idx !== -1) {
|
||||
modalStack.splice(idx, 1)
|
||||
freeZIndex.push(zIndex) // 回收 zIndex
|
||||
modalStack.splice(idx, 1) // 只移出 stack,不回收 zIndex
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user