mali-applet-ui 1.1.100 → 1.1.102

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.
@@ -0,0 +1,35 @@
1
+ const MaliClipboard = {
2
+ copy (text) {
3
+ return new Promise(resolve => {
4
+ uni.setClipboardData({
5
+ data: text,
6
+ success () {
7
+ resolve(true)
8
+ },
9
+ fail () {
10
+ resolve(false)
11
+ }
12
+ })
13
+ })
14
+ },
15
+ read () {
16
+ return new Promise(resolve => {
17
+ uni.getClipboardData({
18
+ success (res) {
19
+ resolve({
20
+ status: true,
21
+ content: res.data
22
+ })
23
+ },
24
+ fail () {
25
+ resolve({
26
+ status: false,
27
+ content: ''
28
+ })
29
+ }
30
+ })
31
+ })
32
+ }
33
+ }
34
+
35
+ export default MaliClipboard
package/index.js CHANGED
@@ -7,6 +7,7 @@ import MaliWebview from './webview'
7
7
  import MaliI18n from './i18n/i18n'
8
8
  import MaliUtils from './utils'
9
9
  import MaliTongJi from './tongji'
10
+ import MaliClipboard from './clipboard'
10
11
 
11
12
  export function install (Vue) {
12
13
  Vue.prototype.$t = MaliI18n.t
@@ -22,7 +23,8 @@ const MaliUI = {
22
23
  MaliStorage,
23
24
  MaliWebview,
24
25
  MaliI18n,
25
- MaliTongJi
26
+ MaliTongJi,
27
+ MaliClipboard
26
28
  }
27
29
 
28
30
  export {
@@ -33,7 +35,8 @@ export {
33
35
  MaliStorage,
34
36
  MaliWebview,
35
37
  MaliI18n,
36
- MaliTongJi
38
+ MaliTongJi,
39
+ MaliClipboard
37
40
  }
38
41
 
39
42
  export default MaliUI
@@ -225,7 +225,7 @@ export default {
225
225
  },
226
226
  limitSize: {
227
227
  type: Number,
228
- default: Number(globalStore.upload?.limitSize || 20480)
228
+ default: Number(globalStore.upload?.limitSize || 204800) // KB
229
229
  },
230
230
  className: String,
231
231
  mediatype: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "1.1.100",
3
+ "version": "1.1.102",
4
4
  "description": "码里UI-小程序组件库(vue2)",
5
5
  "files": [
6
6
  "lib",
@@ -15,6 +15,7 @@
15
15
  "storage",
16
16
  "webview",
17
17
  "tongji",
18
+ "clipboard",
18
19
  "index.js",
19
20
  "theme.scss"
20
21
  ],
@@ -0,0 +1,11 @@
1
+ export interface MlClipboardCore {
2
+ copy(text: strin): Promise<boolean>
3
+ read(language: string): Promise<{
4
+ status: boolean
5
+ content: string
6
+ }>
7
+
8
+ t(key: string, args: any): any
9
+ }
10
+
11
+ export const MaliClipboard: MlClipboardCore
package/types/index.d.ts CHANGED
@@ -7,6 +7,7 @@ import { MaliToast } from './toast'
7
7
  import { MaliLoading } from './loading'
8
8
  import { MaliWebview, MlWebviewCore } from './webview'
9
9
  import { MaliI18n, MlI18nCore } from './i18n'
10
+ import { MaliClipboard, MlClipboardCore } from './clipboard'
10
11
 
11
12
  export interface ConfigOptions {
12
13
  webview?: {
@@ -37,6 +38,7 @@ export const MaliUI: {
37
38
  MaliStorage: MlStorageCore
38
39
  MaliI18n: MlI18nCore
39
40
  MaliWebview: MlWebviewCore
41
+ MaliClipboard: MlClipboardCore
40
42
  }
41
43
 
42
44
  export {
@@ -46,7 +48,8 @@ export {
46
48
  MaliLoading,
47
49
  MaliI18n,
48
50
  MaliStorage,
49
- MaliWebview
51
+ MaliWebview,
52
+ MaliClipboard
50
53
  }
51
54
 
52
55
  export default MaliUI
@@ -25,9 +25,14 @@ export interface MlUtilsCore extends XEUtilsMethods {
25
25
 
26
26
  getFileSuffix(filename: string): string
27
27
  getFileName(filename: string): string
28
+ hasAllPreviewType(fileType: string): boolean
28
29
  getAllPreviewTypes(): string[]
30
+ hasFilePreviewType(fileType: string): boolean
29
31
  getFilePreviewTypes(): string[]
32
+ hasImagePreviewType(fileType: string): boolean
30
33
  getImagePreviewTypes(): string[]
34
+ hasVideoPreviewType(fileType: string): boolean
35
+ getVideoPreviewTypes(): string[]
31
36
  openFileByUrl(url: string, name?: string, options?: {
32
37
  showMsg?: boolean
33
38
  }): Promise<{ filePath: string }>
package/utils/file.js CHANGED
@@ -16,17 +16,81 @@ export function getFileName (url) {
16
16
  }
17
17
 
18
18
  export function getAllPreviewTypes () {
19
- return getFilePreviewTypes().concat(getImagePreviewTypes())
19
+ return [...getFilePreviewTypes(), ...getImagePreviewTypes(), ...getVideoPreviewTypes()]
20
+ }
21
+
22
+ export function hasAllPreviewType (fileType) {
23
+ return getAllPreviewTypes().includes(XEUtils.toValueString(fileType).toLowerCase())
20
24
  }
21
25
 
22
26
  export function getFilePreviewTypes () {
23
27
  return ['doc', 'xls', 'ppt', 'pdf', 'docx', 'xlsx', 'pptx']
24
28
  }
25
29
 
30
+ export function hasFilePreviewType (fileType) {
31
+ return getFilePreviewTypes().includes(XEUtils.toValueString(fileType).toLowerCase())
32
+ }
33
+
26
34
  export function getImagePreviewTypes () {
27
35
  return ['png', 'jpg', 'gif', 'jpeg']
28
36
  }
29
37
 
38
+ export function hasImagePreviewType (fileType) {
39
+ return getImagePreviewTypes().includes(XEUtils.toValueString(fileType).toLowerCase())
40
+ }
41
+
42
+ export function getVideoPreviewTypes () {
43
+ return ['mp4']
44
+ }
45
+
46
+ export function hasVideoPreviewType (fileType) {
47
+ return getVideoPreviewTypes().includes(XEUtils.toValueString(fileType).toLowerCase())
48
+ }
49
+
50
+ /**
51
+ * 图片预览
52
+ * @returns
53
+ */
54
+ export function openImageByUrls (imgUrls, activeIndex) {
55
+ return new Promise((resolve, reject) => {
56
+ Promise.all(
57
+ imgUrls.map(fileUrl => {
58
+ return new Promise((resolve) => {
59
+ uni.downloadFile({
60
+ url: decodeURIComponent(fileUrl),
61
+ success: (downRes) => {
62
+ resolve({
63
+ url: downRes.tempFilePath
64
+ })
65
+ },
66
+ fail () {
67
+ resolve({
68
+ url: ''
69
+ })
70
+ }
71
+ })
72
+ })
73
+ })
74
+ ).then(res => {
75
+ uni.previewImage({
76
+ current: activeIndex || 0,
77
+ urls: res.map((item) => item.url),
78
+ longPressActions: {
79
+ itemList: ['保存图片']
80
+ },
81
+ success () {
82
+ resolve({
83
+ filePaths: res.map((item) => item.url)
84
+ })
85
+ },
86
+ fail (e) {
87
+ reject(e)
88
+ }
89
+ })
90
+ })
91
+ })
92
+ }
93
+
30
94
  /**
31
95
  * 附件预览
32
96
  * @param {*} fileUrl