@truenewx/tnxvue3 3.0.16 → 3.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truenewx/tnxvue3",
3
- "version": "3.0.16",
3
+ "version": "3.0.18",
4
4
  "description": "互联网技术解决方案:Vue3扩展支持",
5
5
  "private": false,
6
6
  "type": "module",
@@ -24,7 +24,7 @@
24
24
  "vue-router": "~4.4.0"
25
25
  },
26
26
  "dependencies": {
27
- "@truenewx/tnxcore": "3.0.14",
27
+ "@truenewx/tnxcore": "3.0.16",
28
28
  "@element-plus/icons-vue": "2.3.1",
29
29
  "async-validator": "4.2.5",
30
30
  "mitt": "3.0.1"
@@ -52,8 +52,11 @@ export default build('tnxbsv', () => {
52
52
  libs: Object.assign({}, tnxjq.libs, tnxvue.libs, {BootstrapVue}),
53
53
  components,
54
54
  componentDefaultApp: undefined, // 组件的默认app,从服务端获取数据的组件以此为远程请求的默认app
55
- _dialogs: [], // 对话框堆栈
55
+ dialogInstances: [], // 对话框堆栈
56
56
  dialog(content, title, buttons, options, contentProps) {
57
+ // 弹出之前关闭所有加载框
58
+ this.hideLoading();
59
+
57
60
  let id = new Date().getTime();
58
61
  let containerId = 'dialog-container-' + id;
59
62
  let componentDefinition = Object.assign({}, Dialog,);
@@ -74,10 +77,10 @@ export default build('tnxbsv', () => {
74
77
  let dialog = dialogVm.mount(dialogContainer);
75
78
  dialog.onHidden = this.util.function.after(dialog.onHidden, () => {
76
79
  dialogVm.unmount();
77
- this._dialogs.remove(dialog);
80
+ window.tnx.dialogInstances.remove(dialog);
78
81
  document.body.removeChild(dialogContainer);
79
82
  });
80
- this._dialogs.push(dialog);
83
+ window.tnx.dialogInstances.push(dialog);
81
84
  return dialogVm;
82
85
  },
83
86
  _closeMessage() {
@@ -189,18 +192,24 @@ export default build('tnxbsv', () => {
189
192
  this._closeMessage();
190
193
 
191
194
  let div = document.createElement('div');
195
+ div.classList.add('tnxbsv-loading-overlay')
192
196
  document.body.appendChild(div);
193
197
  let instance = window.tnx.createVueInstance(LoadingOverlay, null, {message});
194
- let component = instance.mount(div);
195
- window.tnx.loadingInstance = instance;
198
+ instance.mount(div);
199
+ window.tnx.loadingInstances.push(instance);
196
200
  window.tnx.app.eventBus.emit('tnx.showLoading', options);
197
- return component;
198
201
  },
202
+ loadingInstances: [],
199
203
  hideLoading() {
200
- if (window.tnx.loadingInstance) {
201
- window.tnx.loadingInstance.unmount();
202
- document.body.removeChild(window.tnx.loadingInstance._container);
203
- window.tnx.loadingInstance = null;
204
+ if (window.tnx.loadingInstances.length) {
205
+ window.tnx.loadingInstances.forEach(instance => {
206
+ instance.unmount();
207
+ });
208
+ window.tnx.loadingInstances.length = 0;
209
+ // 删除所有div.tnxbsv-loading-overlay
210
+ document.body.querySelectorAll('div.tnxbsv-loading-overlay').forEach(div => {
211
+ document.body.removeChild(div);
212
+ });
204
213
  }
205
214
  },
206
215
  closeLoading() {
package/src/tnxvue.js CHANGED
@@ -96,10 +96,14 @@ export default build('tnxvue', () => {
96
96
  } else if (window.tnx.router.instance) {
97
97
  vm.config.globalProperties.$router = window.tnx.router.instance;
98
98
  }
99
- window.tnx.app.eventBus = window.tnx.app.eventBus || mitt();
100
- window.tnx.app.eventBus.once = function (name, handler) {
101
- this.all.set(name, [handler]);
99
+
100
+ if (!window.tnx.app.eventBus) {
101
+ window.tnx.app.eventBus = window.tnx.app.eventBus || mitt();
102
+ window.tnx.app.eventBus.once = function (name, handler) {
103
+ this.all.set(name, [handler]);
104
+ }
102
105
  }
106
+
103
107
  return vm;
104
108
  },
105
109
  install(vm) {