@jr-public/jr-upload-ui 1.0.3 → 1.0.4

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,10 +1,10 @@
1
1
  {
2
2
  "name": "@jr-public/jr-upload-ui",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "JR upload modal components for Vue2 and Vue3",
5
5
  "license": "MIT",
6
6
  "private": false,
7
- "sideEffects": false,
7
+ "sideEffects": ["*.vue", "*.css"],
8
8
  "main": "./packages/vue2/src/index.js",
9
9
  "module": "./packages/vue3/src/index.js",
10
10
  "exports": {
@@ -315,7 +315,10 @@ export default {
315
315
  uploadPath: { type: String, default: '' },
316
316
 
317
317
  // bucket名称(可选)
318
- bucketName: { type: String, default: '' }
318
+ bucketName: { type: String, default: '' },
319
+
320
+ // 是否将弹框DOM挂载到document.body,避免父容器overflow:hidden影响
321
+ appendToBody: { type: Boolean, default: true }
319
322
  },
320
323
 
321
324
  data() {
@@ -423,6 +426,12 @@ export default {
423
426
  visible(newVal) {
424
427
  if (newVal) {
425
428
  this.initializeComponent()
429
+ // append-to-body: 弹框显示时将根元素移动到document.body
430
+ if (this.appendToBody) {
431
+ this.$nextTick(() => {
432
+ document.body.appendChild(this.$el)
433
+ })
434
+ }
426
435
  // 调试信息:打印当前组件参数
427
436
  console.log('🔧 JrUploadModal 组件参数:', {
428
437
  accept: this.accept,
@@ -466,11 +475,20 @@ export default {
466
475
  await this.initializeComponent()
467
476
  }
468
477
 
478
+ // append-to-body: 组件挂载时将根元素移动到document.body
479
+ if (this.appendToBody) {
480
+ document.body.appendChild(this.$el)
481
+ }
482
+
469
483
  // 动态设置CSS背景图片
470
484
  this.setDynamicBackgroundImages()
471
485
  },
472
486
 
473
487
  beforeDestroy() {
488
+ // append-to-body cleanup: 从document.body移除已挂载的元素
489
+ if (this.appendToBody && this.$el && this.$el.parentNode === document.body) {
490
+ document.body.removeChild(this.$el)
491
+ }
474
492
  this.cleanup()
475
493
  },
476
494
 
@@ -257,7 +257,7 @@
257
257
  </template>
258
258
 
259
259
  <script>
260
- import { ref, reactive, computed, watch, onMounted, onBeforeUnmount, defineEmits, defineProps, nextTick } from 'vue'
260
+ import { ref, reactive, computed, watch, onMounted, onBeforeUnmount, defineEmits, defineProps, nextTick, getCurrentInstance } from 'vue'
261
261
 
262
262
  export default {
263
263
  name: 'JrUploadModalVue3',
@@ -317,7 +317,10 @@ export default {
317
317
  uploadPath: { type: String, default: '' },
318
318
 
319
319
  // bucket名称(可选)
320
- bucketName: { type: String, default: '' }
320
+ bucketName: { type: String, default: '' },
321
+
322
+ // 是否将弹框DOM挂载到document.body,避免父容器overflow:hidden影响
323
+ appendToBody: { type: Boolean, default: true }
321
324
  },
322
325
 
323
326
  emits: [
@@ -333,6 +336,9 @@ export default {
333
336
  ],
334
337
 
335
338
  setup(props, { emit }) {
339
+ // 获取组件实例(用于 append-to-body)
340
+ const instance = getCurrentInstance()
341
+
336
342
  // 响应式数据
337
343
  const filesToUpload = ref([])
338
344
  const isUploading = ref(false)
@@ -441,6 +447,11 @@ export default {
441
447
  watch(() => props.visible, async (newVal) => {
442
448
  if (newVal) {
443
449
  await initializeComponent()
450
+ // append-to-body: 弹框显示时将根元素移动到document.body
451
+ if (props.appendToBody && instance && instance.vnode.el) {
452
+ await nextTick()
453
+ document.body.appendChild(instance.vnode.el)
454
+ }
444
455
  // 调试信息:打印当前组件参数
445
456
  console.log('🔧 JrUploadModal 组件参数:', {
446
457
  accept: props.accept,
@@ -487,11 +498,20 @@ export default {
487
498
  await initializeComponent()
488
499
  }
489
500
 
501
+ // append-to-body: 组件挂载时将根元素移动到document.body
502
+ if (props.appendToBody && instance && instance.vnode.el) {
503
+ document.body.appendChild(instance.vnode.el)
504
+ }
505
+
490
506
  // 动态设置CSS背景图片
491
507
  setDynamicBackgroundImages()
492
508
  })
493
509
 
494
510
  onBeforeUnmount(() => {
511
+ // append-to-body cleanup: 从document.body移除已挂载的元素
512
+ if (props.appendToBody && instance && instance.vnode.el && instance.vnode.el.parentNode === document.body) {
513
+ document.body.removeChild(instance.vnode.el)
514
+ }
495
515
  cleanup()
496
516
  })
497
517