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