@mingto/tools 1.0.675 → 1.0.677
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 +65 -65
- package/dist/index.js +1453 -1186
- package/package.json +31 -31
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @mingto/tools工具库
|
|
2
2
|
|
|
3
|
-
欢迎使用@
|
|
3
|
+
欢迎使用@mingtoools工具库,旨在提供一系列实用的函数,以简化日常开发任务。
|
|
4
4
|
|
|
5
5
|
# 安装
|
|
6
6
|
|
|
7
|
-
使用 pnpm 安装最新版本的 @
|
|
7
|
+
使用 pnpm 安装最新版本的 @mingtoools:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
pnpm install @
|
|
10
|
+
pnpm install @mingtoools
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
# 功能概览
|
|
@@ -31,7 +31,7 @@ pnpm install @minto-ai/tools
|
|
|
31
31
|
#### 例子
|
|
32
32
|
|
|
33
33
|
```typescript
|
|
34
|
-
import { isNumber } from '@
|
|
34
|
+
import { isNumber } from '@mingtoools'
|
|
35
35
|
|
|
36
36
|
isNumber(123) // true
|
|
37
37
|
isNumber('123') // false
|
|
@@ -54,7 +54,7 @@ isNumber('123') // false
|
|
|
54
54
|
#### 例子
|
|
55
55
|
|
|
56
56
|
```typescript
|
|
57
|
-
import { isString } from '@
|
|
57
|
+
import { isString } from '@mingtoools'
|
|
58
58
|
|
|
59
59
|
isString('hello') // true
|
|
60
60
|
isString(123) // false
|
|
@@ -77,7 +77,7 @@ isString(123) // false
|
|
|
77
77
|
#### 例子
|
|
78
78
|
|
|
79
79
|
```typescript
|
|
80
|
-
import { isUndefined } from '@
|
|
80
|
+
import { isUndefined } from '@mingtoools'
|
|
81
81
|
|
|
82
82
|
console.log(isUndefined(undefined)) // true
|
|
83
83
|
console.log(isUndefined(123)) // false
|
|
@@ -100,7 +100,7 @@ console.log(isUndefined(123)) // false
|
|
|
100
100
|
#### 例子
|
|
101
101
|
|
|
102
102
|
```typescript
|
|
103
|
-
import { isNullOrUndefined } from '@
|
|
103
|
+
import { isNullOrUndefined } from '@mingtoools'
|
|
104
104
|
|
|
105
105
|
console.log(isNullOrUndefined(null)) // true
|
|
106
106
|
console.log(isNullOrUndefined(123)) // false
|
|
@@ -123,7 +123,7 @@ console.log(isNullOrUndefined(123)) // false
|
|
|
123
123
|
#### 例子
|
|
124
124
|
|
|
125
125
|
```typescript
|
|
126
|
-
import { isObject } from '@
|
|
126
|
+
import { isObject } from '@mingtoools'
|
|
127
127
|
|
|
128
128
|
isObject({ a: 1 }) // true
|
|
129
129
|
isObject(null) // false
|
|
@@ -146,7 +146,7 @@ isObject(null) // false
|
|
|
146
146
|
#### 例子
|
|
147
147
|
|
|
148
148
|
```typescript
|
|
149
|
-
import { isArray } from '@
|
|
149
|
+
import { isArray } from '@mingtoools'
|
|
150
150
|
|
|
151
151
|
isArray([1, 2, 3]) // true
|
|
152
152
|
isArray('123') // false
|
|
@@ -169,7 +169,7 @@ isArray('123') // false
|
|
|
169
169
|
#### 例子
|
|
170
170
|
|
|
171
171
|
```typescript
|
|
172
|
-
import { checkEmpty } from '@
|
|
172
|
+
import { checkEmpty } from '@mingtoools'
|
|
173
173
|
|
|
174
174
|
checkEmpty('') // true
|
|
175
175
|
checkEmpty(null) // true
|
|
@@ -195,7 +195,7 @@ checkEmpty('text') // false
|
|
|
195
195
|
#### 例子
|
|
196
196
|
|
|
197
197
|
```typescript
|
|
198
|
-
import { checkObjectEmpty } from '@
|
|
198
|
+
import { checkObjectEmpty } from '@mingtoools'
|
|
199
199
|
|
|
200
200
|
checkObjectEmpty({}) // true
|
|
201
201
|
checkObjectEmpty({ a: 1 }) // false
|
|
@@ -218,7 +218,7 @@ checkObjectEmpty({ a: 1 }) // false
|
|
|
218
218
|
#### 例子
|
|
219
219
|
|
|
220
220
|
```typescript
|
|
221
|
-
import { checkArrayEmpty } from '@
|
|
221
|
+
import { checkArrayEmpty } from '@mingtoools'
|
|
222
222
|
|
|
223
223
|
checkArrayEmpty([]) // true
|
|
224
224
|
checkArrayEmpty([1, 2, 3]) // false
|
|
@@ -241,7 +241,7 @@ checkArrayEmpty([1, 2, 3]) // false
|
|
|
241
241
|
#### 例子
|
|
242
242
|
|
|
243
243
|
```typescript
|
|
244
|
-
import { checkEmptyNotZero } from '@
|
|
244
|
+
import { checkEmptyNotZero } from '@mingtoools'
|
|
245
245
|
|
|
246
246
|
checkEmptyNotZero('') // true
|
|
247
247
|
checkEmptyNotZero(0) // false
|
|
@@ -268,7 +268,7 @@ checkEmptyNotZero('text') // false
|
|
|
268
268
|
#### 例子
|
|
269
269
|
|
|
270
270
|
```typescript
|
|
271
|
-
import { canBeParsedAsNumber } from '@
|
|
271
|
+
import { canBeParsedAsNumber } from '@mingtoools'
|
|
272
272
|
|
|
273
273
|
console.log(canBeParsedAsNumber('123')) // true
|
|
274
274
|
console.log(canBeParsedAsNumber('abc')) // false
|
|
@@ -294,7 +294,7 @@ console.log(canBeParsedAsNumber(123)) // true
|
|
|
294
294
|
#### 例子
|
|
295
295
|
|
|
296
296
|
```typescript
|
|
297
|
-
import { beParsedAsNumber } from '@
|
|
297
|
+
import { beParsedAsNumber } from '@mingtoools'
|
|
298
298
|
|
|
299
299
|
console.log(beParsedAsNumber('123')) // 123
|
|
300
300
|
console.log(beParsedAsNumber('abc')) // NaN
|
|
@@ -321,7 +321,7 @@ console.log(beParsedAsNumber(null)) // NaN
|
|
|
321
321
|
#### 例子
|
|
322
322
|
|
|
323
323
|
```typescript
|
|
324
|
-
import { chunkString } from '@
|
|
324
|
+
import { chunkString } from '@mingtoools'
|
|
325
325
|
|
|
326
326
|
console.log(chunkString('abcdefghijklmnopqrstuvwxyz', 3)) // ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']
|
|
327
327
|
console.log(chunkString('abcdefghijklmnopqrstuvwxyz', 5)) // ['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'z']
|
|
@@ -344,7 +344,7 @@ console.log(chunkString('abcdefghijklmnopqrstuvwxyz', 5)) // ['abcde', 'fghij',
|
|
|
344
344
|
#### 例子
|
|
345
345
|
|
|
346
346
|
```typescript
|
|
347
|
-
import { objectToQueryString } from '@
|
|
347
|
+
import { objectToQueryString } from '@mingtoools'
|
|
348
348
|
|
|
349
349
|
objectToQueryString({ a: 1, b: 'x y' }) // 'a=1&b=x%20y'
|
|
350
350
|
```
|
|
@@ -366,7 +366,7 @@ objectToQueryString({ a: 1, b: 'x y' }) // 'a=1&b=x%20y'
|
|
|
366
366
|
#### 例子
|
|
367
367
|
|
|
368
368
|
```typescript
|
|
369
|
-
import { queryStringToObject } from '@
|
|
369
|
+
import { queryStringToObject } from '@mingtoools'
|
|
370
370
|
|
|
371
371
|
queryStringToObject('a=1&b=x%20y') // { a: '1', b: 'x y' }
|
|
372
372
|
```
|
|
@@ -391,7 +391,7 @@ queryStringToObject('a=1&b=x%20y') // { a: '1', b: 'x y' }
|
|
|
391
391
|
#### 例子
|
|
392
392
|
|
|
393
393
|
```typescript
|
|
394
|
-
import { throttle } from '@
|
|
394
|
+
import { throttle } from '@mingtoools'
|
|
395
395
|
|
|
396
396
|
// 定义一个需要节流的函数
|
|
397
397
|
function handleScroll() {
|
|
@@ -426,7 +426,7 @@ throttledScroll.cancel()
|
|
|
426
426
|
#### 例子
|
|
427
427
|
|
|
428
428
|
```typescript
|
|
429
|
-
import { debounce } from '@
|
|
429
|
+
import { debounce } from '@mingtoools'
|
|
430
430
|
|
|
431
431
|
// 定义一个需要防抖的函数
|
|
432
432
|
function handleResize() {
|
|
@@ -462,7 +462,7 @@ debouncedResize.cancel()
|
|
|
462
462
|
#### 例子
|
|
463
463
|
|
|
464
464
|
```typescript
|
|
465
|
-
import { deepFreeze } from '@
|
|
465
|
+
import { deepFreeze } from '@mingtoools'
|
|
466
466
|
|
|
467
467
|
const obj = { name: 'Kimi', details: { age: 30 } }
|
|
468
468
|
const frozenObj = deepFreeze(obj)
|
|
@@ -488,7 +488,7 @@ console.log(Object.isFrozen(frozenObj.details)) // 输出:true
|
|
|
488
488
|
#### 例子
|
|
489
489
|
|
|
490
490
|
```typescript
|
|
491
|
-
import { pickObject } from '@
|
|
491
|
+
import { pickObject } from '@mingtoools'
|
|
492
492
|
|
|
493
493
|
const user = {
|
|
494
494
|
name: 'Kimi',
|
|
@@ -520,7 +520,7 @@ console.log(pickedUser) // 输出:{ name: 'Kimi', email: 'kimi@example.com' }
|
|
|
520
520
|
#### 例子
|
|
521
521
|
|
|
522
522
|
```typescript
|
|
523
|
-
import { chunkArray } from '@
|
|
523
|
+
import { chunkArray } from '@mingtoools'
|
|
524
524
|
|
|
525
525
|
chunkArray(['a', 'b', 'c', 'd'], 2)
|
|
526
526
|
// [['a', 'b'], ['c', 'd']]
|
|
@@ -551,7 +551,7 @@ chunkArray([1, 2, 3, 4, 5], 4)
|
|
|
551
551
|
#### 例子
|
|
552
552
|
|
|
553
553
|
```typescript
|
|
554
|
-
import { getDecimalPlaces } from '@
|
|
554
|
+
import { getDecimalPlaces } from '@mingtoools'
|
|
555
555
|
|
|
556
556
|
console.log(getDecimalPlaces(123.456)) // 3
|
|
557
557
|
console.log(getDecimalPlaces(123)) // 0
|
|
@@ -577,7 +577,7 @@ console.log(getDecimalPlaces(-123.45)) // 2
|
|
|
577
577
|
#### 例子
|
|
578
578
|
|
|
579
579
|
```typescript
|
|
580
|
-
import { add } from '@
|
|
580
|
+
import { add } from '@mingtoools'
|
|
581
581
|
|
|
582
582
|
console.log(add(0.1, 0.2)) // 0.3
|
|
583
583
|
console.log(add(1.234, 5.678)) // 6.912
|
|
@@ -602,7 +602,7 @@ console.log(add(100, 0.001)) // 100.001
|
|
|
602
602
|
#### 例子
|
|
603
603
|
|
|
604
604
|
```typescript
|
|
605
|
-
import { subtract } from '@
|
|
605
|
+
import { subtract } from '@mingtoools'
|
|
606
606
|
|
|
607
607
|
console.log(subtract(0.3, 0.1)) // 0.2
|
|
608
608
|
console.log(subtract(1.234, 0.567)) // 0.667
|
|
@@ -627,7 +627,7 @@ console.log(subtract(100.001, 0.001)) // 100
|
|
|
627
627
|
#### 例子
|
|
628
628
|
|
|
629
629
|
```typescript
|
|
630
|
-
import { multiply } from '@
|
|
630
|
+
import { multiply } from '@mingtoools'
|
|
631
631
|
|
|
632
632
|
console.log(multiply(0.1, 0.2)) // 0.02
|
|
633
633
|
console.log(multiply(1.234, 5.678)) // 7.006652
|
|
@@ -652,7 +652,7 @@ console.log(multiply(100.001, 0.001)) // 0.100001
|
|
|
652
652
|
#### 例子
|
|
653
653
|
|
|
654
654
|
```typescript
|
|
655
|
-
import { divide } from '@
|
|
655
|
+
import { divide } from '@mingtoools'
|
|
656
656
|
|
|
657
657
|
console.log(divide(10, 2)) // 5
|
|
658
658
|
console.log(divide(1.234, 0.567)) // 2.1763668430335097
|
|
@@ -676,7 +676,7 @@ console.log(divide(100.001, 0.001)) // 100001
|
|
|
676
676
|
#### 例子
|
|
677
677
|
|
|
678
678
|
```typescript
|
|
679
|
-
import { calcAspectRatio } from '@
|
|
679
|
+
import { calcAspectRatio } from '@mingtoools'
|
|
680
680
|
|
|
681
681
|
calcAspectRatio([1920, 1080]) // [16, 9]
|
|
682
682
|
calcAspectRatio([1280, 800]) // [16, 10]
|
|
@@ -701,7 +701,7 @@ calcAspectRatio([1280, 800]) // [16, 10]
|
|
|
701
701
|
#### 例子
|
|
702
702
|
|
|
703
703
|
```typescript
|
|
704
|
-
import { copyText } from '@
|
|
704
|
+
import { copyText } from '@mingtoools'
|
|
705
705
|
|
|
706
706
|
copyText('Hello, World!').then(
|
|
707
707
|
text => console.log('Text copied to clipboard:', text),
|
|
@@ -722,7 +722,7 @@ copyText('Hello, World!').then(
|
|
|
722
722
|
#### 例子
|
|
723
723
|
|
|
724
724
|
```typescript
|
|
725
|
-
import { isIos } from '@
|
|
725
|
+
import { isIos } from '@mingtoools'
|
|
726
726
|
|
|
727
727
|
console.log(isIos()) // 输出 true 或 false
|
|
728
728
|
```
|
|
@@ -740,7 +740,7 @@ console.log(isIos()) // 输出 true 或 false
|
|
|
740
740
|
#### 例子
|
|
741
741
|
|
|
742
742
|
```typescript
|
|
743
|
-
import { isAndroid } from '@
|
|
743
|
+
import { isAndroid } from '@mingtoools'
|
|
744
744
|
|
|
745
745
|
console.log(isAndroid()) // 输出 true 或 false
|
|
746
746
|
```
|
|
@@ -758,7 +758,7 @@ console.log(isAndroid()) // 输出 true 或 false
|
|
|
758
758
|
#### 例子
|
|
759
759
|
|
|
760
760
|
```typescript
|
|
761
|
-
import { isMobile } from '@
|
|
761
|
+
import { isMobile } from '@mingtoools'
|
|
762
762
|
|
|
763
763
|
console.log(isMobile()) // 输出 true 或 false
|
|
764
764
|
```
|
|
@@ -776,7 +776,7 @@ console.log(isMobile()) // 输出 true 或 false
|
|
|
776
776
|
#### 例子
|
|
777
777
|
|
|
778
778
|
```typescript
|
|
779
|
-
import { isPc } from '@
|
|
779
|
+
import { isPc } from '@mingtoools'
|
|
780
780
|
|
|
781
781
|
console.log(isPc()) // 输出 true 或 false
|
|
782
782
|
```
|
|
@@ -794,7 +794,7 @@ console.log(isPc()) // 输出 true 或 false
|
|
|
794
794
|
#### 例子
|
|
795
795
|
|
|
796
796
|
```typescript
|
|
797
|
-
import { createAudioPermission } from '@
|
|
797
|
+
import { createAudioPermission } from '@mingtoools'
|
|
798
798
|
|
|
799
799
|
const audioPermission = createAudioPermission()
|
|
800
800
|
|
|
@@ -822,7 +822,7 @@ await audioPermission.requestMicrophonePermission()
|
|
|
822
822
|
#### 例子
|
|
823
823
|
|
|
824
824
|
```typescript
|
|
825
|
-
import { getBrowserFingerprint } from '@
|
|
825
|
+
import { getBrowserFingerprint } from '@mingtoools'
|
|
826
826
|
|
|
827
827
|
// 生成匿名用户唯一ID
|
|
828
828
|
const fingerprint = getBrowserFingerprint()
|
|
@@ -854,7 +854,7 @@ localStorage.setItem('anonymous_id', fingerprint)
|
|
|
854
854
|
#### 例子
|
|
855
855
|
|
|
856
856
|
```typescript
|
|
857
|
-
import { getAbsoluteUrl } from '@
|
|
857
|
+
import { getAbsoluteUrl } from '@mingtoools'
|
|
858
858
|
|
|
859
859
|
// 假设当前页面 URL 为 https://example.com/page
|
|
860
860
|
|
|
@@ -878,7 +878,7 @@ getAbsoluteUrl('') // ''
|
|
|
878
878
|
#### 例子
|
|
879
879
|
|
|
880
880
|
```typescript
|
|
881
|
-
import { getUuid } from '@
|
|
881
|
+
import { getUuid } from '@mingtoools'
|
|
882
882
|
|
|
883
883
|
const uuid = getUuid()
|
|
884
884
|
console.log(uuid) // 输出类似于 "1gann4cq9b6r"
|
|
@@ -901,7 +901,7 @@ console.log(uuid) // 输出类似于 "1gann4cq9b6r"
|
|
|
901
901
|
#### 例子
|
|
902
902
|
|
|
903
903
|
```typescript
|
|
904
|
-
import { timeDelay } from '@
|
|
904
|
+
import { timeDelay } from '@mingtoools'
|
|
905
905
|
|
|
906
906
|
await timeDelay(300)
|
|
907
907
|
// 继续后续逻辑
|
|
@@ -1041,7 +1041,7 @@ await timeDelay(300)
|
|
|
1041
1041
|
#### 例子
|
|
1042
1042
|
|
|
1043
1043
|
```typescript
|
|
1044
|
-
import { getFileSuffix } from '@
|
|
1044
|
+
import { getFileSuffix } from '@mingtoools'
|
|
1045
1045
|
|
|
1046
1046
|
console.log(getFileSuffix('example/document.pdf')) // "pdf"
|
|
1047
1047
|
console.log(getFileSuffix('image.jpg')) // "jpg"
|
|
@@ -1065,7 +1065,7 @@ console.log(getFileSuffix('no_extension')) // ""
|
|
|
1065
1065
|
#### 示例
|
|
1066
1066
|
|
|
1067
1067
|
```typescript
|
|
1068
|
-
import { getFileTitle } from '@
|
|
1068
|
+
import { getFileTitle } from '@mingtoools'
|
|
1069
1069
|
|
|
1070
1070
|
console.log(getFileTitle('/path/to/example/document.pdf')) // "document"
|
|
1071
1071
|
console.log(getFileTitle('/path/to/image.jpg')) // "image"
|
|
@@ -1089,7 +1089,7 @@ console.log(getFileTitle('/path/to/no_extension')) // "no_extension"
|
|
|
1089
1089
|
#### 示例
|
|
1090
1090
|
|
|
1091
1091
|
```typescript
|
|
1092
|
-
import { getFileName } from '@
|
|
1092
|
+
import { getFileName } from '@mingtoools'
|
|
1093
1093
|
|
|
1094
1094
|
console.log(getFileName('/path/to/example/document.pdf')) // "document.pdf"
|
|
1095
1095
|
console.log(getFileName('/path/to/image.jpg')) // "image.jpg"
|
|
@@ -1113,7 +1113,7 @@ console.log(getFileName('/path/to/no_extension')) // "no_extension"
|
|
|
1113
1113
|
#### 示例
|
|
1114
1114
|
|
|
1115
1115
|
```typescript
|
|
1116
|
-
import { isFilePath } from '@
|
|
1116
|
+
import { isFilePath } from '@mingtoools'
|
|
1117
1117
|
|
|
1118
1118
|
console.log(isFilePath('/path/to/example/document.pdf')) // true
|
|
1119
1119
|
console.log(isFilePath('/path/to/image.jpg')) // true
|
|
@@ -1137,7 +1137,7 @@ console.log(isFilePath('/path/to/no_extension')) // false
|
|
|
1137
1137
|
#### 例子
|
|
1138
1138
|
|
|
1139
1139
|
```typescript
|
|
1140
|
-
import { isImageFilePath } from '@
|
|
1140
|
+
import { isImageFilePath } from '@mingtoools'
|
|
1141
1141
|
|
|
1142
1142
|
console.log(isImageFilePath('/path/to/image.jpg')) // true
|
|
1143
1143
|
console.log(isImageFilePath('/path/to/image.png')) // true
|
|
@@ -1162,7 +1162,7 @@ console.log(isImageFilePath('/path/to/image.bmp')) // false
|
|
|
1162
1162
|
#### 例子
|
|
1163
1163
|
|
|
1164
1164
|
```typescript
|
|
1165
|
-
import { isVideoFilePath } from '@
|
|
1165
|
+
import { isVideoFilePath } from '@mingtoools'
|
|
1166
1166
|
|
|
1167
1167
|
console.log(isVideoFilePath('/path/to/video.mp4')) // true
|
|
1168
1168
|
console.log(isVideoFilePath('/path/to/video.avi')) // true
|
|
@@ -1185,7 +1185,7 @@ console.log(isVideoFilePath('/path/to/video.avi')) // true
|
|
|
1185
1185
|
#### 例子
|
|
1186
1186
|
|
|
1187
1187
|
```typescript
|
|
1188
|
-
import { isPptFilePath } from '@
|
|
1188
|
+
import { isPptFilePath } from '@mingtoools'
|
|
1189
1189
|
|
|
1190
1190
|
console.log(isPptFilePath('/path/to/presentation.ppt')) // true
|
|
1191
1191
|
console.log(isPptFilePath('/path/to/presentation.pptx')) // true
|
|
@@ -1208,7 +1208,7 @@ console.log(isPptFilePath('/path/to/presentation.pptx')) // true
|
|
|
1208
1208
|
#### 例子
|
|
1209
1209
|
|
|
1210
1210
|
```typescript
|
|
1211
|
-
import { isDocumentFilePath } from '@
|
|
1211
|
+
import { isDocumentFilePath } from '@mingtoools'
|
|
1212
1212
|
|
|
1213
1213
|
console.log(isDocumentFilePath('/path/to/document.pdf')) // true
|
|
1214
1214
|
console.log(isDocumentFilePath('/path/to/document.docx')) // true
|
|
@@ -1232,7 +1232,7 @@ console.log(isDocumentFilePath('/path/to/document.doc')) // true
|
|
|
1232
1232
|
#### 例子
|
|
1233
1233
|
|
|
1234
1234
|
```typescript
|
|
1235
|
-
import { isMusicFilePath } from '@
|
|
1235
|
+
import { isMusicFilePath } from '@mingtoools'
|
|
1236
1236
|
|
|
1237
1237
|
isMusicFilePath('/path/to/audio.mp3') // true
|
|
1238
1238
|
isMusicFilePath('/path/to/audio.wav') // true
|
|
@@ -1255,7 +1255,7 @@ isMusicFilePath('/path/to/audio.wav') // true
|
|
|
1255
1255
|
#### 例子
|
|
1256
1256
|
|
|
1257
1257
|
```typescript
|
|
1258
|
-
import { isCompressFilePath } from '@
|
|
1258
|
+
import { isCompressFilePath } from '@mingtoools'
|
|
1259
1259
|
|
|
1260
1260
|
isCompressFilePath('/path/to/archive.zip') // true
|
|
1261
1261
|
isCompressFilePath('/path/to/archive.rar') // true
|
|
@@ -1278,7 +1278,7 @@ isCompressFilePath('/path/to/archive.rar') // true
|
|
|
1278
1278
|
#### 示例
|
|
1279
1279
|
|
|
1280
1280
|
```typescript
|
|
1281
|
-
import { FileSuffixEnum, getFileSuffixIcon } from '@
|
|
1281
|
+
import { FileSuffixEnum, getFileSuffixIcon } from '@mingtoools'
|
|
1282
1282
|
|
|
1283
1283
|
console.log(getFileSuffixIcon(FileSuffixEnum.PDF)) // 返回 pdfIcon 的路径
|
|
1284
1284
|
console.log(getFileSuffixIcon(FileSuffixEnum.JPG)) // 返回 imageIcon 的路径
|
|
@@ -1302,7 +1302,7 @@ console.log(getFileSuffixIcon(FileSuffixEnum.TXT)) // 返回 txtIcon 的路径
|
|
|
1302
1302
|
#### 示例
|
|
1303
1303
|
|
|
1304
1304
|
```typescript
|
|
1305
|
-
import { getFileIcon } from '@
|
|
1305
|
+
import { getFileIcon } from '@mingtoools'
|
|
1306
1306
|
|
|
1307
1307
|
console.log(getFileIcon('/path/to/file.pdf')) // 返回 pdfIcon 的路径
|
|
1308
1308
|
console.log(getFileIcon('/path/to/file.txt')) // 返回 txtIcon 的路径
|
|
@@ -1325,7 +1325,7 @@ console.log(getFileIcon('/path/to/file.txt')) // 返回 txtIcon 的路径
|
|
|
1325
1325
|
#### 例子
|
|
1326
1326
|
|
|
1327
1327
|
```typescript
|
|
1328
|
-
import { getFilePathNotQuery } from '@
|
|
1328
|
+
import { getFilePathNotQuery } from '@mingtoools'
|
|
1329
1329
|
|
|
1330
1330
|
getFilePathNotQuery('https://a.com/file.pdf?x=1') // 'https://a.com/file.pdf'
|
|
1331
1331
|
```
|
|
@@ -1347,7 +1347,7 @@ getFilePathNotQuery('https://a.com/file.pdf?x=1') // 'https://a.com/file.pdf'
|
|
|
1347
1347
|
#### 例子
|
|
1348
1348
|
|
|
1349
1349
|
```typescript
|
|
1350
|
-
import { getFileQuery } from '@
|
|
1350
|
+
import { getFileQuery } from '@mingtoools'
|
|
1351
1351
|
|
|
1352
1352
|
getFileQuery('https://a.com/file.pdf?x=1&y=2') // { x: '1', y: '2' }
|
|
1353
1353
|
```
|
|
@@ -1371,7 +1371,7 @@ getFileQuery('https://a.com/file.pdf?x=1&y=2') // { x: '1', y: '2' }
|
|
|
1371
1371
|
#### 例子
|
|
1372
1372
|
|
|
1373
1373
|
```typescript
|
|
1374
|
-
import { updateFilePathQuery } from '@
|
|
1374
|
+
import { updateFilePathQuery } from '@mingtoools'
|
|
1375
1375
|
|
|
1376
1376
|
updateFilePathQuery('https://a.com/file.pdf?x=1', { y: '2' })
|
|
1377
1377
|
// 'https://a.com/file.pdf?x=1&y=2'
|
|
@@ -1398,7 +1398,7 @@ updateFilePathQuery('https://a.com/file.pdf?x=1', { y: '2' }, false)
|
|
|
1398
1398
|
#### 例子
|
|
1399
1399
|
|
|
1400
1400
|
```typescript
|
|
1401
|
-
import { singleDownloadFile } from '@
|
|
1401
|
+
import { singleDownloadFile } from '@mingtoools'
|
|
1402
1402
|
|
|
1403
1403
|
// 示例 1: 使用默认文件名下载
|
|
1404
1404
|
singleDownloadFile('https://example.com/document.pdf')
|
|
@@ -1425,7 +1425,7 @@ singleDownloadFile('https://example.com/document.pdf', 'custom_name.pdf')
|
|
|
1425
1425
|
#### 例子
|
|
1426
1426
|
|
|
1427
1427
|
```typescript
|
|
1428
|
-
import { batchDownloadFile } from '@
|
|
1428
|
+
import { batchDownloadFile } from '@mingtoools'
|
|
1429
1429
|
|
|
1430
1430
|
const fileList = [
|
|
1431
1431
|
{ filePath: 'https://example.com/file1.pdf', fileName: 'document1.pdf' },
|
|
@@ -1455,7 +1455,7 @@ batchDownloadFile(fileList, 'my-files.zip')
|
|
|
1455
1455
|
#### 例子
|
|
1456
1456
|
|
|
1457
1457
|
```typescript
|
|
1458
|
-
import { isValidUrl } from '@
|
|
1458
|
+
import { isValidUrl } from '@mingtoools'
|
|
1459
1459
|
|
|
1460
1460
|
isValidUrl('https://example.com?a=1#hash') // true
|
|
1461
1461
|
isValidUrl('ftp://example.com') // false
|
|
@@ -1476,7 +1476,7 @@ Vue 主题切换 Hook,支持亮色/暗黑模式切换与状态读取,并自
|
|
|
1476
1476
|
#### 例子
|
|
1477
1477
|
|
|
1478
1478
|
```typescript
|
|
1479
|
-
import { useTheme } from '@
|
|
1479
|
+
import { useTheme } from '@mingtoools'
|
|
1480
1480
|
|
|
1481
1481
|
const { theme, isDark, setDark, toggleTheme } = useTheme()
|
|
1482
1482
|
|
|
@@ -1499,7 +1499,7 @@ toggleTheme()
|
|
|
1499
1499
|
#### 例子
|
|
1500
1500
|
|
|
1501
1501
|
```typescript
|
|
1502
|
-
import tools from '@
|
|
1502
|
+
import tools from '@mingtoools'
|
|
1503
1503
|
|
|
1504
1504
|
tools.locale('zh-cn')
|
|
1505
1505
|
```
|
|
@@ -1513,7 +1513,7 @@ tools.locale('zh-cn')
|
|
|
1513
1513
|
#### 例子
|
|
1514
1514
|
|
|
1515
1515
|
```typescript
|
|
1516
|
-
import tools from '@
|
|
1516
|
+
import tools from '@mingtoools'
|
|
1517
1517
|
|
|
1518
1518
|
tools.getLocale() // 'zh-cn'
|
|
1519
1519
|
```
|
|
@@ -1533,7 +1533,7 @@ tools.getLocale() // 'zh-cn'
|
|
|
1533
1533
|
#### 例子
|
|
1534
1534
|
|
|
1535
1535
|
```typescript
|
|
1536
|
-
import { isWebSocketSupported } from '@
|
|
1536
|
+
import { isWebSocketSupported } from '@mingtoools'
|
|
1537
1537
|
|
|
1538
1538
|
if (isWebSocketSupported()) {
|
|
1539
1539
|
console.log('WebSocket is supported!')
|
|
@@ -1560,7 +1560,7 @@ else {
|
|
|
1560
1560
|
#### 例子
|
|
1561
1561
|
|
|
1562
1562
|
```typescript
|
|
1563
|
-
import { createWebSocket } from '@
|
|
1563
|
+
import { createWebSocket } from '@mingtoools'
|
|
1564
1564
|
|
|
1565
1565
|
const socket = createWebSocket('ws://example.com')
|
|
1566
1566
|
// 使用 socket 进行通信...
|
|
@@ -1585,7 +1585,7 @@ const socket = createWebSocket('ws://example.com')
|
|
|
1585
1585
|
#### 例子
|
|
1586
1586
|
|
|
1587
1587
|
```typescript
|
|
1588
|
-
import { createWorker } from '@
|
|
1588
|
+
import { createWorker } from '@mingtoools'
|
|
1589
1589
|
|
|
1590
1590
|
const myWorker = createWorker(() => {
|
|
1591
1591
|
console.log('Hello from the Web Worker!')
|
|
@@ -1605,7 +1605,7 @@ const myWorker = createWorker(() => {
|
|
|
1605
1605
|
#### 例子
|
|
1606
1606
|
|
|
1607
1607
|
```typescript
|
|
1608
|
-
import { closeWorker, createWorker } from '@
|
|
1608
|
+
import { closeWorker, createWorker } from '@mingtoools'
|
|
1609
1609
|
|
|
1610
1610
|
const myWorker = createWorker(() => {
|
|
1611
1611
|
console.log('Hello from the Web Worker!')
|