diff --git a/lib/beans/EpgCategoryListBean.dart b/lib/beans/EpgCategoryListBean.dart new file mode 100644 index 0000000..6d161af --- /dev/null +++ b/lib/beans/EpgCategoryListBean.dart @@ -0,0 +1,24 @@ + +import 'package:json_annotation/json_annotation.dart'; + + +part 'EpgCategoryListBean.g.dart'; + +@JsonSerializable(explicitToJson: true) +class EpgCategoryListBean { + + String? CategoryName; + String? CategoryType; + bool? HasMore; + int? RowNum; + bool? IsQuickStartPopUp; + + + EpgCategoryListBean(this.CategoryName, this.CategoryType, this.HasMore, + this.RowNum, this.IsQuickStartPopUp, ); + + factory EpgCategoryListBean.fromJson(Map json) => _$EpgCategoryListBeanFromJson(json); + + Map toJson() => _$EpgCategoryListBeanToJson(this); + +} diff --git a/lib/beans/EpgCategoryListBean.g.dart b/lib/beans/EpgCategoryListBean.g.dart new file mode 100644 index 0000000..e5ab3cb --- /dev/null +++ b/lib/beans/EpgCategoryListBean.g.dart @@ -0,0 +1,26 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'EpgCategoryListBean.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +EpgCategoryListBean _$EpgCategoryListBeanFromJson(Map json) => + EpgCategoryListBean( + json['CategoryName'] as String?, + json['CategoryType'] as String?, + json['HasMore'] as bool?, + (json['RowNum'] as num?)?.toInt(), + json['IsQuickStartPopUp'] as bool?, + ); + +Map _$EpgCategoryListBeanToJson( + EpgCategoryListBean instance) => + { + 'CategoryName': instance.CategoryName, + 'CategoryType': instance.CategoryType, + 'HasMore': instance.HasMore, + 'RowNum': instance.RowNum, + 'IsQuickStartPopUp': instance.IsQuickStartPopUp, + }; diff --git a/lib/beans/HallEpgListBean.dart b/lib/beans/HallEpgListBean.dart new file mode 100644 index 0000000..f73f048 --- /dev/null +++ b/lib/beans/HallEpgListBean.dart @@ -0,0 +1,20 @@ + +import 'package:json_annotation/json_annotation.dart'; + +import 'EpgCategoryListBean.dart'; + +part 'HallEpgListBean.g.dart'; + +@JsonSerializable(explicitToJson: true) +class HallEpgListBean { + + + List? EpgCategoryList; + + HallEpgListBean(this.EpgCategoryList); + + + factory HallEpgListBean.fromJson(Map json) => _$HallEpgListBeanFromJson(json); + Map toJson() => _$HallEpgListBeanToJson(this); + +} diff --git a/lib/beans/HallEpgListBean.g.dart b/lib/beans/HallEpgListBean.g.dart new file mode 100644 index 0000000..0690b2f --- /dev/null +++ b/lib/beans/HallEpgListBean.g.dart @@ -0,0 +1,20 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'HallEpgListBean.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +HallEpgListBean _$HallEpgListBeanFromJson(Map json) => + HallEpgListBean( + (json['EpgCategoryList'] as List?) + ?.map((e) => EpgCategoryListBean.fromJson(e as Map)) + .toList(), + ); + +Map _$HallEpgListBeanToJson(HallEpgListBean instance) => + { + 'EpgCategoryList': + instance.EpgCategoryList?.map((e) => e.toJson()).toList(), + }; diff --git a/lib/common/Global.dart b/lib/common/Global.dart index 9fcb8dd..219ca1d 100644 --- a/lib/common/Global.dart +++ b/lib/common/Global.dart @@ -21,9 +21,7 @@ class Global { } static Global _getInstance() { - if (_instance == null) { - _instance = new Global._internal(); - } + _instance ??= Global._internal(); return _instance!; } diff --git a/lib/main.dart b/lib/main.dart index ae02769..30d23e8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -13,11 +13,11 @@ Future main() async { await runZonedGuarded(() async { WidgetsFlutterBinding.ensureInitialized(); Global.initialize().then((e) { - new Global(); - runApp(ChatApp()); + Global(); + runApp(const ChatApp()); if (Platform.isAndroid) { // 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后,是为了在渲染后进行set赋值,覆盖状态栏,写在渲染之前MaterialApp组件会覆盖掉这个值。 - SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(statusBarColor: Colors.transparent); + SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(statusBarColor: Colors.transparent); SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle); } }); @@ -35,26 +35,21 @@ class ChatApp extends StatefulWidget { class _ChatAppState extends State { - - @override void initState() { // TODO: implement initState super.initState(); - print("666666"); } @override Widget build(BuildContext context) { return MaterialApp( title: 'AI聊天', - home: Homepage(), - + home: const Homepage(), //注册路由 routes: { - '/HomePage': (BuildContext context) => Homepage(), + '/HomePage': (BuildContext context) => const Homepage(), }, - debugShowMaterialGrid: false, //显示网格 debugShowCheckedModeBanner: false, diff --git a/lib/network/NetworkConfig.dart b/lib/network/NetworkConfig.dart index 11d3d44..aa0d24c 100644 --- a/lib/network/NetworkConfig.dart +++ b/lib/network/NetworkConfig.dart @@ -9,13 +9,13 @@ class NetworkConfig { static int SELECT_INDEX = 0; static List BASE_URLS = [ - "http://127.0.0.1:7860/", - "http://127.0.0.1:7860/", - "http://127.0.0.1:7860/", + "http://117.50.182.144:5000/", + "http://117.50.182.144:5000/", + "http://117.50.182.144:5000/", ]; static List BASE_URLS_AI = [ - "http://127.0.0.1:7860/", + "http://117.50.182.144:5000/", ]; @@ -35,4 +35,6 @@ class NetworkConfig { static const String login = "login"; //登录 + static const String getHallEpgList = "/api/Epg/GetHallEpgList.ashx"; //获取大厅数据 + } diff --git a/lib/tools/HomeModel.dart b/lib/tools/HomeModel.dart new file mode 100644 index 0000000..fa9523b --- /dev/null +++ b/lib/tools/HomeModel.dart @@ -0,0 +1,59 @@ + +import 'dart:async'; +import 'dart:convert'; +import 'package:flutter/services.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import '../beans/HallEpgListBean.dart'; +import '../common/Global.dart'; +import '../network/BaseEntity.dart'; +import '../network/NetworkConfig.dart'; +import '../network/RequestCenter.dart'; + +class HomeModel { + StreamController streamController = StreamController.broadcast(); + + HomeModel() { + setup(); + } + + void setup() { + //初始化 + } + + //首页大厅数据 + Future getHallEpgList(int type) async { + RequestCenter.instance.request(NetworkConfig.getHallEpgList, {}, (BaseEntity dataEntity) { + //print("BaseEntity" + dataEntity.data.toString()); + if (dataEntity.code == 0 && dataEntity.result == 0) { + Map json = jsonDecode(dataEntity.data); + HallEpgListBean data = HallEpgListBean.fromJson(json); + streamController.sink.add({ + 'code': "1", //有数据 + 'data': data, + }); + } else { + streamController.sink.add({ + 'code': "-1", // + 'data': dataEntity.message, + }); + } + }, (ErrorEntity errorEntity) { + streamController.sink.add({ + 'code': "0", //无数据 + 'data': errorEntity.message, + }); + }); + } + + + + + // 获取原生的值 + invokeNativeMethod(String method, Map map) async { + dynamic args; + try { + args = await Global.method.invokeMethod(method, map); + } on PlatformException catch (e) {} + } +} diff --git a/pubspec.yaml b/pubspec.yaml index b88b744..63a5555 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -35,6 +35,8 @@ dependencies: cupertino_icons: ^1.0.6 flutter_easyloading: ^3.0.5 crypto: ^3.0.3 + shared_preferences: ^2.0.7 + json_annotation: ^4.9.0 dev_dependencies: flutter_test: @@ -46,6 +48,8 @@ dev_dependencies: # package. See that file for information about deactivating specific lint # rules and activating additional ones. flutter_lints: ^3.0.0 + build_runner: ^2.4.11 + json_serializable: ^6.8.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec