diff --git a/lib/common/conf.dart b/lib/common/conf.dart index 112827f..f9d2d99 100644 --- a/lib/common/conf.dart +++ b/lib/common/conf.dart @@ -16,8 +16,8 @@ import 'package:window_manager/window_manager.dart'; import '../base/ui.dart'; class AppConf { - static const String appVersion = "2.9.10 Beta"; - static const int appVersionCode = 25; + static const String appVersion = "2.9.12 Beta"; + static const int appVersionCode = 27; static const String appVersionDate = "2023-11-03"; static const String gitlabHomeUrl = @@ -46,9 +46,6 @@ class AppConf { static const isMSE = String.fromEnvironment("MSE", defaultValue: "false") == "true"; - static final launchHelperPath = - "${AppConf.applicationSupportDir}\\launch_helper.vbs"; - static init(List args) async { dPrint("launch args == $args"); WidgetsFlutterBinding.ensureInitialized(); diff --git a/lib/common/helper/system_helper.dart b/lib/common/helper/system_helper.dart index a25c117..917e042 100644 --- a/lib/common/helper/system_helper.dart +++ b/lib/common/helper/system_helper.dart @@ -1,6 +1,5 @@ import 'dart:io'; -import 'package:starcitizen_doctor/common/conf.dart'; import 'package:starcitizen_doctor/common/utils/base_utils.dart'; class SystemHelper { @@ -198,24 +197,4 @@ foreach ($adapter in $adapterMemory) { } catch (_) {} return totalSize; } - - static initVBS() async { - final script = ''' -If Not WScript.Arguments.Named.Exists("elevate") Then - CreateObject("Shell.Application").ShellExecute WScript.FullName _ - , """" & WScript.ScriptFullName & """ /elevate", "", "runas", 1 - WScript.Quit - End If -Dim objShell -Set objShell = WScript.CreateObject( "WScript.Shell" ) -objShell.Run("""${Platform.resolvedExecutable}""") -Set objShell = Nothing - '''; - final vbsFile = File(AppConf.launchHelperPath); - if (await vbsFile.exists()) { - await vbsFile.delete(); - } - await vbsFile.create(); - await vbsFile.writeAsString(script); - } } diff --git a/lib/global_ui_model.dart b/lib/global_ui_model.dart index c8240c4..9811ecc 100644 --- a/lib/global_ui_model.dart +++ b/lib/global_ui_model.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:hive/hive.dart'; import 'package:starcitizen_doctor/common/helper/log_helper.dart'; import 'api/api.dart'; @@ -70,9 +71,14 @@ class AppGlobalUIModel extends BaseUIModel { } _runAsAdmin() async { - await SystemHelper.initVBS(); - await Process.run( - SystemHelper.powershellPath, [AppConf.launchHelperPath]); + final box = await Hive.openBox("app_conf"); + await box.close(); + await Process.run(SystemHelper.powershellPath, [ + """ + Start-Process powershell -Verb RunAs -ArgumentList "Start-Process '${Platform.resolvedExecutable}' -Verb RunAs" + """ + ]); + await Future.delayed(const Duration(seconds: 2)); exit(0); } } diff --git a/pubspec.yaml b/pubspec.yaml index 0021b07..60ec832 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -125,7 +125,7 @@ msix_config: publisher_display_name: xkeyC Studio identity_name: 56575xkeyC.MSE publisher: CN=B54C897B-C263-4680-B6AB-4913C603DF87 - msix_version: 2.9.10.0 + msix_version: 2.9.12.0 logo_path: ./assets/app_logo.png capabilities: internetClient languages: zh-cn