@airpower/enum 0.0.3 → 0.0.5
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 +17 -18
- package/package.json +4 -4
- /package/dist/{airpower.js → main.js} +0 -0
package/README.md
CHANGED
|
@@ -26,42 +26,41 @@ cnpm install @airpower/enum
|
|
|
26
26
|
## 📖 如何使用
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
|
-
import {Enum} from
|
|
29
|
+
import { Enum } from '@/airpower/enum'
|
|
30
30
|
|
|
31
31
|
class UserGender extends Enum<string> {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
static MALE = new UserGender('MALE', '男')
|
|
33
|
+
static FEMALE = new UserGender('FEMALE', '女')
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
class UserStatus extends Enum {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
static NORMAL = new UserStatus(0, '正常')
|
|
38
|
+
static DISABLED = new UserStatus(1, '禁用')
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// 扩展自定义属性
|
|
42
42
|
|
|
43
43
|
class Platform extends Enum<number> {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
static readonly MAC = new Platform(1, 'mac', 'apple.png')
|
|
45
|
+
static readonly WINDOWS = new Platform(2, 'windows', 'windows.png')
|
|
46
|
+
static readonly ANDROID = new Platform(3, 'android', 'android.png')
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
icon!: string
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
50
|
+
constructor(key: number, label?: string, icon?: string) {
|
|
51
|
+
super(key, label)
|
|
52
|
+
if (icon) {
|
|
53
|
+
this.icon = icon
|
|
55
54
|
}
|
|
55
|
+
}
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
static getIcon(this: EnumConstructor<number, Platform>, key: number) {
|
|
58
|
+
return this.get(key)!.icon
|
|
59
|
+
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
console.warn(Platform.getIcon(1))
|
|
63
63
|
console.warn(Platform.MAC.icon)
|
|
64
|
-
|
|
65
64
|
```
|
|
66
65
|
|
|
67
66
|
## ⏰ 欢迎反馈
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airpower/enum",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"description": "AirPower-Enum 是一个基于 TypeScript 的封装的类似 Java 枚举类的枚举字典处理工具。",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Hamm",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"module": "dist/main.js",
|
|
31
31
|
"types": "dist/index.d.ts",
|
|
32
32
|
"files": [
|
|
33
|
-
"
|
|
34
|
-
"
|
|
33
|
+
"assets",
|
|
34
|
+
"dist"
|
|
35
35
|
],
|
|
36
36
|
"scripts": {
|
|
37
|
-
"build": "tsc && vite build",
|
|
37
|
+
"build": "eslint && tsc && vite build",
|
|
38
38
|
"lint": "eslint src --ext .ts",
|
|
39
39
|
"preview": "vite preview"
|
|
40
40
|
},
|
|
File without changes
|