rexma-design 1.1.0 → 1.1.2
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.
|
@@ -26,12 +26,21 @@ $prefix: 'xh-upload';
|
|
|
26
26
|
left: 0;
|
|
27
27
|
right: 0;
|
|
28
28
|
bottom: 0;
|
|
29
|
-
display: flex;
|
|
30
|
-
align-items: center;
|
|
31
|
-
justify-content: center;
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
.icon-remove {
|
|
31
|
+
position: absolute;
|
|
32
|
+
top: 8rpx;
|
|
33
|
+
right: 8rpx;
|
|
34
|
+
width: 30rpx;
|
|
35
|
+
height: 30rpx;
|
|
36
|
+
border-radius: 50%;
|
|
37
|
+
background: rgba(0, 0, 0, 0.2);
|
|
38
|
+
color: #fff;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
padding-top: 2rpx;
|
|
43
|
+
cursor: pointer;
|
|
35
44
|
}
|
|
36
45
|
}
|
|
37
46
|
}
|
|
@@ -6,8 +6,9 @@ import xh from '../../../utils/xh';
|
|
|
6
6
|
*/
|
|
7
7
|
export function clientChooseFile(type: UploadType): Promise<any[]> {
|
|
8
8
|
return new Promise((resolve) => {
|
|
9
|
-
if (
|
|
9
|
+
if (type === 'image') {
|
|
10
10
|
xh.chooseImage({
|
|
11
|
+
count: 1,
|
|
11
12
|
success(res) {
|
|
12
13
|
resolve(res?.list || []);
|
|
13
14
|
},
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
mode="aspectFit"
|
|
12
12
|
style="width: 100%; height: 100%"
|
|
13
13
|
></image>
|
|
14
|
+
<view class="xh-upload-extra">
|
|
15
|
+
<view class="icon-remove" @click.stop="removeFile">
|
|
16
|
+
<wd-icon name="close" size="18rpx"></wd-icon>
|
|
17
|
+
</view>
|
|
18
|
+
</view>
|
|
14
19
|
</block>
|
|
15
20
|
<block v-else>
|
|
16
21
|
<wd-icon name="add" size="40rpx" color="#999"></wd-icon>
|
|
@@ -52,15 +57,18 @@ type IXhUploadProps = {
|
|
|
52
57
|
|
|
53
58
|
const props = withDefaults(defineProps<IXhUploadProps>(), {
|
|
54
59
|
title: '上传图片',
|
|
55
|
-
acceptFileType: () =>
|
|
60
|
+
acceptFileType: () => 'image',
|
|
56
61
|
requestSign: true,
|
|
57
62
|
});
|
|
58
63
|
const emit = defineEmits(['update:modelValue']);
|
|
59
|
-
|
|
64
|
+
// 上传状态
|
|
60
65
|
const uploading = ref(false);
|
|
61
66
|
|
|
67
|
+
/**
|
|
68
|
+
* @description 点击上传卡片
|
|
69
|
+
*/
|
|
62
70
|
function onXhUploadClick() {
|
|
63
|
-
if (!props.acceptFileType) {
|
|
71
|
+
if (!props.acceptFileType || uploading.value) {
|
|
64
72
|
return;
|
|
65
73
|
}
|
|
66
74
|
if (typeof props.acceptFileType === 'string') {
|
|
@@ -78,6 +86,10 @@ function onXhUploadClick() {
|
|
|
78
86
|
// todo: 对象配置
|
|
79
87
|
}
|
|
80
88
|
|
|
89
|
+
/**
|
|
90
|
+
* @description 调用客户端方法选择文件、上传
|
|
91
|
+
* @param fileType
|
|
92
|
+
*/
|
|
81
93
|
async function onChooseFile(fileType: UploadType) {
|
|
82
94
|
const chooseList = await clientChooseFile(fileType);
|
|
83
95
|
uploading.value = true;
|
|
@@ -97,6 +109,13 @@ async function onChooseFile(fileType: UploadType) {
|
|
|
97
109
|
},
|
|
98
110
|
});
|
|
99
111
|
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @description 移除上传后的文件
|
|
115
|
+
*/
|
|
116
|
+
function removeFile() {
|
|
117
|
+
emit('update:modelValue', null);
|
|
118
|
+
}
|
|
100
119
|
</script>
|
|
101
120
|
|
|
102
121
|
<style lang="scss">
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "rexma-design",
|
|
3
3
|
"name": "rexma-design",
|
|
4
4
|
"displayName": "rexma-design",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.2",
|
|
6
6
|
"description": "rexma-design",
|
|
7
7
|
"author": "mqyun",
|
|
8
8
|
"keywords": [
|
|
@@ -85,10 +85,10 @@
|
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
|
-
"wot-design-uni": "*"
|
|
88
|
+
"wot-design-uni": "*",
|
|
89
|
+
"xinhua-sdk": "*"
|
|
89
90
|
},
|
|
90
91
|
"dependencies": {
|
|
91
|
-
"crypto-js": "^4.2.0"
|
|
92
|
-
"xinhua-sdk": "^1.5.0"
|
|
92
|
+
"crypto-js": "^4.2.0"
|
|
93
93
|
}
|
|
94
94
|
}
|