From c5d5c90c069778db98800a437f5d0b8057a29d53 Mon Sep 17 00:00:00 2001 From: cookfront Date: Fri, 10 Mar 2017 17:22:47 +0800 Subject: [PATCH] fix popup manager --- src/mixins/popup/index.js | 19 ++++++++++--------- src/mixins/popup/popup-manager.js | 13 +------------ 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/mixins/popup/index.js b/src/mixins/popup/index.js index b7a9a7741..8303addbb 100644 --- a/src/mixins/popup/index.js +++ b/src/mixins/popup/index.js @@ -2,19 +2,20 @@ import Vue from 'vue'; import merge from 'src/utils/merge'; import PopupManager from './popup-manager'; -let popupContext; +let popupContext = { + idSeed: 1, + zIndex: 2000, + hasModal: false, + instances: {}, + modalStack: [] +}; + if (Vue.prototype.$isServer) { - popupContext = global.popupContext || {}; global.popupContext = popupContext; } else { - popupContext = window.popupContext || {}; window.popupContext = popupContext; } -popupContext = merge(popupContext, { - idSeed: 1 -}); - const getDOM = function(dom) { if (dom.nodeType === 3) { dom = dom.nextElementSibling || dom.nextSibling; @@ -98,9 +99,9 @@ export default { const props = merge({}, this, options); const zIndex = props.zIndex; - // 如果属性中传入了`zIndex`,则覆盖`PopupManager`中对应的`zIndex` + // 如果属性中传入了`zIndex`,则覆盖`popupContext`中对应的`zIndex` if (zIndex) { - PopupManager.zIndex = zIndex; + popupContext.zIndex = zIndex; } // 如果显示遮罩层 diff --git a/src/mixins/popup/popup-manager.js b/src/mixins/popup/popup-manager.js index 4fea88a08..d574d9792 100644 --- a/src/mixins/popup/popup-manager.js +++ b/src/mixins/popup/popup-manager.js @@ -1,22 +1,13 @@ import Vue from 'vue'; -import merge from 'src/utils/merge'; import { addClass } from 'src/utils/dom'; let popupContext; if (Vue.prototype.$isServer) { popupContext = global.popupContext || {}; - global.popupContext = popupContext; } else { popupContext = window.popupContext || {}; - window.popupContext = popupContext; } -popupContext = merge(popupContext, { - hasModal: false, - instances: {}, - modalStack: [] -}); - const getModal = function() { let modalDom = PopupManager.modalDom; if (modalDom) { @@ -40,10 +31,8 @@ const getModal = function() { }; const PopupManager = { - zIndex: 2000, - nextZIndex() { - return this.zIndex++; + return popupContext.zIndex++; }, getInstance(id) {