Skip to content

Commit

Permalink
feat: zIndex 全局管理,由内存改为 sessionStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
ocean-gao committed Nov 1, 2024
1 parent 00ddba0 commit 0bdfadc
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions components/_util/popupManager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import { useSessionStorage } from '@vueuse/core';
import { getPrefixStorage } from '../_util/storage';

const INIT_Z_INDEX = 2000;

const zIndex = useSessionStorage<number>(getPrefixStorage('z-index'), INIT_Z_INDEX);
if (zIndex.value < INIT_Z_INDEX) {
zIndex.value = INIT_Z_INDEX;
}

const PopupManager = {
zIndex: 2000,
zIndex: zIndex.value,
nextZIndex() {
return ++PopupManager.zIndex;
++zIndex.value;
PopupManager.zIndex = zIndex.value;
return PopupManager.zIndex;
},
};

Expand Down

0 comments on commit 0bdfadc

Please sign in to comment.