第一次

This commit is contained in:
zhangzhan 2024-06-14 15:58:48 +08:00
parent 4a812d1a16
commit 97c6d06a8f
9 changed files with 165 additions and 17 deletions

View File

@ -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<String, dynamic> json) => _$EpgCategoryListBeanFromJson(json);
Map<String, dynamic> toJson() => _$EpgCategoryListBeanToJson(this);
}

View File

@ -0,0 +1,26 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'EpgCategoryListBean.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
EpgCategoryListBean _$EpgCategoryListBeanFromJson(Map<String, dynamic> json) =>
EpgCategoryListBean(
json['CategoryName'] as String?,
json['CategoryType'] as String?,
json['HasMore'] as bool?,
(json['RowNum'] as num?)?.toInt(),
json['IsQuickStartPopUp'] as bool?,
);
Map<String, dynamic> _$EpgCategoryListBeanToJson(
EpgCategoryListBean instance) =>
<String, dynamic>{
'CategoryName': instance.CategoryName,
'CategoryType': instance.CategoryType,
'HasMore': instance.HasMore,
'RowNum': instance.RowNum,
'IsQuickStartPopUp': instance.IsQuickStartPopUp,
};

View File

@ -0,0 +1,20 @@
import 'package:json_annotation/json_annotation.dart';
import 'EpgCategoryListBean.dart';
part 'HallEpgListBean.g.dart';
@JsonSerializable(explicitToJson: true)
class HallEpgListBean {
List<EpgCategoryListBean>? EpgCategoryList;
HallEpgListBean(this.EpgCategoryList);
factory HallEpgListBean.fromJson(Map<String, dynamic> json) => _$HallEpgListBeanFromJson(json);
Map<String, dynamic> toJson() => _$HallEpgListBeanToJson(this);
}

View File

@ -0,0 +1,20 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'HallEpgListBean.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
HallEpgListBean _$HallEpgListBeanFromJson(Map<String, dynamic> json) =>
HallEpgListBean(
(json['EpgCategoryList'] as List<dynamic>?)
?.map((e) => EpgCategoryListBean.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$HallEpgListBeanToJson(HallEpgListBean instance) =>
<String, dynamic>{
'EpgCategoryList':
instance.EpgCategoryList?.map((e) => e.toJson()).toList(),
};

View File

@ -21,9 +21,7 @@ class Global {
}
static Global _getInstance() {
if (_instance == null) {
_instance = new Global._internal();
}
_instance ??= Global._internal();
return _instance!;
}

View File

@ -13,11 +13,11 @@ Future<void> 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<ChatApp> {
@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: <String, WidgetBuilder>{
'/HomePage': (BuildContext context) => Homepage(),
'/HomePage': (BuildContext context) => const Homepage(),
},
debugShowMaterialGrid: false,
//
debugShowCheckedModeBanner: false,

View File

@ -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"; //
}

59
lib/tools/HomeModel.dart Normal file
View File

@ -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<void> getHallEpgList(int type) async {
RequestCenter.instance.request(NetworkConfig.getHallEpgList, {}, (BaseEntity dataEntity) {
//print("BaseEntity" + dataEntity.data.toString());
if (dataEntity.code == 0 && dataEntity.result == 0) {
Map<String, dynamic> 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<String, Object> map) async {
dynamic args;
try {
args = await Global.method.invokeMethod(method, map);
} on PlatformException catch (e) {}
}
}

View File

@ -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