mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
37 lines
612 B
JavaScript
37 lines
612 B
JavaScript
import Vue from 'vue';
|
|
|
|
const _global = Vue.prototype.$isServer ? global : window;
|
|
|
|
const DEFAULT_CONTEXT = {
|
|
idSeed: 1,
|
|
zIndex: 2000,
|
|
hasModal: false,
|
|
instances: {},
|
|
modalStack: []
|
|
};
|
|
|
|
if (!_global.popupContext) {
|
|
_global.popupContext = {
|
|
...DEFAULT_CONTEXT
|
|
};
|
|
}
|
|
|
|
const PopupContext = {
|
|
getContext(key) {
|
|
return _global.popupContext[key];
|
|
},
|
|
|
|
setContext(key, value) {
|
|
_global.popupContext[key] = value;
|
|
},
|
|
|
|
plusKeyByOne(key) {
|
|
const oldVal = +_global.popupContext[key];
|
|
_global.popupContext[key] = oldVal + 1;
|
|
|
|
return oldVal;
|
|
}
|
|
};
|
|
|
|
export default PopupContext;
|