import 'dart:async';

import 'package:get/get.dart';
import 'package:vitalapp/architecture/defines.dart';
import 'package:vitalapp/managers/interfaces/system_setting.dart';
import 'package:vitalapp/store/store.dart';
import 'state.dart';

class SplashController extends FControllerBase {
  final state = SplashState();

  /// 跳转路由
  void onRouteTo() async {
    if (Store.user.isLogOn) {
      Get.offAllNamed("/");
      Store.user.isShowUserCard = true;
    } else {
      Get.offAllNamed("/login");
    }
  }

  /// 加载数据
  Future<void> loadData() async {
    await Future.wait([
      _loadServerSettings(),
      // 其他异步加载项
    ]);
  }

  /// 加载服务配置
  Future<void> _loadServerSettings() async {
    await Get.find<ISystemSettingManager>().getSettings();
  }

  @override
  void onClose() {
    _doDispose();
    super.onClose();
  }

  void _doDispose() {}
}
