49 lines
1.2 KiB
Dart
Executable File
49 lines
1.2 KiB
Dart
Executable File
import 'package:flutter/foundation.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:translator_lux/dataBase/table/translator_history_table.dart';
|
|
import 'package:translator_lux/entity/translator_history_entity.dart';
|
|
import 'package:translator_lux/page/translator_result/translator_result_view.dart';
|
|
|
|
import 'translator_state.dart';
|
|
|
|
/// @description:
|
|
/// @author
|
|
/// @date: 2024-06-27 13:55:27
|
|
class TranslatorLogic extends GetxController {
|
|
final state = TranslatorState();
|
|
|
|
@override
|
|
onInit() {
|
|
super.onInit();
|
|
initData();
|
|
debugPrint("进来了");
|
|
}
|
|
|
|
@override
|
|
dispose() {
|
|
super.dispose();
|
|
state.historyShowData.clear();
|
|
}
|
|
|
|
initData() async {
|
|
List<TranslatorHistoryEntity> queryShowData =
|
|
await TranslatorHistoryTable.queryShowData();
|
|
state.historyShowData.addAll(queryShowData);
|
|
if (state.historyShowData.isNotEmpty) {
|
|
state.isThereData.value = true;
|
|
}
|
|
}
|
|
|
|
toResult(String value) {
|
|
Get.toNamed(
|
|
TranslatorResultPage.routName,
|
|
arguments: {"translateString": value},
|
|
);
|
|
}
|
|
|
|
cleanAllHistory() {
|
|
TranslatorHistoryTable.cleanAllShowData();
|
|
state.isThereData.value = false;
|
|
}
|
|
}
|