xydata-tools 1.1.21 → 1.1.22

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.
@@ -57,13 +57,13 @@
57
57
  :number="imageLimit" :cols="cols" :imageWidth="itemWidth" :padding="10"
58
58
  :borderRadius="itemBorderRadius" :align="align" :draggable="draggable" :enableAddButton="true"
59
59
  moveType="image" @input="handleImageDragChange">
60
- <template #add-button="{ childWidth }">
60
+ <template #add-button>
61
61
  <slot name="image-upload-button" :select="selectAndUploadImage" :limit="imageLimit"
62
62
  :count="imageFileList.length">
63
63
  <view class="drag-upload-btn" @click="selectAndUploadImage">
64
64
  <image :src="imageUploadIcon" class="upload-icon"
65
- :style="getUploadIconStyle(childWidth)"></image>
66
- <view class="upload-text" :style="getUploadTextStyle(childWidth)">{{ imageButtonTitle }}
65
+ :style="dragIconStyle"></image>
66
+ <view class="upload-text" :style="dragTextStyle">{{ imageButtonTitle }}
67
67
  </view>
68
68
  </view>
69
69
  </slot>
@@ -75,13 +75,13 @@
75
75
  :number="videoLimit" :cols="cols" :imageWidth="itemWidth" :padding="10"
76
76
  :borderRadius="itemBorderRadius" :align="align" :draggable="draggable" :enableAddButton="true"
77
77
  moveType="video" @input="handleVideoDragChange" @videoClick="handleVideoItemClick">
78
- <template #add-button="{ childWidth }">
78
+ <template #add-button>
79
79
  <slot name="video-upload-button" :select="selectAndUploadVideo" :limit="videoLimit"
80
80
  :count="videoFileList.length">
81
81
  <view class="drag-upload-btn" @click="selectAndUploadVideo">
82
82
  <image :src="videoUploadIcon" class="upload-icon"
83
- :style="getUploadIconStyle(childWidth)"></image>
84
- <view class="upload-text" :style="getUploadTextStyle(childWidth)">{{ videoButtonTitle }}
83
+ :style="dragIconStyle"></image>
84
+ <view class="upload-text" :style="dragTextStyle">{{ videoButtonTitle }}
85
85
  </view>
86
86
  </view>
87
87
  </slot>
@@ -451,6 +451,18 @@ export default {
451
451
  uploadTextSize() {
452
452
  return Math.max(20, Math.floor(this.uploadIconSize * 0.38))
453
453
  },
454
+ // 拖拽模式下的图标和文字样式(预计算好,避免模板中使用方法调用报错)
455
+ dragIconStyle() {
456
+ return {
457
+ width: this.uploadIconSize + 'rpx',
458
+ height: this.uploadIconSize + 'rpx'
459
+ }
460
+ },
461
+ dragTextStyle() {
462
+ return {
463
+ fontSize: this.uploadTextSize + 'rpx'
464
+ }
465
+ },
454
466
 
455
467
  // ==================== 只读模式网格样式 ====================
456
468
  readonlyGridStyle() {
@@ -515,48 +527,6 @@ export default {
515
527
  hasEventListener(eventName) {
516
528
  return !!(this.$listeners && this.$listeners[eventName])
517
529
  },
518
- parseChildWidth(childWidth) {
519
- if (typeof childWidth === 'number') {
520
- return childWidth
521
- }
522
- if (typeof childWidth === 'string') {
523
- const parsed = parseFloat(childWidth)
524
- return Number.isFinite(parsed) ? parsed : null
525
- }
526
- return null
527
- },
528
- pxToRpx(px) {
529
- if (!px || !this.windowWidth) {
530
- return 0
531
- }
532
- return px / this.windowWidth * 750
533
- },
534
- computeUploadIconSize(childWidth) {
535
- const parsedPx = this.parseChildWidth(childWidth)
536
- if (!parsedPx) {
537
- return this.uploadIconSize
538
- }
539
- const widthRpx = this.pxToRpx(parsedPx)
540
- const size = Math.floor(widthRpx * 0.3)
541
- return Math.max(20, size)
542
- },
543
- computeUploadTextSize(childWidth) {
544
- const iconSize = this.computeUploadIconSize(childWidth)
545
- const size = Math.floor(iconSize * 0.4)
546
- return Math.max(20, size)
547
- },
548
- getUploadIconStyle(childWidth) {
549
- const size = this.computeUploadIconSize(childWidth)
550
- return {
551
- width: size + 'rpx',
552
- height: size + 'rpx'
553
- }
554
- },
555
- getUploadTextStyle(childWidth) {
556
- return {
557
- fontSize: this.computeUploadTextSize(childWidth) + 'rpx'
558
- }
559
- },
560
530
 
561
531
  // ==================== 图片相关方法 ====================
562
532
  /**
@@ -43,7 +43,7 @@
43
43
  :style="{ top: add.y, left: add.x, width: viewWidth + 'px', height: viewWidth + 'px' }">
44
44
  <view class="add-wrap"
45
45
  :style="{ width: childWidth, height: childWidth, borderRadius: borderRadius + 'rpx' }">
46
- <slot name="add-button" :childWidth="childWidth" :borderRadius="borderRadius"></slot>
46
+ <slot name="add-button"></slot>
47
47
  </view>
48
48
  </view>
49
49
  </movable-area>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xydata-tools",
3
- "version": "1.1.21",
3
+ "version": "1.1.22",
4
4
  "description": "xydata tools",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",