feat: 新增 Hosts 写入功能,通过预设的干净 DNS 获取ip 并 写入 hosts 文件

This commit is contained in:
2024-03-12 22:08:46 +08:00
parent 26b58324c4
commit cb924f267c
5 changed files with 321 additions and 3 deletions

View File

@ -22,6 +22,8 @@ import 'package:starcitizen_doctor/widgets/widgets.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:xml/xml.dart';
import 'dialogs/hosts_booster_dialog_ui.dart';
part 'tools_ui_model.g.dart';
part 'tools_ui_model.freezed.dart';
@ -81,6 +83,13 @@ class ToolsUIModel extends _$ToolsUIModel {
const Icon(FontAwesomeIcons.download, size: 28),
onTap: () => _downloadP4k(context),
),
ToolsItemData(
"hosts_booster",
"Hosts 加速",
"将 IP 信息写入 Hosts 文件,解决部分地区的 DNS 污染导致无法登录官网等问题。",
const Icon(FluentIcons.virtual_network, size: 28),
onTap: () => _doHostsBooster(context),
),
ToolsItemData(
"reinstall_eac",
"重装 EasyAntiCheat 反作弊",
@ -549,4 +558,10 @@ class ToolsUIModel extends _$ToolsUIModel {
void onChangeLauncherPath(String s) {
state = state.copyWith(rsiLauncherInstalledPath: s);
}
_doHostsBooster(BuildContext context) async {
showDialog(
context: context,
builder: (BuildContext context) => const HostsBoosterDialogUI());
}
}