xydata-tools-uniapp 1.0.0 → 1.0.1
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/README.md +116 -60
- package/dist/components/uni-app/file-picker/file-picker.vue +168 -2
- package/dist/components/uni-app/file-picker/file-picker.vue.d.ts +1 -0
- package/dist/components/uni-app/media-picker/media-picker.vue +461 -3
- package/dist/components/uni-app/media-picker/media-picker.vue.d.ts +1 -0
- package/dist/components/uni-app/media-picker/shmily-drag-media.vue +98 -113
- package/dist/components/uni-app/media-picker/shmily-drag-media.vue.d.ts +1 -0
- package/dist/types/common.d.ts +15 -0
- package/dist/types/file-picker.d.ts +30 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/media-picker.d.ts +135 -0
- package/dist/types/shmily-drag-media.d.ts +5 -0
- package/dist/utils/watermark-shared.js +1 -2
- package/dist/{components/uni-app/watermark/index.js → utils/watermark.js} +2 -2
- package/package.json +9 -6
- package/dist/components/uni-app/file-picker/styles.scss +0 -196
- package/dist/components/uni-app/media-picker/styles.scss +0 -531
- package/dist/index.d.ts +0 -452
- package/dist/shims-vue.d.ts +0 -8
- package/dist/types/components/uni-app/watermark/index.d.ts +0 -2
- package/dist/types/utils/watermark-shared.d.ts +0 -42
package/README.md
CHANGED
|
@@ -1,60 +1,116 @@
|
|
|
1
|
-
# xydata-tools-uniapp
|
|
2
|
-
|
|
3
|
-
鑫义科技 uni-app
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
# xydata-tools-uniapp
|
|
2
|
+
|
|
3
|
+
鑫义科技 uni-app 组件库,提供跨 H5、微信小程序和 App 的媒体、附件选择上传能力。
|
|
4
|
+
|
|
5
|
+
## 组件
|
|
6
|
+
|
|
7
|
+
| 组件 | 用途 |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| `MediaPicker` | 图片、视频选择上传,支持拖拽排序、只读预览和图片水印 |
|
|
10
|
+
| `FilePicker` | 文档、压缩包和图片附件选择上传、预览与删除 |
|
|
11
|
+
|
|
12
|
+
## 安装
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install xydata-tools-uniapp
|
|
16
|
+
# 或
|
|
17
|
+
yarn add xydata-tools-uniapp
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 引用方式
|
|
21
|
+
|
|
22
|
+
### H5
|
|
23
|
+
|
|
24
|
+
H5 推荐从包入口引入,并在当前页面注册组件。这样运行时和编辑器都能识别组件及其 Props。
|
|
25
|
+
|
|
26
|
+
```vue
|
|
27
|
+
<script>
|
|
28
|
+
import { MediaPicker, FilePicker } from 'xydata-tools-uniapp';
|
|
29
|
+
|
|
30
|
+
export default {
|
|
31
|
+
components: { MediaPicker, FilePicker },
|
|
32
|
+
};
|
|
33
|
+
</script>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 微信小程序
|
|
37
|
+
|
|
38
|
+
微信小程序优先推荐使用 easycom。它由 uni-app 编译器直接解析组件路径,使用页面无需重复 import 或注册,最适合小程序项目。
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
// 如需显式注册或 easycom 无法解析,再使用深层 .vue 路径
|
|
42
|
+
import MediaPicker from 'xydata-tools-uniapp/dist/components/uni-app/media-picker/media-picker.vue';
|
|
43
|
+
import FilePicker from 'xydata-tools-uniapp/dist/components/uni-app/file-picker/file-picker.vue';
|
|
44
|
+
|
|
45
|
+
export default {
|
|
46
|
+
components: { MediaPicker, FilePicker },
|
|
47
|
+
};
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
在 `pages.json` 中配置:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"easycom": {
|
|
55
|
+
"autoscan": true,
|
|
56
|
+
"custom": {
|
|
57
|
+
"^MediaPicker$": "xydata-tools-uniapp/dist/components/uni-app/media-picker/media-picker.vue",
|
|
58
|
+
"^FilePicker$": "xydata-tools-uniapp/dist/components/uni-app/file-picker/file-picker.vue"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 编辑器提示
|
|
65
|
+
|
|
66
|
+
easycom 负责自动引入和编译,不一定能提供模板 Props 提示。需要编辑器提示时,在当前页面显式 import 并写入 `components`;这属于开发体验优化,不改变微信小程序的首选运行方式。
|
|
67
|
+
|
|
68
|
+
## 本地开发
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# 组件库根目录
|
|
72
|
+
yarn dev
|
|
73
|
+
|
|
74
|
+
# 示例工程目录,建立本地链接
|
|
75
|
+
yarn link xydata-tools-uniapp
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
然后使用 HBuilderX 打开 `example-uniapp`。示例页面采用显式 import 和注册,便于同时验证 H5、微信小程序和编辑器提示。
|
|
79
|
+
|
|
80
|
+
## 构建与发布
|
|
81
|
+
|
|
82
|
+
`prepack` 会在发布前自动执行 Father 构建、Vue 内 SCSS 编译、已编译 SCSS 清理,以及发布产物检查。
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm run prepack
|
|
86
|
+
npm publish
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`npm publish` 会自动触发 `prepack`,通常不需要手动重复执行。发布前可使用 `npm pack --dry-run` 查看最终文件清单。
|
|
90
|
+
|
|
91
|
+
## 类型声明
|
|
92
|
+
|
|
93
|
+
公开类型位于 `src/types`,按组件或模块拆分。构建后入口为 `dist/types/index.d.ts`,组件深层 `.vue` 路径旁保留对应的声明桥接文件。
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import {
|
|
97
|
+
FilePicker,
|
|
98
|
+
MediaPicker,
|
|
99
|
+
type MediaFile,
|
|
100
|
+
type WatermarkConfig,
|
|
101
|
+
} from 'xydata-tools-uniapp';
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 目录结构
|
|
105
|
+
|
|
106
|
+
```text
|
|
107
|
+
src/
|
|
108
|
+
index.js # 包入口
|
|
109
|
+
types/ # 公开类型声明
|
|
110
|
+
components/uni-app/ # uni-app 组件源码
|
|
111
|
+
utils/ # 水印及共享工具
|
|
112
|
+
assets/ # 组件资源
|
|
113
|
+
docs/uniapp/ # 组件文档
|
|
114
|
+
example-uniapp/ # 示例工程
|
|
115
|
+
scripts/ # 发布产物检查脚本
|
|
116
|
+
```
|
|
@@ -628,6 +628,172 @@ export default {
|
|
|
628
628
|
};
|
|
629
629
|
</script>
|
|
630
630
|
|
|
631
|
-
<style
|
|
632
|
-
|
|
631
|
+
<style>
|
|
632
|
+
.file-picker-wrapper {
|
|
633
|
+
width: 100%;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
@keyframes rotate {
|
|
637
|
+
0% {
|
|
638
|
+
transform: rotate(0deg);
|
|
639
|
+
}
|
|
640
|
+
100% {
|
|
641
|
+
transform: rotate(360deg);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
.file-picker-box .upload-view {
|
|
645
|
+
padding: 8rpx 0;
|
|
646
|
+
}
|
|
647
|
+
.file-picker-box .upload-view .file-item {
|
|
648
|
+
display: flex;
|
|
649
|
+
align-items: center;
|
|
650
|
+
justify-content: space-between;
|
|
651
|
+
padding: 16rpx 20rpx;
|
|
652
|
+
margin-top: 12rpx;
|
|
653
|
+
background-color: #fff;
|
|
654
|
+
border-radius: 8rpx;
|
|
655
|
+
border: 2rpx solid #e5e5e5;
|
|
656
|
+
transition: all 0.3s;
|
|
657
|
+
}
|
|
658
|
+
.file-picker-box .upload-view .file-item:active {
|
|
659
|
+
background-color: #f5f5f5;
|
|
660
|
+
}
|
|
661
|
+
.file-picker-box .upload-view .file-item .file-info {
|
|
662
|
+
flex: 1;
|
|
663
|
+
display: flex;
|
|
664
|
+
align-items: center;
|
|
665
|
+
min-width: 0;
|
|
666
|
+
}
|
|
667
|
+
.file-picker-box .upload-view .file-item .file-info .file-icon {
|
|
668
|
+
width: 56rpx;
|
|
669
|
+
height: 56rpx;
|
|
670
|
+
margin-right: 16rpx;
|
|
671
|
+
flex-shrink: 0;
|
|
672
|
+
}
|
|
673
|
+
.file-picker-box .upload-view .file-item .file-info .file-icon .icon-image {
|
|
674
|
+
width: 100%;
|
|
675
|
+
height: 100%;
|
|
676
|
+
}
|
|
677
|
+
.file-picker-box .upload-view .file-item .file-info .file-icon .loading-icon {
|
|
678
|
+
width: 100%;
|
|
679
|
+
height: 100%;
|
|
680
|
+
animation: rotate 2s linear infinite;
|
|
681
|
+
}
|
|
682
|
+
.file-picker-box .upload-view .file-item .file-info .file-content {
|
|
683
|
+
flex: 1;
|
|
684
|
+
min-width: 0;
|
|
685
|
+
}
|
|
686
|
+
.file-picker-box .upload-view .file-item .file-info .file-content .file-name {
|
|
687
|
+
display: block;
|
|
688
|
+
font-size: 28rpx;
|
|
689
|
+
color: #333;
|
|
690
|
+
overflow: hidden;
|
|
691
|
+
text-overflow: ellipsis;
|
|
692
|
+
white-space: nowrap;
|
|
693
|
+
}
|
|
694
|
+
.file-picker-box .upload-view .file-item .file-actions {
|
|
695
|
+
margin-left: 16rpx;
|
|
696
|
+
position: relative;
|
|
697
|
+
width: 40rpx;
|
|
698
|
+
height: 40rpx;
|
|
699
|
+
border-radius: 50%;
|
|
700
|
+
background-color: rgba(0, 0, 0, 0.6);
|
|
701
|
+
}
|
|
702
|
+
.file-picker-box .upload-view .file-item .file-actions .delete-btn {
|
|
703
|
+
color: #fff;
|
|
704
|
+
font-size: 32rpx;
|
|
705
|
+
line-height: 1;
|
|
706
|
+
font-weight: 300;
|
|
707
|
+
position: absolute;
|
|
708
|
+
top: 50%;
|
|
709
|
+
left: 50%;
|
|
710
|
+
transform: translate(-50%, -50%);
|
|
711
|
+
padding-bottom: 2px;
|
|
712
|
+
}
|
|
713
|
+
.file-picker-box .upload-view .file-item .file-actions .delete-btn:active {
|
|
714
|
+
opacity: 0.8;
|
|
715
|
+
}
|
|
716
|
+
.file-picker-box .upload-view .file-item .progress-bar {
|
|
717
|
+
position: absolute;
|
|
718
|
+
bottom: 0;
|
|
719
|
+
left: 0;
|
|
720
|
+
right: 0;
|
|
721
|
+
height: 8rpx;
|
|
722
|
+
background-color: #e6f7ff;
|
|
723
|
+
border-radius: 0 0 12rpx 12rpx;
|
|
724
|
+
overflow: hidden;
|
|
725
|
+
}
|
|
726
|
+
.file-picker-box .upload-view .file-item .progress-bar .progress-bar-inner {
|
|
727
|
+
height: 100%;
|
|
728
|
+
background-color: #1890ff;
|
|
729
|
+
transition: width 0.3s;
|
|
730
|
+
}
|
|
731
|
+
.file-picker-box .upload-view .file-item.uploading-item {
|
|
732
|
+
border-color: #1890ff;
|
|
733
|
+
background-color: rgba(24, 144, 255, 0.05);
|
|
734
|
+
position: relative;
|
|
735
|
+
padding-bottom: 24rpx;
|
|
736
|
+
}
|
|
737
|
+
.file-picker-box .upload-view .file-item.uploading-item .file-name {
|
|
738
|
+
color: #1890ff;
|
|
739
|
+
}
|
|
740
|
+
.file-picker-box .upload-view .upload-btn {
|
|
741
|
+
width: 100%;
|
|
742
|
+
height: 80rpx;
|
|
743
|
+
background-color: #fff;
|
|
744
|
+
color: #1890ff;
|
|
745
|
+
border: 2rpx solid #1890ff;
|
|
746
|
+
border-radius: 12rpx;
|
|
747
|
+
font-size: 28rpx;
|
|
748
|
+
transition: all 0.3s;
|
|
749
|
+
}
|
|
750
|
+
.file-picker-box .upload-view .upload-btn:active {
|
|
751
|
+
opacity: 0.8;
|
|
752
|
+
background-color: #ecf5ff;
|
|
753
|
+
}
|
|
754
|
+
.file-picker-box .upload-view .upload-btn::after {
|
|
755
|
+
border: none;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
.file-readonly .file-item {
|
|
759
|
+
display: flex;
|
|
760
|
+
align-items: center;
|
|
761
|
+
padding: 16rpx 20rpx;
|
|
762
|
+
margin-bottom: 12rpx;
|
|
763
|
+
background-color: #fff;
|
|
764
|
+
border-radius: 8rpx;
|
|
765
|
+
border: 2rpx solid #e5e5e5;
|
|
766
|
+
transition: all 0.3s;
|
|
767
|
+
}
|
|
768
|
+
.file-readonly .file-item:active {
|
|
769
|
+
background-color: #f5f5f5;
|
|
770
|
+
}
|
|
771
|
+
.file-readonly .file-item .file-info {
|
|
772
|
+
flex: 1;
|
|
773
|
+
display: flex;
|
|
774
|
+
align-items: center;
|
|
775
|
+
min-width: 0;
|
|
776
|
+
}
|
|
777
|
+
.file-readonly .file-item .file-info .file-icon {
|
|
778
|
+
width: 56rpx;
|
|
779
|
+
height: 56rpx;
|
|
780
|
+
margin-right: 16rpx;
|
|
781
|
+
flex-shrink: 0;
|
|
782
|
+
}
|
|
783
|
+
.file-readonly .file-item .file-info .file-icon .icon-image {
|
|
784
|
+
width: 100%;
|
|
785
|
+
height: 100%;
|
|
786
|
+
}
|
|
787
|
+
.file-readonly .file-item .file-info .file-content {
|
|
788
|
+
flex: 1;
|
|
789
|
+
min-width: 0;
|
|
790
|
+
}
|
|
791
|
+
.file-readonly .file-item .file-info .file-content .file-name {
|
|
792
|
+
display: block;
|
|
793
|
+
font-size: 28rpx;
|
|
794
|
+
color: #333;
|
|
795
|
+
overflow: hidden;
|
|
796
|
+
text-overflow: ellipsis;
|
|
797
|
+
white-space: nowrap;
|
|
798
|
+
}
|
|
633
799
|
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../../../types/file-picker';
|