12345678910111213141516171819202122232425262728293031323334353637383940 |
- /*
- - GEOSITE,geolocation-!cn,proxy
- - GEOSITE,cn,DIRECT
- - GEOIP,CN,DIRECT
- - MATCH,proxy
- */
- class Rule {
- final String type;
- final String? condition;
- final String action;
- Rule({
- required this.type,
- this.condition,
- required this.action,
- });
- factory Rule.fromMap(Map<String, dynamic> map) {
- return Rule(
- type: map['type'],
- condition: map['condition'],
- action: map['action'],
- );
- }
- Map<String, dynamic> toJson() {
- return {
- 'type': type,
- 'condition': condition,
- 'action': action,
- };
- }
- String toYaml() {
- // 当 condition 不为空时,包括 condition,否则省略 condition
- String conditionPart = condition != null ? ',$condition' : '';
- return ' - $type$conditionPart,$action';
- }
- }
|