feat: UnP4kc fix missing runtime

close https://github.com/StarCitizenToolBox/app/issues/27
This commit is contained in:
xkeyC 2024-05-06 20:21:35 +08:00
parent b965c6262f
commit 34d1007e30
3 changed files with 49 additions and 23 deletions

View File

@ -9,6 +9,7 @@ import 'package:re_highlight/styles/vs2015.dart';
import 'package:starcitizen_doctor/data/app_advanced_localization_data.dart';
import 'package:starcitizen_doctor/ui/home/home_ui_model.dart';
import 'package:starcitizen_doctor/ui/home/localization/advanced_localization_ui_model.dart';
import 'package:starcitizen_doctor/ui/tools/unp4kc/unp4kc_ui.dart';
import 'package:starcitizen_doctor/widgets/widgets.dart';
import 'package:super_sliver_list/super_sliver_list.dart';
@ -51,11 +52,8 @@ class AdvancedLocalizationUI extends HookConsumerWidget {
: Column(
children: [
if (state.errorMessage.isNotEmpty)
Padding(
padding: const EdgeInsets.all(32),
child: Center(
child: Text(state.errorMessage),
),
UnP4kErrorWidget(
errorMessage: state.errorMessage,
)
else ...[
Row(

View File

@ -594,18 +594,6 @@ class ToolsUIModel extends _$ToolsUIModel {
}
static rsiEnhance(BuildContext context) async {
final userOK = await showConfirmDialogs(
context,
S.current.tools_rsi_launcher_enhance_note_title,
Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(S.current.tools_rsi_launcher_enhance_note_msg),
],
),
constraints:
BoxConstraints(maxWidth: MediaQuery.of(context).size.width * .55));
if (!userOK) return;
if ((await SystemHelper.getPID("\"RSI Launcher\"")).isNotEmpty) {
if (!context.mounted) return;
showToast(

View File

@ -10,6 +10,7 @@ import 'package:starcitizen_doctor/data/app_unp4k_p4k_item_data.dart';
import 'package:starcitizen_doctor/provider/unp4kc.dart';
import 'package:starcitizen_doctor/widgets/widgets.dart';
import 'package:super_sliver_list/super_sliver_list.dart';
import 'package:url_launcher/url_launcher_string.dart';
class UnP4kcUI extends HookConsumerWidget {
const UnP4kcUI({super.key});
@ -29,12 +30,7 @@ class UnP4kcUI extends HookConsumerWidget {
Widget makeBody(BuildContext context, Unp4kcState state, Unp4kCModel model,
List<AppUnp4kP4kItemData>? files, List<String> paths) {
if (state.errorMessage.isNotEmpty) {
return Padding(
padding: const EdgeInsets.all(24),
child: Center(
child: Text(state.errorMessage),
),
);
return UnP4kErrorWidget(errorMessage: state.errorMessage);
}
return state.files == null
? Column(
@ -282,3 +278,47 @@ class _TextTempWidget extends HookConsumerWidget {
);
}
}
class UnP4kErrorWidget extends StatelessWidget {
final String errorMessage;
const UnP4kErrorWidget({super.key, required this.errorMessage});
static const _downloadUrl =
"https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=win-x64&os=win10&apphost_version=8.0.0";
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(24),
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
if (errorMessage.contains(
"You must install .NET to run this application") ||
errorMessage.contains(
"You must install or update .NET to run this application")) ...[
const Text(
"缺少运行库",
style: TextStyle(fontSize: 16),
),
const SizedBox(height: 6),
const Text("使用此功能需安装 .NET8 运行库,请点击下方按钮下载安装,安装成功后重新打开此页面即可继续使用。"),
const SizedBox(height: 16),
FilledButton(
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 3),
child: Text("安装运行库"),
),
onPressed: () {
launchUrlString(_downloadUrl);
}),
] else
Text(errorMessage),
],
),
),
);
}
}