10 changed files with 295 additions and 87 deletions
@ -0,0 +1,13 @@ |
|||||||
|
|
||||||
|
获取记录:| |
||||||
|
<M>[获取记录][{{tableName}}({{keyName}}) |
||||||
|
][ |
||||||
|
{{#keyFields}} |
||||||
|
{{.}} = @{{.}}{{^@last}}, {{/@last}} |
||||||
|
{{/keyFields}} |
||||||
|
] |
||||||
|
[继续执行] |
||||||
|
[记录为空][{{tableName}}] |
||||||
|
{ |
||||||
|
[报错返回][][{{#keyFields}}{{.}} = @{{.}}{{^@last}}, {{/@last}}{{/keyFields}}] |
||||||
|
} |
@ -0,0 +1,51 @@ |
|||||||
|
import 'package:flutter/services.dart' show rootBundle; |
||||||
|
import 'package:yaml/yaml.dart'; |
||||||
|
|
||||||
|
class UftMacroService { |
||||||
|
static final UftMacroService _instance = UftMacroService._internal(); |
||||||
|
factory UftMacroService() => _instance; |
||||||
|
UftMacroService._internal(); |
||||||
|
|
||||||
|
late Map<String, dynamic> _config; |
||||||
|
|
||||||
|
static bool _isInitialized = false; |
||||||
|
|
||||||
|
// 初始化配置 |
||||||
|
Future<void> init() async { |
||||||
|
if (_isInitialized) return; |
||||||
|
final configString = await rootBundle.loadString('assets/config/uft_macro_list.yaml'); |
||||||
|
final yamlMap = loadYaml(configString) as YamlMap; |
||||||
|
|
||||||
|
final globalConfig = yamlMap['global'] as YamlMap? ?? {}; |
||||||
|
|
||||||
|
_config = {...globalConfig}; |
||||||
|
|
||||||
|
_isInitialized = true; |
||||||
|
} |
||||||
|
|
||||||
|
// 获取配置值 |
||||||
|
dynamic get(String key) { |
||||||
|
return _config[key]; |
||||||
|
} |
||||||
|
|
||||||
|
// 获取字符串值 |
||||||
|
String getString(String key) { |
||||||
|
return _config[key] as String; |
||||||
|
} |
||||||
|
|
||||||
|
// 获取布尔值 |
||||||
|
bool getBool(String key) { |
||||||
|
return _config[key] as bool; |
||||||
|
} |
||||||
|
|
||||||
|
// 获取整数 |
||||||
|
int getInt(String key) { |
||||||
|
return _config[key] as int; |
||||||
|
} |
||||||
|
|
||||||
|
// 获取列表 |
||||||
|
List<T> getList<T>(String key) { |
||||||
|
final list = _config[key] as List; |
||||||
|
return list.cast<T>(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
import 'package:win_text_editor/modules/memory_table/controllers/base_data_source.dart'; |
||||||
|
|
||||||
|
class Field implements SelectableItem { |
||||||
|
Field(this.id, this.name, this.chineseName, this.type, [this.isSelected = false]); |
||||||
|
|
||||||
|
final String id; |
||||||
|
final String name; |
||||||
|
final String chineseName; |
||||||
|
final String type; |
||||||
|
@override |
||||||
|
bool isSelected; |
||||||
|
} |
||||||
|
|
||||||
|
// 索引数据模型 |
||||||
|
class Index implements SelectableItem { |
||||||
|
Index(this.indexName, this.isPrimary, this.indexFields, this.rule, [this.isSelected = false]); |
||||||
|
|
||||||
|
final String indexName; |
||||||
|
final bool isPrimary; |
||||||
|
final String indexFields; |
||||||
|
final String rule; |
||||||
|
@override |
||||||
|
bool isSelected; |
||||||
|
|
||||||
|
List<String> get fields => indexFields.split(',').map((e) => e.trim()).toList(); |
||||||
|
} |
||||||
|
|
||||||
|
class MemoryTable { |
||||||
|
final String tableName; |
||||||
|
final List<Field> columns; |
||||||
|
final List<Index> indexes; |
||||||
|
|
||||||
|
MemoryTable({required this.tableName, required this.columns, required this.indexes}); |
||||||
|
} |
Loading…
Reference in new issue