import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:get/get.dart';
import 'package:ln_jq_app/pages/home/view.dart';
import 'package:ln_jq_app/pages/login/view.dart';
import 'package:ln_jq_app/storage_service.dart';

class WelcomeController extends GetxController {
  @override
  void onReady() {
    super.onReady();
    // 移除原生闪屏页（如果有的话）
    FlutterNativeSplash.remove();
    _startTimer();
  }

  void _startTimer() {
    // 1.5秒后执行跳转逻辑
    Future.delayed(const Duration(milliseconds: 1500), () {
      Get.offAll(() => const HomePage());
    });
  }

  void _jumpToNextPage() {
    if (StorageService.to.isLoggedIn) {
      // 已登录，跳转到首页
      Get.offAll(() => const HomePage());
    } else {
      // 未登录，跳转到登录页
      Get.offAll(() => const LoginPage());
    }
  }
}
