12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import 'package:get/get.dart';
- import 'package:vitalapp/architecture/defines.dart';
- import 'package:vitalapp/architecture/utils/prompt_box.dart';
- import 'package:vitalapp/managers/interfaces/account.dart';
- import 'package:vitalapp/rpc.dart';
- import 'package:vitalapp/store/store.dart';
- import 'state.dart';
- class SettingsController extends FControllerBase {
- final state = SettingsState();
- void onSubmit() async {
- try {
- final uri = Uri.parse(state.gateway);
- rpc.setServerHost("${uri.host}:${uri.port}", uri.scheme == 'https');
- rpc.clearCache();
- PromptBox.success("保存成功");
- } catch (e) {
- PromptBox.error("保存失败");
- }
- }
- /// 登出
- Future<void> logOut() async {
- final result = await Get.find<IAccountManager>().logout();
- if (result) {
- Store.user.currentSelectPatientInfo = null;
- Get.offAllNamed("/login");
- }
- }
- @override
- void onInit() {
- state.gateway = rpc.currentHostAddress;
- state.version = "2.0.0";
- super.onInit();
- }
- @override
- void onReady() {
- //
- super.onReady();
- }
- @override
- void onClose() {
- _doDispose();
- super.onClose();
- }
- void _doDispose() {}
- }
|