@fenglimg/cocos-state-controller 0.1.0
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/LICENSE +21 -0
- package/README.md +287 -0
- package/assets/script/controller/Capability.ts +100 -0
- package/assets/script/controller/Capability.ts.meta +10 -0
- package/assets/script/controller/CapabilityRegistry.ts +116 -0
- package/assets/script/controller/CapabilityRegistry.ts.meta +10 -0
- package/assets/script/controller/EnumPropRefMap.ts +232 -0
- package/assets/script/controller/EnumPropRefMap.ts.meta +10 -0
- package/assets/script/controller/NestedCtrlData.ts +199 -0
- package/assets/script/controller/NestedCtrlData.ts.meta +10 -0
- package/assets/script/controller/PrefabIntrospection.ts +151 -0
- package/assets/script/controller/PrefabIntrospection.ts.meta +10 -0
- package/assets/script/controller/Props.meta +13 -0
- package/assets/script/controller/StateControllerV2.ts +1957 -0
- package/assets/script/controller/StateControllerV2.ts.meta +10 -0
- package/assets/script/controller/StateEnumV2.ts +165 -0
- package/assets/script/controller/StateEnumV2.ts.meta +10 -0
- package/assets/script/controller/StateErrorManagerV2.ts +217 -0
- package/assets/script/controller/StateErrorManagerV2.ts.meta +10 -0
- package/assets/script/controller/StatePropHandlerV2.ts +316 -0
- package/assets/script/controller/StatePropHandlerV2.ts.meta +10 -0
- package/assets/script/controller/StatePropertyControlService.ts +148 -0
- package/assets/script/controller/StatePropertyControlService.ts.meta +10 -0
- package/assets/script/controller/StateSelectV2.ts +4542 -0
- package/assets/script/controller/StateSelectV2.ts.meta +10 -0
- package/assets/script/controller/capabilities/AutoSyncCapability.ts +30 -0
- package/assets/script/controller/capabilities/AutoSyncCapability.ts.meta +10 -0
- package/assets/script/controller/capabilities/EventCapability.ts +144 -0
- package/assets/script/controller/capabilities/EventCapability.ts.meta +10 -0
- package/assets/script/controller/capabilities/MigrationCapability.ts +94 -0
- package/assets/script/controller/capabilities/MigrationCapability.ts.meta +10 -0
- package/assets/script/controller/capabilities/MultiCtrlBindingCapability.ts +157 -0
- package/assets/script/controller/capabilities/MultiCtrlBindingCapability.ts.meta +10 -0
- package/assets/script/controller/capabilities/PropertyControlCapability.ts +124 -0
- package/assets/script/controller/capabilities/PropertyControlCapability.ts.meta +10 -0
- package/assets/script/controller/capabilities/RecordingCapability.ts +69 -0
- package/assets/script/controller/capabilities/RecordingCapability.ts.meta +10 -0
- package/assets/script/controller/capabilities/SelectedPageIdCapability.ts +88 -0
- package/assets/script/controller/capabilities/SelectedPageIdCapability.ts.meta +10 -0
- package/assets/script/controller/capabilities.meta +13 -0
- package/assets/script/controller/props/CtrlInspectorGroups.ts +138 -0
- package/assets/script/controller/props/CtrlInspectorGroups.ts.meta +10 -0
- package/assets/script/controller/props/SelectInspectorGroups.ts +104 -0
- package/assets/script/controller/props/SelectInspectorGroups.ts.meta +10 -0
- package/bin/csc.js +286 -0
- package/package.json +60 -0
- package/packages/state-controller-v2-panel/README.md +80 -0
- package/packages/state-controller-v2-panel/inspector-inject.js +917 -0
- package/packages/state-controller-v2-panel/inspector-probe.json +3767 -0
- package/packages/state-controller-v2-panel/lib/handlers.js +534 -0
- package/packages/state-controller-v2-panel/main.js +149 -0
- package/packages/state-controller-v2-panel/package.json +32 -0
- package/packages/state-controller-v2-panel/panel/build.js +23 -0
- package/packages/state-controller-v2-panel/panel/logic.js +1207 -0
- package/packages/state-controller-v2-panel/panel/styles.css +454 -0
- package/packages/state-controller-v2-panel/panel/template.html +296 -0
- package/packages/state-controller-v2-panel/scene-accessor.js +657 -0
- package/skills/cocos-state-controller/SKILL.md +28 -0
- package/skills/cocos-state-controller/refs/cli-usage.md +78 -0
- package/skills/cocos-state-controller/refs/editor-guide.md +127 -0
- package/skills/cocos-state-controller/refs/migrate.md +106 -0
- package/skills/cocos-state-controller/refs/upstream-pr.md +66 -0
- package/tools/migration/migrate-prefab-v1-to-v2.js +608 -0
- package/tools/state-controller-sync-manifest.json +33 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 状态名枚举 (空骨架, 不要往里加值)。
|
|
3
|
+
*
|
|
4
|
+
* Cocos Creator 2.x 用 @property(EnumStateName) 把字段显示成枚举下拉。
|
|
5
|
+
* 下拉的实际选项不在这里静态声明 — StateControllerV2 在运行时通过
|
|
6
|
+
* cc.Class.Attr.setClassAttr(this, "selectedIndex", "enumList", array)
|
|
7
|
+
* 把当前实例的 states 列表注入到这个枚举的下拉项。
|
|
8
|
+
*/
|
|
9
|
+
export enum EnumStateName {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** 更新选择器的类型 */
|
|
13
|
+
export enum EnumUpdateType {
|
|
14
|
+
/** 名字 */
|
|
15
|
+
Name = 1,
|
|
16
|
+
/** 可选状态 */
|
|
17
|
+
SelPage = 2,
|
|
18
|
+
/** 状态 */
|
|
19
|
+
State = 0,
|
|
20
|
+
/** 删除控制器 */
|
|
21
|
+
Delete = 4,
|
|
22
|
+
/** 初始化 */
|
|
23
|
+
Init = 3,
|
|
24
|
+
/** 更新选中的属性 */
|
|
25
|
+
Prop = 5,
|
|
26
|
+
/** 状态顺序变更 */
|
|
27
|
+
Move = 6,
|
|
28
|
+
/** 状态复制 (copySelectedState 触发, 通知 StateSelectV2 深拷贝 pageData) */
|
|
29
|
+
Copy = 7,
|
|
30
|
+
/** 录制开始 (StateControllerV2.startRecording 触发, 通知 StateSelectV2 拍 snapshot) */
|
|
31
|
+
RecordingStart = 8,
|
|
32
|
+
/** 录制结束 (StateControllerV2.stopRecording 触发, 通知 StateSelectV2 final commit + 清 snapshot) */
|
|
33
|
+
RecordingStop = 9,
|
|
34
|
+
/** 状态即将切换 (selectedIndex setter 触发, 录制中触发 diff commit) */
|
|
35
|
+
StateWillChange = 10,
|
|
36
|
+
/** 回收站硬删 (purgeDeletedState 触发, 通知 StateSelectV2 清掉 _ctrlData[stateId] 页数据), value = stateId */
|
|
37
|
+
PurgeStateId = 11,
|
|
38
|
+
/** 回收站预览进入 (previewDeletedState 触发, 通知 StateSelectV2 快照+apply 该 stateId 数据), value = stateId */
|
|
39
|
+
PreviewEnter = 12,
|
|
40
|
+
/** 回收站预览退出 (exitPreview 触发, 通知 StateSelectV2 按快照还原节点) */
|
|
41
|
+
PreviewExit = 13,
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* 控制器名字枚举 (空骨架, 不要往里加值)。
|
|
45
|
+
* 同 EnumStateName: 由 StateSelectV2 运行时把可见的控制器名字列表
|
|
46
|
+
* 注入为 currCtrlId 字段的 inspector 下拉项。
|
|
47
|
+
*/
|
|
48
|
+
export enum EnumCtrlName {
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* W6-4 排除清单下拉空骨架枚举 (不要往里加值)。
|
|
52
|
+
* 同 EnumStateName / EnumCtrlName: 由 StateSelectV2.refreshExcludeEnumLists 运行时
|
|
53
|
+
* 通过 cc.Class.Attr.setClassAttr(this, "addExcludeTrigger" | "removeExcludeTrigger", "enumList", array)
|
|
54
|
+
* 注入实际选项. cocos 2.x inspector 必须有 type:EnumXxx 才渲染下拉, type:cc.String 渲染输入框.
|
|
55
|
+
*/
|
|
56
|
+
export enum EnumExcludeSlot {
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 🔧 核心枚举:属性名 - 定义所有支持的UI属性类型
|
|
60
|
+
*
|
|
61
|
+
* 这是整个状态控制器系统的基础枚举:
|
|
62
|
+
* 1. 每个枚举值对应一种UI属性类型
|
|
63
|
+
* 2. 枚举值的顺序决定了编辑器中的显示顺序
|
|
64
|
+
* 3. 添加新属性类型需要同步更新属性处理器
|
|
65
|
+
* 4. Non=0 是特殊值,表示"不选择任何属性"
|
|
66
|
+
*
|
|
67
|
+
* 扩展方式:
|
|
68
|
+
* 1. 在此枚举中添加新的属性类型
|
|
69
|
+
* 2. 在StatePropHandler.ts中实现对应的处理器
|
|
70
|
+
* 3. 在StateSelectV2.ts中的setDefaultProp方法中添加对应的case
|
|
71
|
+
*/
|
|
72
|
+
export enum EnumPropName {
|
|
73
|
+
/** 不选择 - 特殊值,表示未选择任何属性 */
|
|
74
|
+
Non = 0,
|
|
75
|
+
|
|
76
|
+
// 🔧 节点基础属性
|
|
77
|
+
/** 显示隐藏 */
|
|
78
|
+
Active = 1,
|
|
79
|
+
/** 位置 */
|
|
80
|
+
Position = 2,
|
|
81
|
+
/** 旋转、欧拉角 */
|
|
82
|
+
Euler = 6,
|
|
83
|
+
/** 缩放 */
|
|
84
|
+
Scale = 7,
|
|
85
|
+
/** 锚点 */
|
|
86
|
+
Anchor = 8,
|
|
87
|
+
/** 宽高 */
|
|
88
|
+
Size = 9,
|
|
89
|
+
/** 颜色 */
|
|
90
|
+
Color = 10,
|
|
91
|
+
/** 透明度 */
|
|
92
|
+
Opacity = 11,
|
|
93
|
+
|
|
94
|
+
// 🔧 组件相关属性
|
|
95
|
+
/** 文本 */
|
|
96
|
+
LabelString = 3,
|
|
97
|
+
/** 描边 */
|
|
98
|
+
LabelOutlineColor = 4,
|
|
99
|
+
/** 图片 */
|
|
100
|
+
SpriteFrame = 5,
|
|
101
|
+
/** 字体 */
|
|
102
|
+
Font = 12,
|
|
103
|
+
/** 滑动条 */
|
|
104
|
+
SliderProgress = 13,
|
|
105
|
+
/** 编辑框 */
|
|
106
|
+
EditboxString = 14,
|
|
107
|
+
/** 灰度 */
|
|
108
|
+
GrayScale = 15,
|
|
109
|
+
/** 按钮交互 */
|
|
110
|
+
ButtonInteractable = 16,
|
|
111
|
+
|
|
112
|
+
/** 进度条(ProgressBar) 进度 */
|
|
113
|
+
ProgressBarProgress = 17,
|
|
114
|
+
/** Toggle 选中状态 */
|
|
115
|
+
ToggleIsChecked = 18,
|
|
116
|
+
/** RichText 文本内容 */
|
|
117
|
+
RichTextString = 19,
|
|
118
|
+
/** ScrollView 启用状态 */
|
|
119
|
+
ScrollViewEnabled = 20,
|
|
120
|
+
/** Mask 组件启用状态 */
|
|
121
|
+
MaskEnabled = 21,
|
|
122
|
+
|
|
123
|
+
/** Label 字体大小 */
|
|
124
|
+
LabelFontSize = 22,
|
|
125
|
+
/** Label 行高 */
|
|
126
|
+
LabelLineHeight = 23,
|
|
127
|
+
/** Label 字符间距 (spacingX) */
|
|
128
|
+
LabelSpacingX = 24,
|
|
129
|
+
/** Label 自动换行开关 */
|
|
130
|
+
LabelWrapEnable = 25,
|
|
131
|
+
/** Sprite 填充范围 (fillRange) */
|
|
132
|
+
SpriteFillRange = 26,
|
|
133
|
+
/** Widget 启用状态 */
|
|
134
|
+
WidgetEnabled = 27,
|
|
135
|
+
/** Widget 对齐刷新模式 */
|
|
136
|
+
WidgetAlignMode = 28,
|
|
137
|
+
/** Widget 顶部对齐开关 */
|
|
138
|
+
WidgetIsAlignTop = 29,
|
|
139
|
+
/** Widget 底部对齐开关 */
|
|
140
|
+
WidgetIsAlignBottom = 30,
|
|
141
|
+
/** Widget 左侧对齐开关 */
|
|
142
|
+
WidgetIsAlignLeft = 31,
|
|
143
|
+
/** Widget 右侧对齐开关 */
|
|
144
|
+
WidgetIsAlignRight = 32,
|
|
145
|
+
/** Widget 水平居中开关 */
|
|
146
|
+
WidgetIsAlignHorizontalCenter = 33,
|
|
147
|
+
/** Widget 垂直居中开关 */
|
|
148
|
+
WidgetIsAlignVerticalCenter = 34,
|
|
149
|
+
/** Widget 顶部边距 */
|
|
150
|
+
WidgetTop = 35,
|
|
151
|
+
/** Widget 底部边距 */
|
|
152
|
+
WidgetBottom = 36,
|
|
153
|
+
/** Widget 左侧边距 */
|
|
154
|
+
WidgetLeft = 37,
|
|
155
|
+
/** Widget 右侧边距 */
|
|
156
|
+
WidgetRight = 38,
|
|
157
|
+
/** Widget 水平居中偏移 */
|
|
158
|
+
WidgetHorizontalCenter = 39,
|
|
159
|
+
/** Widget 垂直居中偏移 */
|
|
160
|
+
WidgetVerticalCenter = 40,
|
|
161
|
+
|
|
162
|
+
// 🔧 注意:旋转四元数暂时不支持,因为编辑器操作复杂
|
|
163
|
+
// /** 旋转、四元数*/
|
|
164
|
+
// Rotation,
|
|
165
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/** 🔧 错误级别枚举 */
|
|
2
|
+
export enum ErrorLevel {
|
|
3
|
+
DEBUG = 0,
|
|
4
|
+
INFO = 1,
|
|
5
|
+
WARN = 2,
|
|
6
|
+
ERROR = 3,
|
|
7
|
+
FATAL = 4,
|
|
8
|
+
SILENT = 5, // 特殊级别:完全静音
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** 🔧 错误处理上下文接口 */
|
|
12
|
+
export interface IErrorContext {
|
|
13
|
+
component?: string
|
|
14
|
+
method?: string
|
|
15
|
+
params?: unknown
|
|
16
|
+
node?: cc.Node
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 🔧 统一错误处理类 - 为整个状态控制器系统提供统一的错误处理机制
|
|
21
|
+
*
|
|
22
|
+
* 核心功能:
|
|
23
|
+
* 1. 统一的日志格式和输出
|
|
24
|
+
* 2. 按级别分类的错误处理
|
|
25
|
+
* 3. 编辑器和运行时环境的适配
|
|
26
|
+
* 4. 优雅的降级处理机制
|
|
27
|
+
* 5. 常见错误场景的验证工具
|
|
28
|
+
* 6. 可配置的日志级别控制
|
|
29
|
+
*/
|
|
30
|
+
export class StateErrorManager {
|
|
31
|
+
private static readonly COMPONENT_NAME = "StateControllerV2";
|
|
32
|
+
|
|
33
|
+
/** 🔧 当前日志输出级别,只有高于或等于此级别的日志才会输出 */
|
|
34
|
+
private static _logLevel: ErrorLevel = ErrorLevel.WARN;
|
|
35
|
+
|
|
36
|
+
/** 🔧 设置日志输出级别 */
|
|
37
|
+
public static setLogLevel(level: ErrorLevel) {
|
|
38
|
+
this._logLevel = level;
|
|
39
|
+
this.info(`日志级别已设置为: ${ErrorLevel[level]}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** 🔧 获取当前日志级别 */
|
|
43
|
+
public static getLogLevel(): ErrorLevel {
|
|
44
|
+
return this._logLevel;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** 🔧 检查是否应该输出指定级别的日志 */
|
|
48
|
+
private static shouldLog(level: ErrorLevel): boolean {
|
|
49
|
+
return level >= this._logLevel;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 🔧 统一日志输出方法 - 根据不同错误级别和环境选择合适的输出方式
|
|
54
|
+
*
|
|
55
|
+
* @param level 错误级别
|
|
56
|
+
* @param message 错误消息
|
|
57
|
+
* @param context 错误上下文,包含组件、方法、参数等详细信息
|
|
58
|
+
*/
|
|
59
|
+
private static log(level: ErrorLevel, message: string, context?: IErrorContext) {
|
|
60
|
+
// 🔧 级别检查:如果当前级别低于设定级别,则不输出
|
|
61
|
+
if (!this.shouldLog(level)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const levelName = ErrorLevel[level];
|
|
66
|
+
const prefix = `[${this.COMPONENT_NAME}][${levelName}]`;
|
|
67
|
+
const fullMessage = context
|
|
68
|
+
? `${prefix} ${message} | Context: ${JSON.stringify(context)}`
|
|
69
|
+
: `${prefix} ${message}`;
|
|
70
|
+
|
|
71
|
+
// 🔧 根据错误级别选择不同的输出方式
|
|
72
|
+
switch (level) {
|
|
73
|
+
case ErrorLevel.DEBUG:
|
|
74
|
+
// 🔧 调试信息:仅在开发模式下输出,使用较低的优先级
|
|
75
|
+
if (CC_EDITOR) {
|
|
76
|
+
cc.log(`🔍 ${fullMessage}`);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// console.debug ? console.debug(fullMessage) : console.log(fullMessage);
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
case ErrorLevel.INFO:
|
|
83
|
+
if (CC_EDITOR) {
|
|
84
|
+
cc.log(fullMessage);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// console.log(fullMessage);
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
case ErrorLevel.WARN:
|
|
91
|
+
// 🔧 编辑器环境使用cc.warn,运行时使用console.warn
|
|
92
|
+
if (CC_EDITOR) {
|
|
93
|
+
cc.warn(fullMessage);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
// console.warn(fullMessage);
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
case ErrorLevel.ERROR:
|
|
100
|
+
// 🔧 编辑器环境使用cc.error,运行时使用console.error
|
|
101
|
+
if (CC_EDITOR) {
|
|
102
|
+
cc.error(fullMessage);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// console.error(fullMessage);
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
case ErrorLevel.FATAL:
|
|
109
|
+
// 🔧 致命错误:使用特殊标识符,便于快速定位严重问题
|
|
110
|
+
if (CC_EDITOR) {
|
|
111
|
+
cc.error(`💥 FATAL: ${fullMessage}`);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
// console.error(`💥 FATAL: ${fullMessage}`);
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** 友好的用户提示 */
|
|
121
|
+
public static userFriendlyError(userMessage: string, technicalDetails?: string, context?: IErrorContext) {
|
|
122
|
+
this.log(ErrorLevel.ERROR, userMessage, context);
|
|
123
|
+
if (technicalDetails) {
|
|
124
|
+
this.log(ErrorLevel.INFO, `技术细节: ${technicalDetails}`, context);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 🔧 核心方法:优雅降级处理 - 在操作失败时提供安全的备选方案
|
|
130
|
+
*
|
|
131
|
+
* 这是系统稳定性的关键机制:
|
|
132
|
+
* 1. 捕获所有异常,避免系统崩溃
|
|
133
|
+
* 2. 提供合理的降级值,保证功能连续性
|
|
134
|
+
* 3. 记录错误信息,便于问题追踪
|
|
135
|
+
* 4. 对用户透明,不影响正常使用流程
|
|
136
|
+
*
|
|
137
|
+
* @param operation 要执行的操作函数
|
|
138
|
+
* @param fallbackValue 操作失败时的降级返回值
|
|
139
|
+
* @param errorMessage 自定义错误消息
|
|
140
|
+
* @returns 操作成功时返回原值,失败时返回降级值
|
|
141
|
+
*/
|
|
142
|
+
public static gracefulFallback<T>(operation: () => T, fallbackValue: T, errorMessage?: string): T {
|
|
143
|
+
try {
|
|
144
|
+
return operation();
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
// 🔧 记录错误并返回安全的降级值,确保系统继续运行
|
|
148
|
+
this.log(ErrorLevel.WARN, errorMessage || "操作失败,使用降级处理", { params: { error: error.message } });
|
|
149
|
+
return fallbackValue;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 🔧 节点有效性验证 - 防止对无效节点的操作导致系统错误
|
|
155
|
+
*
|
|
156
|
+
* 常见的节点无效场景:
|
|
157
|
+
* 1. 节点被删除但引用仍然存在
|
|
158
|
+
* 2. 节点在场景切换时被销毁
|
|
159
|
+
* 3. 节点引用为null或undefined
|
|
160
|
+
* 4. 节点的isValid属性为false
|
|
161
|
+
*
|
|
162
|
+
* @param node 要验证的节点
|
|
163
|
+
* @param context 验证上下文信息
|
|
164
|
+
* @returns 节点有效返回true,无效返回false
|
|
165
|
+
*/
|
|
166
|
+
public static validateNode(node: cc.Node, context?: IErrorContext): boolean {
|
|
167
|
+
if (!node || !node.isValid) {
|
|
168
|
+
this.userFriendlyError(
|
|
169
|
+
"节点无效或已被销毁",
|
|
170
|
+
"请检查节点是否存在且未被删除",
|
|
171
|
+
context,
|
|
172
|
+
);
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** 验证属性类型 */
|
|
179
|
+
public static validatePropType(propType: unknown, context?: IErrorContext): boolean {
|
|
180
|
+
if (propType === undefined || propType === null) {
|
|
181
|
+
this.userFriendlyError(
|
|
182
|
+
"属性类型不能为空",
|
|
183
|
+
"请选择有效的属性类型",
|
|
184
|
+
context,
|
|
185
|
+
);
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// 🔧 便捷方法:直接调用不同级别的日志
|
|
192
|
+
|
|
193
|
+
/** 调试日志 */
|
|
194
|
+
public static debug(message: string, context?: IErrorContext) {
|
|
195
|
+
this.log(ErrorLevel.DEBUG, message, context);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** 信息日志 */
|
|
199
|
+
public static info(message: string, context?: IErrorContext) {
|
|
200
|
+
this.log(ErrorLevel.INFO, message, context);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** 警告日志 */
|
|
204
|
+
public static warn(message: string, context?: IErrorContext) {
|
|
205
|
+
this.log(ErrorLevel.WARN, message, context);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** 错误日志 */
|
|
209
|
+
public static error(message: string, context?: IErrorContext) {
|
|
210
|
+
this.log(ErrorLevel.ERROR, message, context);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** 致命错误日志 */
|
|
214
|
+
public static fatal(message: string, context?: IErrorContext) {
|
|
215
|
+
this.log(ErrorLevel.FATAL, message, context);
|
|
216
|
+
}
|
|
217
|
+
}
|