@micl/constant 0.0.1
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 +139 -0
- package/index.js +1 -0
- package/package.json +36 -0
- package/types/core.d.ts +11 -0
- package/types/index.d.ts +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# @micl/constant
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
Micl 项目的常量定义模块,提供统一的枚举和常量配置,确保项目中常量的一致性和可维护性。
|
|
8
|
+
|
|
9
|
+
## 📦 安装
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @micl/constant
|
|
13
|
+
# or
|
|
14
|
+
pnpm add @micl/constant
|
|
15
|
+
# or
|
|
16
|
+
yarn add @micl/constant
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 📚 模块导出
|
|
20
|
+
|
|
21
|
+
### TASK_STATUS_ENUM
|
|
22
|
+
|
|
23
|
+
任务状态枚举,定义了任务的各种状态码:
|
|
24
|
+
|
|
25
|
+
| 状态 | 值 | 描述 | 类型 |
|
|
26
|
+
|------|-----|------|------|
|
|
27
|
+
| `NotFound` | 0 | 任务不存在 | 系统状态 |
|
|
28
|
+
| `Created` | 1 | 任务已创建 | 系统状态 |
|
|
29
|
+
| `Pending` | 2 | 任务等待中 | 系统状态 |
|
|
30
|
+
| `Stopping` | 3 | 任务停止中 | 系统状态 |
|
|
31
|
+
| `Completed` | 4 | 任务已完成 | 系统状态 |
|
|
32
|
+
| `Failed` | 5 | 任务失败 | 系统状态 |
|
|
33
|
+
| `Pause` | 12 | 任务暂停 | 用户操作 |
|
|
34
|
+
| `Abort` | 13 | 任务中止 | 用户操作 |
|
|
35
|
+
| `Delete` | 99 | 任务删除 | 用户操作 |
|
|
36
|
+
|
|
37
|
+
## 🎯 使用示例
|
|
38
|
+
|
|
39
|
+
### 基本使用
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { TASK_STATUS_ENUM } from '@micl/constant';
|
|
43
|
+
|
|
44
|
+
// 检查任务状态
|
|
45
|
+
if (task.status === TASK_STATUS_ENUM.Completed) {
|
|
46
|
+
console.log('任务已完成');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// 状态判断
|
|
50
|
+
function getStatusText(status: number): string {
|
|
51
|
+
const statusMap: Record<number, string> = {
|
|
52
|
+
[TASK_STATUS_ENUM.NotFound]: '任务不存在',
|
|
53
|
+
[TASK_STATUS_ENUM.Created]: '任务已创建',
|
|
54
|
+
[TASK_STATUS_ENUM.Pending]: '任务等待中',
|
|
55
|
+
[TASK_STATUS_ENUM.Stopping]: '任务停止中',
|
|
56
|
+
[TASK_STATUS_ENUM.Completed]: '任务已完成',
|
|
57
|
+
[TASK_STATUS_ENUM.Failed]: '任务失败',
|
|
58
|
+
[TASK_STATUS_ENUM.Pause]: '任务暂停',
|
|
59
|
+
[TASK_STATUS_ENUM.Abort]: '任务中止',
|
|
60
|
+
[TASK_STATUS_ENUM.Delete]: '任务删除',
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return statusMap[status] || '未知状态';
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 类型安全
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { TASK_STATUS_ENUM } from '@micl/constant';
|
|
71
|
+
|
|
72
|
+
// TypeScript 类型推断
|
|
73
|
+
const status: TASK_STATUS_ENUM = TASK_STATUS_ENUM.Pending;
|
|
74
|
+
|
|
75
|
+
// 类型安全的状态检查
|
|
76
|
+
function processTask(status: TASK_STATUS_ENUM): void {
|
|
77
|
+
switch (status) {
|
|
78
|
+
case TASK_STATUS_ENUM.Completed:
|
|
79
|
+
// 处理完成状态
|
|
80
|
+
break;
|
|
81
|
+
case TASK_STATUS_ENUM.Failed:
|
|
82
|
+
// 处理失败状态
|
|
83
|
+
break;
|
|
84
|
+
// 其他状态处理...
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## 🛠 开发
|
|
90
|
+
|
|
91
|
+
### 构建
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# 进入 constant 目录
|
|
95
|
+
cd constant
|
|
96
|
+
|
|
97
|
+
# 构建项目
|
|
98
|
+
yarn build
|
|
99
|
+
|
|
100
|
+
# 或使用 npm
|
|
101
|
+
npm run build
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 代码质量
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# 代码检查
|
|
108
|
+
yarn lint
|
|
109
|
+
|
|
110
|
+
# 代码格式化
|
|
111
|
+
yarn format
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 📁 项目结构
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
constant/
|
|
118
|
+
├── core.ts # 核心常量定义
|
|
119
|
+
├── index.ts # 模块导出
|
|
120
|
+
├── package.json # 包配置
|
|
121
|
+
├── rollup.config.js # 构建配置
|
|
122
|
+
└── yarn.lock # 依赖锁文件
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## 🤝 贡献
|
|
126
|
+
|
|
127
|
+
欢迎提交 Issue 和 Pull Request 来完善这个模块。
|
|
128
|
+
|
|
129
|
+
## 📄 许可证
|
|
130
|
+
|
|
131
|
+
本项目采用 ISC 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情。
|
|
132
|
+
|
|
133
|
+
## 📞 支持
|
|
134
|
+
|
|
135
|
+
如有问题或建议,请提交 [Issue](../../issues) 或联系维护者。
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
**@micl/constant** - 统一常量管理,简化开发流程 🚀
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e;!function(e){e[e.NotFound=0]="NotFound",e[e.Created=1]="Created",e[e.Pending=2]="Pending",e[e.Stopping=3]="Stopping",e[e.Completed=4]="Completed",e[e.Failed=5]="Failed",e[e.Pause=12]="Pause",e[e.Abort=13]="Abort",e[e.Delete=99]="Delete"}(e||(e={}));export{e as TASK_STATUS_ENUM};
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@micl/constant",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "micl constant",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"types": "types/index.d.ts",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=18.0.0"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "rollup -c",
|
|
13
|
+
"lint": "eslint --ext .js,.ts src",
|
|
14
|
+
"format": "eslint --ext .js,.ts src --fix"
|
|
15
|
+
},
|
|
16
|
+
"author": "alexgogoing",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@babel/core": "^7.24.9",
|
|
20
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
21
|
+
"@rollup/plugin-commonjs": "^26.0.1",
|
|
22
|
+
"@rollup/plugin-eslint": "^9.0.5",
|
|
23
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
24
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
25
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
26
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
27
|
+
"@rollup/plugin-virtual": "^3.0.2",
|
|
28
|
+
"@typescript-eslint/eslint-plugin": "^7.16.1",
|
|
29
|
+
"@typescript-eslint/parser": "^7.16.1",
|
|
30
|
+
"eslint": "^9.7.0",
|
|
31
|
+
"eslint-config-prettier": "^9.1.0",
|
|
32
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
33
|
+
"rollup": "^4.18.1",
|
|
34
|
+
"typescript": "^5.5.3"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/types/core.d.ts
ADDED
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TASK_STATUS_ENUM } from './core';
|