2022-11-27 20:22:42 +08:00
|
|
|
import DeleteRule from "../bo/rules/DeleteRule";
|
|
|
|
import InsertRule from "../bo/rules/InsertRule";
|
|
|
|
import SerializationRule from "../bo/rules/SerializationRule";
|
|
|
|
import AutoRule from "../bo/rules/AutoRule";
|
2023-05-10 20:24:29 +08:00
|
|
|
import ReplaceRule from "../bo/rules/ReplaceRule";
|
2024-09-18 16:58:59 +08:00
|
|
|
import TranslateRole from "../bo/rules/TranslateRole";
|
2022-11-27 20:22:42 +08:00
|
|
|
|
|
|
|
export default class RuleObj {
|
2023-05-10 20:24:29 +08:00
|
|
|
type: string;
|
|
|
|
message: string;
|
|
|
|
/**
|
|
|
|
* 具体参数
|
|
|
|
*/
|
|
|
|
data: any;
|
2022-11-27 20:22:42 +08:00
|
|
|
|
2023-05-10 20:24:29 +08:00
|
|
|
constructor(data: any) {
|
|
|
|
this.type = data.type;
|
|
|
|
this.message = data.message;
|
|
|
|
switch (this.type) {
|
|
|
|
case "delete":
|
|
|
|
this.data = new DeleteRule(data.data);
|
|
|
|
break;
|
|
|
|
case "insert":
|
|
|
|
this.data = new InsertRule(data.data);
|
|
|
|
break;
|
|
|
|
case "serialization":
|
|
|
|
this.data = new SerializationRule(data.data);
|
|
|
|
break;
|
|
|
|
case "auto":
|
|
|
|
this.data = new AutoRule(data.data);
|
|
|
|
break;
|
|
|
|
case "replace":
|
|
|
|
this.data = new ReplaceRule(data.data);
|
|
|
|
break;
|
2024-09-18 16:58:59 +08:00
|
|
|
case "translate":
|
|
|
|
this.data = new TranslateRole(data.data);
|
|
|
|
break;
|
2023-05-10 20:24:29 +08:00
|
|
|
default:
|
|
|
|
throw new Error("不支持的规则:" + this.type);
|
|
|
|
}
|
|
|
|
}
|
2021-06-27 22:06:11 +08:00
|
|
|
}
|