You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.4 KiB
81 lines
2.4 KiB
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
import 'package:get_storage/get_storage.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'core/bindings/initial_binding.dart';
|
|
import 'core/routes/app_pages.dart';
|
|
import 'core/routes/app_routes.dart';
|
|
import 'dart:io';
|
|
import 'package:window_size/window_size.dart';
|
|
import 'app/translations/app_translations.dart';
|
|
import 'data/services/voice_interaction_service.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
// 设置窗口大小(仅在 macOS 下生效)
|
|
if (Platform.isMacOS) {
|
|
const double width = 375.0;
|
|
const double height = 812.0;
|
|
|
|
setWindowTitle('Deep Voice');
|
|
setWindowMinSize(const Size(width, height));
|
|
setWindowMaxSize(const Size(width, height));
|
|
|
|
// 居中显示窗口
|
|
getCurrentScreen().then((screen) {
|
|
if (screen != null) {
|
|
final screenFrame = screen.frame;
|
|
final windowFrame = Rect.fromCenter(
|
|
center: screenFrame.center,
|
|
width: width,
|
|
height: height,
|
|
);
|
|
setWindowFrame(windowFrame);
|
|
}
|
|
});
|
|
}
|
|
|
|
// 初始化环境变量
|
|
await dotenv.load();
|
|
|
|
// 初始化存储
|
|
await GetStorage.init();
|
|
|
|
// AudioService 将在 AudioServiceManager 中初始化
|
|
// 不再需要在这里调用 AudioService.init
|
|
|
|
runApp(const MainApp());
|
|
}
|
|
|
|
class MainApp extends StatelessWidget {
|
|
const MainApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ScreenUtilInit(
|
|
designSize: const Size(375, 812),
|
|
minTextAdapt: true,
|
|
splitScreenMode: true,
|
|
builder: (_, child) {
|
|
return GetMaterialApp(
|
|
title: 'Deep Voice',
|
|
theme: ThemeData(
|
|
primarySwatch: Colors.blue,
|
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
|
),
|
|
initialBinding: InitialBinding(),
|
|
initialRoute: Routes.initial,
|
|
getPages: AppPages.pages,
|
|
debugShowCheckedModeBanner: false,
|
|
translations: AppTranslations(),
|
|
locale: const Locale('zh', 'CN'),
|
|
fallbackLocale: const Locale('en', 'US'),
|
|
// 注意:VoiceInteractionService 在 HomeController 的 onInit 方法中初始化
|
|
// 不要在这里重复初始化,以避免多次注册事件监听器
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|