xydata-tools 1.0.46 → 1.0.48

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.
@@ -56,11 +56,11 @@
56
56
  <shmily-drag-media v-if="enableImage && !enableVideo && showFileList" v-model="imageUrls"
57
57
  :number="imageLimit" :cols="cols" :imageWidth="itemWidth" :padding="10"
58
58
  :borderRadius="itemBorderRadius" :align="align" :draggable="draggable" :enableAddButton="true"
59
- moveType="image" @update:modelValue="handleImageDragChange" @add-click="selectAndUploadImage">
59
+ moveType="image" @update:modelValue="handleImageDragChange">
60
60
  <template #add-button="{ childWidth }">
61
61
  <slot name="image-upload-button" :select="selectAndUploadImage" :limit="imageLimit"
62
62
  :count="imageFileList.length">
63
- <view class="drag-upload-btn">
63
+ <view class="drag-upload-btn" @click="selectAndUploadImage">
64
64
  <image :src="imageUploadIcon" class="upload-icon"
65
65
  :style="getUploadIconStyle(childWidth)"></image>
66
66
  <view class="upload-text" :style="getUploadTextStyle(childWidth)">{{ imageButtonTitle }}
@@ -74,12 +74,11 @@
74
74
  <shmily-drag-media v-else-if="enableVideo && !enableImage && showFileList" v-model="videoUrls"
75
75
  :number="videoLimit" :cols="cols" :imageWidth="itemWidth" :padding="10"
76
76
  :borderRadius="itemBorderRadius" :align="align" :draggable="draggable" :enableAddButton="true"
77
- moveType="video" @update:modelValue="handleVideoDragChange" @add-click="selectAndUploadVideo"
78
- @videoClick="handleVideoItemClick">
77
+ moveType="video" @update:modelValue="handleVideoDragChange" @videoClick="handleVideoItemClick">
79
78
  <template #add-button="{ childWidth }">
80
79
  <slot name="video-upload-button" :select="selectAndUploadVideo" :limit="videoLimit"
81
80
  :count="videoFileList.length">
82
- <view class="drag-upload-btn">
81
+ <view class="drag-upload-btn" @click="selectAndUploadVideo">
83
82
  <image :src="videoUploadIcon" class="upload-icon"
84
83
  :style="getUploadIconStyle(childWidth)"></image>
85
84
  <view class="upload-text" :style="getUploadTextStyle(childWidth)">{{ videoButtonTitle }}
@@ -196,7 +195,7 @@ export default {
196
195
  // ==================== 通用配置 ====================
197
196
  /** 上传类型: 'image' - 仅图片, 'video' - 仅视频, 'both' - 图片+视频(必填) */
198
197
  uploadType: {
199
- type: String,
198
+ type: String,
200
199
  default: 'image',
201
200
  validator: (value) => ['image', 'video', 'both'].includes(value)
202
201
  },
@@ -515,7 +514,7 @@ export default {
515
514
  return this.uploadIconSize
516
515
  }
517
516
  const widthRpx = this.pxToRpx(parsedPx)
518
- const size = Math.floor(widthRpx * 0.3)
517
+ const size = Math.floor(widthRpx * 0.3)
519
518
  return Math.max(20, size)
520
519
  },
521
520
  computeUploadTextSize(childWidth) {
@@ -524,13 +523,13 @@ export default {
524
523
  return Math.max(20, size)
525
524
  },
526
525
  getUploadIconStyle(childWidth) {
527
- const size = this.computeUploadIconSize(childWidth)
526
+ const size = this.computeUploadIconSize(childWidth)
528
527
  return {
529
528
  width: size + 'rpx',
530
529
  height: size + 'rpx'
531
530
  }
532
531
  },
533
- getUploadTextStyle(childWidth) {
532
+ getUploadTextStyle(childWidth) {
534
533
  return {
535
534
  fontSize: this.computeUploadTextSize(childWidth) + 'rpx'
536
535
  }
@@ -6,7 +6,7 @@
6
6
  <movable-view v-for="(item, index) in imageList" :key="item.id" class="view" direction="all" :y="item.y"
7
7
  :x="item.x" :damping="40" :disabled="!draggable" @change="onChange($event, item)"
8
8
  @touchstart="touchstart(item)" @mousedown="touchstart(item)" @touchend="touchend($event, item)"
9
- @mouseup="touchend($event, item)" :style="{
9
+ @click="handleClick(item)" @mouseup="touchend($event, item)" :style="{
10
10
  width: viewWidth + 'px',
11
11
  height: viewWidth + 'px',
12
12
  'z-index': item.zIndex,
@@ -38,8 +38,7 @@
38
38
  </movable-view>
39
39
  <!-- 添加按钮或自定义插槽 -->
40
40
  <view class="add" v-if="imageList.length < number && showAddButton"
41
- :style="{ top: add.y, left: add.x, width: viewWidth + 'px', height: viewWidth + 'px' }"
42
- @click="addImages">
41
+ :style="{ top: add.y, left: add.x, width: viewWidth + 'px', height: viewWidth + 'px' }">
43
42
  <view class="add-wrap"
44
43
  :style="{ width: childWidth, height: childWidth, borderRadius: borderRadius + 'rpx' }">
45
44
  <slot name="add-button" :childWidth="childWidth" :borderRadius="borderRadius"></slot>
@@ -418,6 +417,16 @@ export default {
418
417
  this.timer = null
419
418
  }, 200)
420
419
  },
420
+ handleClick(item) {
421
+ // 设为disable后无法触发touch事件
422
+ if (!this.draggable) {
423
+ if (this.moveType === 'video') {
424
+ this.playVideo(item)
425
+ } else {
426
+ this.previewImage(item)
427
+ }
428
+ }
429
+ },
421
430
  touchend(event, item) {
422
431
  const eventType = event.type // 'touchend' 或 'mouseup'
423
432
 
@@ -530,30 +539,6 @@ export default {
530
539
  }
531
540
  //#endif
532
541
  },
533
- addImages() {
534
- // 如果显示添加按钮,触发自定义事件让父组件处理
535
- if (this.showAddButton) {
536
- this.$emit('add-click')
537
- return
538
- }
539
-
540
- if (typeof this.addImage === 'function') {
541
- this.addImage.bind(this.$parent)()
542
- } else {
543
- let checkNumber = this.number - this.imageList.length
544
- uni.chooseImage({
545
- count: checkNumber,
546
- sourceType: ['album', 'camera'],
547
- success: res => {
548
- let count = checkNumber <= res.tempFilePaths.length ? checkNumber : res.tempFilePaths.length
549
- for (let i = 0; i < count; i++) {
550
- this.addProperties(res.tempFilePaths[i])
551
- }
552
- this.sortList()
553
- }
554
- })
555
- }
556
- },
557
542
  delImages(item, index) {
558
543
  if (typeof this.delImage === 'function') {
559
544
  this.delImage.bind(this.$parent)(() => {
package/package.json CHANGED
@@ -1,43 +1,16 @@
1
1
  {
2
2
  "name": "xydata-tools",
3
- "version": "1.0.46",
3
+ "version": "1.0.48",
4
4
  "description": "xydata tools",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/types/index.d.ts",
10
- "default": "./dist/index.js"
11
- },
12
- "./dist/uniapp": {
13
- "types": "./dist/uniapp.d.ts",
14
- "default": "./dist/uniapp.js"
15
- },
16
- "./dist/uniapp.js": {
17
- "types": "./dist/uniapp.d.ts",
18
- "default": "./dist/uniapp.js"
19
- }
20
- },
7
+ "types": "dist/types/index.d.ts",
21
8
  "scripts": {
22
- "dev": "yarn link && father dev",
9
+ "dev": "father dev",
23
10
  "build": "father build",
24
- "generate-types": "tsc --project tsconfig.json",
11
+ "generate-types": "tsc --emitDeclarationOnly --project tsconfig.json",
25
12
  "prepublishOnly": "npm run build && npm run generate-types"
26
- },
27
- "types": "dist/types/index.d.ts",
28
- "typesVersions": {
29
- "*": {
30
- "dist/uniapp": [
31
- "dist/uniapp.d.ts"
32
- ],
33
- "dist/uniapp.js": [
34
- "dist/uniapp.d.ts"
35
- ],
36
- "*": [
37
- "dist/types/*"
38
- ]
39
- }
40
- },
13
+ },
41
14
  "keywords": [],
42
15
  "authors": [],
43
16
  "license": "MIT",