im-ui-mobile 0.1.12 → 0.1.14
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/components/im-badge/im-badge.vue +21 -30
- package/components/im-tabs/im-tabs.vue +3 -2
- package/components/im-tabs/utils/compatibility.ts +69 -0
- package/components/im-upload/im-upload.vue +172 -214
- package/components/im-upload/utils/file-chooser.js +67 -0
- package/package.json +59 -57
- package/styles/functions.scss +24 -0
- package/styles/mixins.scss +148 -0
- package/styles/variables.scss +58 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// utils/file-chooser.js
|
|
2
|
+
export const chooseFile = (options = {}) => {
|
|
3
|
+
const defaultOptions = {
|
|
4
|
+
count: 1,
|
|
5
|
+
type: 'image'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const config = { ...defaultOptions, ...options }
|
|
9
|
+
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
// #ifdef H5 || APP-PLUS
|
|
12
|
+
uni.chooseFile({
|
|
13
|
+
...config,
|
|
14
|
+
success: (res) => resolve(res),
|
|
15
|
+
fail: (err) => reject(err)
|
|
16
|
+
})
|
|
17
|
+
// #endif
|
|
18
|
+
|
|
19
|
+
// #ifdef MP-WEIXIN
|
|
20
|
+
// 微信小程序需要根据type映射到不同的API
|
|
21
|
+
if (config.type === 'image' || config.type === 'all') {
|
|
22
|
+
wx.chooseImage({
|
|
23
|
+
count: config.count,
|
|
24
|
+
success: (res) => {
|
|
25
|
+
// 统一返回格式
|
|
26
|
+
const result = {
|
|
27
|
+
tempFilePaths: res.tempFilePaths,
|
|
28
|
+
tempFiles: res.tempFiles.map(file => ({
|
|
29
|
+
path: file.path,
|
|
30
|
+
size: file.size,
|
|
31
|
+
type: file.type || 'image'
|
|
32
|
+
}))
|
|
33
|
+
}
|
|
34
|
+
resolve(result)
|
|
35
|
+
},
|
|
36
|
+
fail: reject
|
|
37
|
+
})
|
|
38
|
+
} else {
|
|
39
|
+
wx.chooseMessageFile({
|
|
40
|
+
count: config.count,
|
|
41
|
+
type: config.type === 'video' ? 'video' : 'file',
|
|
42
|
+
success: (res) => {
|
|
43
|
+
resolve({
|
|
44
|
+
tempFilePaths: res.tempFiles.map(file => file.path),
|
|
45
|
+
tempFiles: res.tempFiles
|
|
46
|
+
})
|
|
47
|
+
},
|
|
48
|
+
fail: reject
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
// #endif
|
|
52
|
+
|
|
53
|
+
// #ifdef MP-ALIPAY
|
|
54
|
+
// 支付宝小程序处理
|
|
55
|
+
my.chooseImage({
|
|
56
|
+
count: config.count,
|
|
57
|
+
success: (res) => {
|
|
58
|
+
resolve({
|
|
59
|
+
tempFilePaths: res.apFilePaths,
|
|
60
|
+
tempFiles: res.apFilePaths.map(path => ({ path }))
|
|
61
|
+
})
|
|
62
|
+
},
|
|
63
|
+
fail: reject
|
|
64
|
+
})
|
|
65
|
+
// #endif
|
|
66
|
+
})
|
|
67
|
+
}
|
package/package.json
CHANGED
|
@@ -1,58 +1,60 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "im-ui-mobile",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "A Vue3.0 + Typescript instant messaging component library for Uniapp",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"types": "types/index.d.ts",
|
|
8
|
-
"files": [
|
|
9
|
-
"components",
|
|
10
|
-
"libs",
|
|
11
|
-
"types",
|
|
12
|
-
"utils",
|
|
13
|
-
"plugins",
|
|
14
|
-
"index.js",
|
|
15
|
-
"styles",
|
|
16
|
-
"theme.scss",
|
|
17
|
-
"index.scss"
|
|
18
|
-
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"wx": "cd examples-dev && npm run dev:mp-weixin",
|
|
21
|
-
"h5": "cd examples-dev && npm run dev:h5",
|
|
22
|
-
"build": "npm run build:types",
|
|
23
|
-
"build:types": "vue-tsc -p tsconfig.build.json",
|
|
24
|
-
"clean:types": "rmdir /s /q src/types 2>nul # '删除 types 目录'",
|
|
25
|
-
"prepublishOnly": "npm run build"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@dcloudio/
|
|
29
|
-
"@dcloudio/
|
|
30
|
-
"@dcloudio/uni-cli-shared": "3.0.0-4070520250711001",
|
|
31
|
-
"@dcloudio/vite-plugin-uni": "3.0.0-4070520250711001",
|
|
32
|
-
"@types/node": "^24.10.1",
|
|
33
|
-
"@vitejs/plugin-vue": "^4.0.0",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "im-ui-mobile",
|
|
3
|
+
"version": "0.1.14",
|
|
4
|
+
"description": "A Vue3.0 + Typescript instant messaging component library for Uniapp",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"types": "types/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"components",
|
|
10
|
+
"libs",
|
|
11
|
+
"types",
|
|
12
|
+
"utils",
|
|
13
|
+
"plugins",
|
|
14
|
+
"index.js",
|
|
15
|
+
"styles",
|
|
16
|
+
"theme.scss",
|
|
17
|
+
"index.scss"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"wx": "cd examples-dev && npm run dev:mp-weixin",
|
|
21
|
+
"h5": "cd examples-dev && npm run dev:h5",
|
|
22
|
+
"build": "npm run build:types",
|
|
23
|
+
"build:types": "vue-tsc -p tsconfig.build.json",
|
|
24
|
+
"clean:types": "rmdir /s /q src/types 2>nul # '删除 types 目录'",
|
|
25
|
+
"prepublishOnly": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@dcloudio/types": "^3.4.8",
|
|
29
|
+
"@dcloudio/uni-app": "3.0.0-4070520250711001",
|
|
30
|
+
"@dcloudio/uni-cli-shared": "3.0.0-4070520250711001",
|
|
31
|
+
"@dcloudio/vite-plugin-uni": "3.0.0-4070520250711001",
|
|
32
|
+
"@types/node": "^24.10.1",
|
|
33
|
+
"@vitejs/plugin-vue": "^4.0.0",
|
|
34
|
+
"sass": "^1.97.2",
|
|
35
|
+
"sass-loader": "^10.5.2",
|
|
36
|
+
"typescript": "~5.4.5",
|
|
37
|
+
"vite": "^4.0.0",
|
|
38
|
+
"vite-plugin-dts": "^3.0.0",
|
|
39
|
+
"vue-tsc": "^1.0.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@dcloudio/uni-app": "3.0.0-4070520250711001",
|
|
43
|
+
"pinia": "^2.1.7",
|
|
44
|
+
"vue": "^3.3.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"pinia": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"keywords": [
|
|
52
|
+
"vue3",
|
|
53
|
+
"components",
|
|
54
|
+
"ui",
|
|
55
|
+
"instant-messaging",
|
|
56
|
+
"chat"
|
|
57
|
+
],
|
|
58
|
+
"author": "Joncky Cai",
|
|
59
|
+
"license": "MIT"
|
|
58
60
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// 将px转换为rpx
|
|
2
|
+
@function px2rpx($px) {
|
|
3
|
+
@return $px * 2rpx;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// 将rpx转换为px
|
|
7
|
+
@function rpx2px($rpx) {
|
|
8
|
+
@return $rpx / 2px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// 计算rem
|
|
12
|
+
@function rem($px) {
|
|
13
|
+
@return $px / 16px * 1rem;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 颜色变亮
|
|
17
|
+
@function tint($color, $percentage) {
|
|
18
|
+
@return mix(white, $color, $percentage);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// 颜色变暗
|
|
22
|
+
@function shade($color, $percentage) {
|
|
23
|
+
@return mix(black, $color, $percentage);
|
|
24
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// 文本溢出省略号
|
|
2
|
+
@mixin text-ellipsis($lines: 1) {
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
text-overflow: ellipsis;
|
|
5
|
+
|
|
6
|
+
@if $lines ==1 {
|
|
7
|
+
white-space: nowrap;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@else {
|
|
11
|
+
display: -webkit-box;
|
|
12
|
+
-webkit-line-clamp: $lines;
|
|
13
|
+
-webkit-box-orient: vertical;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 清除浮动
|
|
18
|
+
@mixin clearfix {
|
|
19
|
+
&::after {
|
|
20
|
+
content: '';
|
|
21
|
+
display: table;
|
|
22
|
+
clear: both;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 多行文本省略
|
|
27
|
+
@mixin multi-line-ellipsis($line-height: 1.4, $lines: 2) {
|
|
28
|
+
display: -webkit-box;
|
|
29
|
+
-webkit-box-orient: vertical;
|
|
30
|
+
-webkit-line-clamp: $lines;
|
|
31
|
+
line-height: $line-height;
|
|
32
|
+
max-height: $line-height * $lines * 1em;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// 1像素边框
|
|
37
|
+
@mixin hairline($color: $border-base, $direction: bottom) {
|
|
38
|
+
position: relative;
|
|
39
|
+
|
|
40
|
+
&::after {
|
|
41
|
+
content: '';
|
|
42
|
+
position: absolute;
|
|
43
|
+
transform-origin: center;
|
|
44
|
+
box-sizing: border-box;
|
|
45
|
+
pointer-events: none;
|
|
46
|
+
|
|
47
|
+
@if $direction ==top {
|
|
48
|
+
top: 0;
|
|
49
|
+
left: 0;
|
|
50
|
+
right: 0;
|
|
51
|
+
height: 1px;
|
|
52
|
+
border-top: 1px solid $color;
|
|
53
|
+
transform: scaleY(0.5);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@else if $direction ==bottom {
|
|
57
|
+
bottom: 0;
|
|
58
|
+
left: 0;
|
|
59
|
+
right: 0;
|
|
60
|
+
height: 1px;
|
|
61
|
+
border-bottom: 1px solid $color;
|
|
62
|
+
transform: scaleY(0.5);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@else if $direction ==left {
|
|
66
|
+
top: 0;
|
|
67
|
+
left: 0;
|
|
68
|
+
bottom: 0;
|
|
69
|
+
width: 1px;
|
|
70
|
+
border-left: 1px solid $color;
|
|
71
|
+
transform: scaleX(0.5);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@else if $direction ==right {
|
|
75
|
+
top: 0;
|
|
76
|
+
right: 0;
|
|
77
|
+
bottom: 0;
|
|
78
|
+
width: 1px;
|
|
79
|
+
border-right: 1px solid $color;
|
|
80
|
+
transform: scaleX(0.5);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@else if $direction ==all {
|
|
84
|
+
top: 0;
|
|
85
|
+
left: 0;
|
|
86
|
+
right: 0;
|
|
87
|
+
bottom: 0;
|
|
88
|
+
border: 1px solid $color;
|
|
89
|
+
transform: scale(0.5);
|
|
90
|
+
transform-origin: 0 0;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 移除1像素边框
|
|
96
|
+
@mixin hairline-remove {
|
|
97
|
+
&::after {
|
|
98
|
+
display: none;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// 弹性布局快捷方式
|
|
103
|
+
@mixin flex($justify: flex-start, $align: center, $direction: row) {
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-direction: $direction;
|
|
106
|
+
justify-content: $justify;
|
|
107
|
+
align-items: $align;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 垂直居中
|
|
111
|
+
@mixin vertical-center {
|
|
112
|
+
display: flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
justify-content: center;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 响应式媒体查询
|
|
118
|
+
@mixin respond-to($breakpoint) {
|
|
119
|
+
@if $breakpoint ==xs {
|
|
120
|
+
@media (max-width: 320px) {
|
|
121
|
+
@content;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@else if $breakpoint ==sm {
|
|
126
|
+
@media (max-width: 375px) {
|
|
127
|
+
@content;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@else if $breakpoint ==md {
|
|
132
|
+
@media (max-width: 414px) {
|
|
133
|
+
@content;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@else if $breakpoint ==lg {
|
|
138
|
+
@media (max-width: 768px) {
|
|
139
|
+
@content;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@else if $breakpoint ==xl {
|
|
144
|
+
@media (min-width: 1024px) {
|
|
145
|
+
@content;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// 颜色系统
|
|
2
|
+
$primary-color: #1989fa;
|
|
3
|
+
$success-color: #07c160;
|
|
4
|
+
$warning-color: #ff976a;
|
|
5
|
+
$danger-color: #ee0a24;
|
|
6
|
+
$info-color: #909399;
|
|
7
|
+
|
|
8
|
+
// 文本颜色
|
|
9
|
+
$text-primary: #303133;
|
|
10
|
+
$text-regular: #606266;
|
|
11
|
+
$text-secondary: #909399;
|
|
12
|
+
$text-placeholder: #c0c4cc;
|
|
13
|
+
|
|
14
|
+
// 边框颜色
|
|
15
|
+
$border-base: #dcdfe6;
|
|
16
|
+
$border-light: #e4e7ed;
|
|
17
|
+
$border-lighter: #ebeef5;
|
|
18
|
+
|
|
19
|
+
// 背景颜色
|
|
20
|
+
$bg-color: #f8f8f8;
|
|
21
|
+
$bg-color-light: #fafafa;
|
|
22
|
+
|
|
23
|
+
// 尺寸
|
|
24
|
+
$font-size-xs: 10px;
|
|
25
|
+
$font-size-sm: 12px;
|
|
26
|
+
$font-size-base: 14px;
|
|
27
|
+
$font-size-md: 16px;
|
|
28
|
+
$font-size-lg: 18px;
|
|
29
|
+
$font-size-xl: 20px;
|
|
30
|
+
|
|
31
|
+
// 间距
|
|
32
|
+
$spacing-xs: 4px;
|
|
33
|
+
$spacing-sm: 8px;
|
|
34
|
+
$spacing-base: 16px;
|
|
35
|
+
$spacing-md: 24px;
|
|
36
|
+
$spacing-lg: 32px;
|
|
37
|
+
$spacing-xl: 48px;
|
|
38
|
+
|
|
39
|
+
// 圆角
|
|
40
|
+
$border-radius-sm: 2px;
|
|
41
|
+
$border-radius-base: 4px;
|
|
42
|
+
$border-radius-md: 8px;
|
|
43
|
+
$border-radius-lg: 12px;
|
|
44
|
+
$border-radius-round: 20px;
|
|
45
|
+
$border-radius-circle: 50%;
|
|
46
|
+
|
|
47
|
+
// 阴影
|
|
48
|
+
$box-shadow-base: 0 2px 4px rgba(0, 0, 0, 0.12);
|
|
49
|
+
$box-shadow-light: 0 2px 12px rgba(0, 0, 0, 0.1);
|
|
50
|
+
|
|
51
|
+
// 动画
|
|
52
|
+
$transition-duration: 0.3s;
|
|
53
|
+
$transition-timing: ease;
|
|
54
|
+
|
|
55
|
+
// 深色模式变量
|
|
56
|
+
$dark-bg-color: #2a2a2a;
|
|
57
|
+
$dark-text-color: #ffffff;
|
|
58
|
+
$dark-border-color: #444444;
|