From 8db2766c19fc3a837887bf13cb814cb933088b41 Mon Sep 17 00:00:00 2001 From: xkeyC <3334969096@qq.com> Date: Sun, 29 Oct 2023 17:10:39 +0800 Subject: [PATCH] fix --- lib/common/helper/system_helper.dart | 6 ++++++ lib/ui/tools/downloader/downloader_dialog_ui_model.dart | 2 +- lib/ui/tools/tools_ui_model.dart | 9 +++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/common/helper/system_helper.dart b/lib/common/helper/system_helper.dart index eb69ccc..1c3137d 100644 --- a/lib/common/helper/system_helper.dart +++ b/lib/common/helper/system_helper.dart @@ -129,6 +129,12 @@ class SystemHelper { return r.stdout.toString().trim(); } + static Future getCpuName() async { + final r = await Process.run( + "powershell", ["(Get-WmiObject -Class Win32_Processor).Name"]); + return r.stdout.toString().trim(); + } + static Future getGpuInfo() async { const cmd = r""" $adapterMemory = (Get-ItemProperty -Path "HKLM:\SYSTEM\ControlSet001\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\0*" -Name "HardwareInformation.AdapterString", "HardwareInformation.qwMemorySize" -Exclude PSPath -ErrorAction SilentlyContinue) diff --git a/lib/ui/tools/downloader/downloader_dialog_ui_model.dart b/lib/ui/tools/downloader/downloader_dialog_ui_model.dart index 20b6bba..6613dde 100644 --- a/lib/ui/tools/downloader/downloader_dialog_ui_model.dart +++ b/lib/ui/tools/downloader/downloader_dialog_ui_model.dart @@ -84,7 +84,7 @@ class DownloaderDialogUIModel extends BaseUIModel { } } catch (e) { if (e is DioException && e.type != DioExceptionType.cancel) { - if (mounted) showToast(context!, "下载失败:$e"); + Navigator.pop(context!, e); } } } diff --git a/lib/ui/tools/tools_ui_model.dart b/lib/ui/tools/tools_ui_model.dart index 43ff85e..37daed4 100644 --- a/lib/ui/tools/tools_ui_model.dart +++ b/lib/ui/tools/tools_ui_model.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'dart:io'; +import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:starcitizen_doctor/base/ui_model.dart'; @@ -33,6 +34,7 @@ class ToolsUIModel extends BaseUIModel { @override Future loadData({bool skipPathScan = false}) async { + if (isItemLoading) return; items.clear(); notifyListeners(); if (!skipPathScan) { @@ -244,7 +246,7 @@ class ToolsUIModel extends BaseUIModel { Future getSystemInfo() async { return "系统:${await SystemHelper.getSystemName()}\n\n" - "处理器:${await SystemHelper.getSystemCimInstance("Win32_Processor")}\n\n" + "处理器:${await SystemHelper.getCpuName()}\n\n" "内存大小:${await SystemHelper.getSystemMemorySizeGB()}GB\n\n" "显卡信息:\n${await SystemHelper.getGpuInfo()}\n\n" "硬盘信息:\n${await SystemHelper.getDiskInfo()}\n\n"; @@ -359,8 +361,11 @@ class ToolsUIModel extends BaseUIModel { if (r != null) { if (r == "cancel") { return showToast(context!, "下载已取消,下载进度已保留,如果您无需恢复下载,请手动删除下载临时文件。"); + } else if (r is DioException) { + showToast(context!, "下载失败:$r"); + } else { + showToast(context!, "下载完毕,文件已保存到:$r"); } - showToast(context!, "下载完毕,文件已保存到:$r"); } } }