mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-22 08:13:42 +08:00
add Party Room Module
This commit is contained in:
parent
71eadd86f5
commit
7240878148
@ -52,7 +52,9 @@ class BaseUIModel extends ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<T?> handleError<T>(Future<T> Function() requestFunc,
|
||||
{bool showFullScreenError = false, String? errorOverride}) async {
|
||||
{bool showFullScreenError = false,
|
||||
String? errorOverride,
|
||||
bool noAlert = false}) async {
|
||||
uiErrorMsg = "";
|
||||
if (mounted) notifyListeners();
|
||||
try {
|
||||
@ -72,7 +74,7 @@ class BaseUIModel extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
return null;
|
||||
}
|
||||
showToast(context!, errorOverride ?? errorMsg);
|
||||
if (!noAlert) showToast(context!, errorOverride ?? errorMsg);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ import 'package:window_manager/window_manager.dart';
|
||||
import '../base/ui.dart';
|
||||
|
||||
class AppConf {
|
||||
static const String appVersion = "2.10.1 Beta";
|
||||
static const String appVersion = "2.11.0 Beta";
|
||||
static const int appVersionCode = 36;
|
||||
static const String appVersionDate = "2023-12-12";
|
||||
static const String appVersionDate = "2024-01-07";
|
||||
|
||||
static const String giteaAttachmentsUrl =
|
||||
"https://git.sctoolbox.sccsgo.com/SCToolBox/Release";
|
||||
|
97
lib/generated/grpc/party_room_server/index.pb.dart
Normal file
97
lib/generated/grpc/party_room_server/index.pb.dart
Normal file
@ -0,0 +1,97 @@
|
||||
//
|
||||
// Generated code. Do not modify.
|
||||
// source: index.proto
|
||||
//
|
||||
// @dart = 2.12
|
||||
|
||||
// ignore_for_file: annotate_overrides, camel_case_types, comment_references
|
||||
// ignore_for_file: constant_identifier_names, library_prefixes
|
||||
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
|
||||
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import
|
||||
|
||||
import 'dart:core' as $core;
|
||||
|
||||
import 'package:fixnum/fixnum.dart' as $fixnum;
|
||||
import 'package:protobuf/protobuf.dart' as $pb;
|
||||
|
||||
class PingData extends $pb.GeneratedMessage {
|
||||
factory PingData({
|
||||
$core.String? data,
|
||||
$fixnum.Int64? clientVersion,
|
||||
$fixnum.Int64? serverVersion,
|
||||
}) {
|
||||
final $result = create();
|
||||
if (data != null) {
|
||||
$result.data = data;
|
||||
}
|
||||
if (clientVersion != null) {
|
||||
$result.clientVersion = clientVersion;
|
||||
}
|
||||
if (serverVersion != null) {
|
||||
$result.serverVersion = serverVersion;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
PingData._() : super();
|
||||
factory PingData.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
|
||||
factory PingData.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
|
||||
|
||||
static final $pb.BuilderInfo _i = $pb.BuilderInfo(_omitMessageNames ? '' : 'PingData', createEmptyInstance: create)
|
||||
..aOS(1, _omitFieldNames ? '' : 'data')
|
||||
..a<$fixnum.Int64>(2, _omitFieldNames ? '' : 'clientVersion', $pb.PbFieldType.OS6, protoName: 'clientVersion', defaultOrMaker: $fixnum.Int64.ZERO)
|
||||
..a<$fixnum.Int64>(3, _omitFieldNames ? '' : 'serverVersion', $pb.PbFieldType.OS6, protoName: 'serverVersion', defaultOrMaker: $fixnum.Int64.ZERO)
|
||||
..hasRequiredFields = false
|
||||
;
|
||||
|
||||
@$core.Deprecated(
|
||||
'Using this can add significant overhead to your binary. '
|
||||
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
|
||||
'Will be removed in next major version')
|
||||
PingData clone() => PingData()..mergeFromMessage(this);
|
||||
@$core.Deprecated(
|
||||
'Using this can add significant overhead to your binary. '
|
||||
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
|
||||
'Will be removed in next major version')
|
||||
PingData copyWith(void Function(PingData) updates) => super.copyWith((message) => updates(message as PingData)) as PingData;
|
||||
|
||||
$pb.BuilderInfo get info_ => _i;
|
||||
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static PingData create() => PingData._();
|
||||
PingData createEmptyInstance() => create();
|
||||
static $pb.PbList<PingData> createRepeated() => $pb.PbList<PingData>();
|
||||
@$core.pragma('dart2js:noInline')
|
||||
static PingData getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<PingData>(create);
|
||||
static PingData? _defaultInstance;
|
||||
|
||||
@$pb.TagNumber(1)
|
||||
$core.String get data => $_getSZ(0);
|
||||
@$pb.TagNumber(1)
|
||||
set data($core.String v) { $_setString(0, v); }
|
||||
@$pb.TagNumber(1)
|
||||
$core.bool hasData() => $_has(0);
|
||||
@$pb.TagNumber(1)
|
||||
void clearData() => clearField(1);
|
||||
|
||||
@$pb.TagNumber(2)
|
||||
$fixnum.Int64 get clientVersion => $_getI64(1);
|
||||
@$pb.TagNumber(2)
|
||||
set clientVersion($fixnum.Int64 v) { $_setInt64(1, v); }
|
||||
@$pb.TagNumber(2)
|
||||
$core.bool hasClientVersion() => $_has(1);
|
||||
@$pb.TagNumber(2)
|
||||
void clearClientVersion() => clearField(2);
|
||||
|
||||
@$pb.TagNumber(3)
|
||||
$fixnum.Int64 get serverVersion => $_getI64(2);
|
||||
@$pb.TagNumber(3)
|
||||
set serverVersion($fixnum.Int64 v) { $_setInt64(2, v); }
|
||||
@$pb.TagNumber(3)
|
||||
$core.bool hasServerVersion() => $_has(2);
|
||||
@$pb.TagNumber(3)
|
||||
void clearServerVersion() => clearField(3);
|
||||
}
|
||||
|
||||
|
||||
const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names');
|
||||
const _omitMessageNames = $core.bool.fromEnvironment('protobuf.omit_message_names');
|
11
lib/generated/grpc/party_room_server/index.pbenum.dart
Normal file
11
lib/generated/grpc/party_room_server/index.pbenum.dart
Normal file
@ -0,0 +1,11 @@
|
||||
//
|
||||
// Generated code. Do not modify.
|
||||
// source: index.proto
|
||||
//
|
||||
// @dart = 2.12
|
||||
|
||||
// ignore_for_file: annotate_overrides, camel_case_types, comment_references
|
||||
// ignore_for_file: constant_identifier_names, library_prefixes
|
||||
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
|
||||
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import
|
||||
|
59
lib/generated/grpc/party_room_server/index.pbgrpc.dart
Normal file
59
lib/generated/grpc/party_room_server/index.pbgrpc.dart
Normal file
@ -0,0 +1,59 @@
|
||||
//
|
||||
// Generated code. Do not modify.
|
||||
// source: index.proto
|
||||
//
|
||||
// @dart = 2.12
|
||||
|
||||
// ignore_for_file: annotate_overrides, camel_case_types, comment_references
|
||||
// ignore_for_file: constant_identifier_names, library_prefixes
|
||||
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
|
||||
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import
|
||||
|
||||
import 'dart:async' as $async;
|
||||
import 'dart:core' as $core;
|
||||
|
||||
import 'package:grpc/service_api.dart' as $grpc;
|
||||
import 'package:protobuf/protobuf.dart' as $pb;
|
||||
|
||||
import 'index.pb.dart' as $0;
|
||||
|
||||
export 'index.pb.dart';
|
||||
|
||||
@$pb.GrpcServiceName('IndexService')
|
||||
class IndexServiceClient extends $grpc.Client {
|
||||
static final _$pingServer = $grpc.ClientMethod<$0.PingData, $0.PingData>(
|
||||
'/IndexService/PingServer',
|
||||
($0.PingData value) => value.writeToBuffer(),
|
||||
($core.List<$core.int> value) => $0.PingData.fromBuffer(value));
|
||||
|
||||
IndexServiceClient($grpc.ClientChannel channel,
|
||||
{$grpc.CallOptions? options,
|
||||
$core.Iterable<$grpc.ClientInterceptor>? interceptors})
|
||||
: super(channel, options: options,
|
||||
interceptors: interceptors);
|
||||
|
||||
$grpc.ResponseFuture<$0.PingData> pingServer($0.PingData request, {$grpc.CallOptions? options}) {
|
||||
return $createUnaryCall(_$pingServer, request, options: options);
|
||||
}
|
||||
}
|
||||
|
||||
@$pb.GrpcServiceName('IndexService')
|
||||
abstract class IndexServiceBase extends $grpc.Service {
|
||||
$core.String get $name => 'IndexService';
|
||||
|
||||
IndexServiceBase() {
|
||||
$addMethod($grpc.ServiceMethod<$0.PingData, $0.PingData>(
|
||||
'PingServer',
|
||||
pingServer_Pre,
|
||||
false,
|
||||
false,
|
||||
($core.List<$core.int> value) => $0.PingData.fromBuffer(value),
|
||||
($0.PingData value) => value.writeToBuffer()));
|
||||
}
|
||||
|
||||
$async.Future<$0.PingData> pingServer_Pre($grpc.ServiceCall call, $async.Future<$0.PingData> request) async {
|
||||
return pingServer(call, await request);
|
||||
}
|
||||
|
||||
$async.Future<$0.PingData> pingServer($grpc.ServiceCall call, $0.PingData request);
|
||||
}
|
30
lib/generated/grpc/party_room_server/index.pbjson.dart
Normal file
30
lib/generated/grpc/party_room_server/index.pbjson.dart
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// Generated code. Do not modify.
|
||||
// source: index.proto
|
||||
//
|
||||
// @dart = 2.12
|
||||
|
||||
// ignore_for_file: annotate_overrides, camel_case_types, comment_references
|
||||
// ignore_for_file: constant_identifier_names, library_prefixes
|
||||
// ignore_for_file: non_constant_identifier_names, prefer_final_fields
|
||||
// ignore_for_file: unnecessary_import, unnecessary_this, unused_import
|
||||
|
||||
import 'dart:convert' as $convert;
|
||||
import 'dart:core' as $core;
|
||||
import 'dart:typed_data' as $typed_data;
|
||||
|
||||
@$core.Deprecated('Use pingDataDescriptor instead')
|
||||
const PingData$json = {
|
||||
'1': 'PingData',
|
||||
'2': [
|
||||
{'1': 'data', '3': 1, '4': 1, '5': 9, '10': 'data'},
|
||||
{'1': 'clientVersion', '3': 2, '4': 1, '5': 18, '10': 'clientVersion'},
|
||||
{'1': 'serverVersion', '3': 3, '4': 1, '5': 18, '10': 'serverVersion'},
|
||||
],
|
||||
};
|
||||
|
||||
/// Descriptor for `PingData`. Decode as a `google.protobuf.DescriptorProto`.
|
||||
final $typed_data.Uint8List pingDataDescriptor = $convert.base64Decode(
|
||||
'CghQaW5nRGF0YRISCgRkYXRhGAEgASgJUgRkYXRhEiQKDWNsaWVudFZlcnNpb24YAiABKBJSDW'
|
||||
'NsaWVudFZlcnNpb24SJAoNc2VydmVyVmVyc2lvbhgDIAEoElINc2VydmVyVmVyc2lvbg==');
|
||||
|
26
lib/grpc/party_room_server.dart
Normal file
26
lib/grpc/party_room_server.dart
Normal file
@ -0,0 +1,26 @@
|
||||
import 'package:fixnum/fixnum.dart';
|
||||
import 'package:grpc/grpc.dart';
|
||||
import 'package:starcitizen_doctor/base/ui.dart';
|
||||
import 'package:starcitizen_doctor/generated/grpc/party_room_server/index.pbgrpc.dart';
|
||||
|
||||
class PartyRoomGrpcServer {
|
||||
static const clientVersion = 0;
|
||||
static final _channel = ClientChannel(
|
||||
"127.0.0.1",
|
||||
port: 39399,
|
||||
options: ChannelOptions(
|
||||
credentials: const ChannelCredentials.insecure(),
|
||||
codecRegistry:
|
||||
CodecRegistry(codecs: const [GzipCodec(), IdentityCodec()]),
|
||||
),
|
||||
);
|
||||
|
||||
static final _indexService = IndexServiceClient(_channel);
|
||||
|
||||
static Future<PingData> pingServer() async {
|
||||
final r = await _indexService.pingServer(PingData(
|
||||
data: "PING", clientVersion: Int64.parseInt(clientVersion.toString())));
|
||||
dPrint(r.writeToJson());
|
||||
return r;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import 'package:starcitizen_doctor/main.dart';
|
||||
import 'package:starcitizen_doctor/ui/about/about_ui.dart';
|
||||
import 'package:starcitizen_doctor/ui/about/about_ui_model.dart';
|
||||
import 'package:starcitizen_doctor/ui/home/home_ui.dart';
|
||||
import 'package:starcitizen_doctor/ui/party_room/party_room_home_ui_model.dart';
|
||||
import 'package:starcitizen_doctor/ui/settings/settings_ui.dart';
|
||||
import 'package:starcitizen_doctor/ui/settings/settings_ui_model.dart';
|
||||
import 'package:starcitizen_doctor/ui/tools/tools_ui.dart';
|
||||
@ -12,6 +13,7 @@ import 'package:window_manager/window_manager.dart';
|
||||
|
||||
import 'home/home_ui_model.dart';
|
||||
import 'index_ui_model.dart';
|
||||
import 'party_room/party_room_home_ui.dart';
|
||||
|
||||
class IndexUI extends BaseUI<IndexUIModel> {
|
||||
@override
|
||||
@ -67,16 +69,21 @@ class IndexUI extends BaseUI<IndexUIModel> {
|
||||
modelCreate: () =>
|
||||
model.getChildUIModelProviders<HomeUIModel>("home"));
|
||||
case 1:
|
||||
return BaseUIContainer(
|
||||
uiCreate: () => PartyRoomHomeUI(),
|
||||
modelCreate: () =>
|
||||
model.getChildUIModelProviders<PartyRoomHomeUIModel>("party"));
|
||||
case 2:
|
||||
return BaseUIContainer(
|
||||
uiCreate: () => ToolsUI(),
|
||||
modelCreate: () =>
|
||||
model.getChildUIModelProviders<ToolsUIModel>("tools"));
|
||||
case 2:
|
||||
case 3:
|
||||
return BaseUIContainer(
|
||||
uiCreate: () => SettingUI(),
|
||||
modelCreate: () =>
|
||||
model.getChildUIModelProviders<SettingUIModel>("settings"));
|
||||
case 3:
|
||||
case 4:
|
||||
return BaseUIContainer(
|
||||
uiCreate: () => AboutUI(),
|
||||
modelCreate: () =>
|
||||
@ -88,6 +95,7 @@ class IndexUI extends BaseUI<IndexUIModel> {
|
||||
List<NavigationPaneItem> getNavigationPaneItems(IndexUIModel model) {
|
||||
final menus = {
|
||||
FluentIcons.home: "首页",
|
||||
FluentIcons.game: "大厅",
|
||||
FluentIcons.toolbox: "工具",
|
||||
FluentIcons.settings: "设置",
|
||||
FluentIcons.info: "关于",
|
||||
|
@ -10,6 +10,8 @@ import 'package:starcitizen_doctor/ui/settings/settings_ui_model.dart';
|
||||
import 'package:starcitizen_doctor/ui/tools/tools_ui_model.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import 'party_room/party_room_home_ui_model.dart';
|
||||
|
||||
class IndexUIModel extends BaseUIModel {
|
||||
int curIndex = 0;
|
||||
|
||||
@ -32,6 +34,8 @@ class IndexUIModel extends BaseUIModel {
|
||||
return SettingUIModel();
|
||||
case "about":
|
||||
return AboutUIModel();
|
||||
case "party":
|
||||
return PartyRoomHomeUIModel();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -39,9 +43,10 @@ class IndexUIModel extends BaseUIModel {
|
||||
void onIndexMenuTap(String value) {
|
||||
final index = {
|
||||
"首页": 0,
|
||||
"工具": 1,
|
||||
"设置": 2,
|
||||
"关于": 3,
|
||||
"大厅": 1,
|
||||
"工具": 2,
|
||||
"设置": 3,
|
||||
"关于": 4,
|
||||
};
|
||||
curIndex = index[value] ?? 0;
|
||||
switch (curIndex) {
|
||||
@ -49,9 +54,12 @@ class IndexUIModel extends BaseUIModel {
|
||||
getCreatedChildUIModel("home")?.reloadData();
|
||||
break;
|
||||
case 1:
|
||||
getCreatedChildUIModel("tools")?.reloadData();
|
||||
getCreatedChildUIModel("party")?.reloadData();
|
||||
break;
|
||||
case 2:
|
||||
getCreatedChildUIModel("tools")?.reloadData();
|
||||
break;
|
||||
case 3:
|
||||
getCreatedChildUIModel("settings")?.reloadData();
|
||||
break;
|
||||
}
|
||||
|
22
lib/ui/party_room/party_room_home_ui.dart
Normal file
22
lib/ui/party_room/party_room_home_ui.dart
Normal file
@ -0,0 +1,22 @@
|
||||
import 'package:starcitizen_doctor/base/ui.dart';
|
||||
|
||||
import 'party_room_home_ui_model.dart';
|
||||
|
||||
class PartyRoomHomeUI extends BaseUI<PartyRoomHomeUIModel> {
|
||||
@override
|
||||
Widget? buildBody(BuildContext context, PartyRoomHomeUIModel model) {
|
||||
if (model.pingServerMessage == null) return makeLoading(context);
|
||||
if (model.pingServerMessage!.isNotEmpty) {
|
||||
return Center(
|
||||
child: Text("${model.pingServerMessage}"),
|
||||
);
|
||||
}
|
||||
return Center(
|
||||
child: Text("PartyRoom"),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String getUITitle(BuildContext context, PartyRoomHomeUIModel model) =>
|
||||
"PartyRoom";
|
||||
}
|
29
lib/ui/party_room/party_room_home_ui_model.dart
Normal file
29
lib/ui/party_room/party_room_home_ui_model.dart
Normal file
@ -0,0 +1,29 @@
|
||||
import 'package:starcitizen_doctor/base/ui_model.dart';
|
||||
import 'package:starcitizen_doctor/grpc/party_room_server.dart';
|
||||
|
||||
class PartyRoomHomeUIModel extends BaseUIModel {
|
||||
String? pingServerMessage;
|
||||
|
||||
@override
|
||||
Future loadData() async {
|
||||
if (pingServerMessage != "") {
|
||||
pingServerMessage = null;
|
||||
notifyListeners();
|
||||
}
|
||||
await _pingServer();
|
||||
}
|
||||
|
||||
_pingServer() async {
|
||||
try {
|
||||
final r = await PartyRoomGrpcServer.pingServer();
|
||||
dPrint(
|
||||
"[PartyRoomHomeUIModel] Connected! serverVersion ==> ${r.serverVersion}");
|
||||
pingServerMessage = "";
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
pingServerMessage = "服务器连接失败,请稍后重试。\n$e";
|
||||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -66,6 +66,9 @@ dependencies:
|
||||
dart_rss: ^3.0.1
|
||||
html: ^0.15.4
|
||||
xml: ^6.5.0
|
||||
fixnum: ^1.1.0
|
||||
protobuf: ^3.1.0
|
||||
grpc: ^3.2.4
|
||||
|
||||
dependency_overrides:
|
||||
http: ^1.1.2
|
||||
@ -81,7 +84,7 @@ dev_dependencies:
|
||||
# rules and activating additional ones.
|
||||
flutter_lints: ^3.0.0
|
||||
msix: ^3.16.4
|
||||
ffigen: ^10.0.0
|
||||
ffigen: ^11.0.0
|
||||
build_runner: ^2.4.6
|
||||
freezed: ^2.4.5
|
||||
|
||||
|
1
update_grpc.bat
Normal file
1
update_grpc.bat
Normal file
@ -0,0 +1 @@
|
||||
protoc --dart_out=grpc:lib/generated/grpc/party_room_server -I../party_room_server/protos/ ../party_room_server/protos/*.proto
|
Loading…
Reference in New Issue
Block a user