mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-23 00:33:42 +08:00
新增创建快捷方式的功能
This commit is contained in:
parent
c136b68922
commit
a8ce60bd98
@ -48,6 +48,8 @@ class AppConf {
|
||||
|
||||
static const gameChannels = ["LIVE", "PTU", "EPTU"];
|
||||
|
||||
static const appShortCutName = "SC汉化盒子${AppConf.isMSE ? "" : "DEV"}.lnk";
|
||||
|
||||
static late final String applicationSupportDir;
|
||||
|
||||
static AppVersionData? networkVersionData;
|
||||
|
@ -18,16 +18,9 @@ class AboutUI extends BaseUI<AboutUIModel> {
|
||||
const SizedBox(height: 64),
|
||||
Image.asset("assets/app_logo.png", width: 128, height: 128),
|
||||
const SizedBox(height: 6),
|
||||
if (AppConf.isMSE)
|
||||
const Text(
|
||||
"SC汉化盒子 V${AppConf.appVersion}",
|
||||
style: TextStyle(fontSize: 18),
|
||||
)
|
||||
else
|
||||
const Text(
|
||||
"星际公民盒子 V${AppConf.appVersion}",
|
||||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
const Text(
|
||||
"SC汉化盒子 V${AppConf.appVersion} ${AppConf.isMSE ? "" : " +Dev"}",
|
||||
style: TextStyle(fontSize: 18)),
|
||||
const SizedBox(height: 12),
|
||||
Button(
|
||||
onPressed: model.checkUpdate,
|
||||
@ -118,8 +111,7 @@ class AboutUI extends BaseUI<AboutUIModel> {
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
launchUrlString(
|
||||
"https://github.com/StarCitizenToolBox/app");
|
||||
launchUrlString("https://github.com/StarCitizenToolBox/app");
|
||||
},
|
||||
),
|
||||
],
|
||||
|
@ -32,10 +32,8 @@ class IndexUI extends BaseUI<IndexUIModel> {
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
if (AppConf.isMSE)
|
||||
const Text("SC汉化盒子 V${AppConf.appVersion}")
|
||||
else
|
||||
const Text("星际公民盒子 V${AppConf.appVersion}"),
|
||||
const Text(
|
||||
"SC汉化盒子 V${AppConf.appVersion} ${AppConf.isMSE ? "" : " +Dev"}")
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -12,7 +12,10 @@ class SettingUI extends BaseUI<SettingUIModel> {
|
||||
margin: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
children: [
|
||||
makeSettingsItem(const Icon(FluentIcons.link, size: 20), "创建设置快捷方式",
|
||||
subTitle: "在桌面创建《SC汉化盒子》快捷方式", onTap: model.addShortCut),
|
||||
if (AppConf.isMSE) ...[
|
||||
const SizedBox(height: 12),
|
||||
makeSettingsItem(
|
||||
const Icon(FluentIcons.reset_device, size: 20), "重置自动密码填充",
|
||||
subTitle:
|
||||
|
@ -149,4 +149,25 @@ class SettingUIModel extends BaseUIModel {
|
||||
reloadData();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> addShortCut() async {
|
||||
dPrint(Platform.resolvedExecutable);
|
||||
final script = """
|
||||
\$targetPath = "${Platform.resolvedExecutable}";
|
||||
\$shortcutPath = [System.IO.Path]::Combine([System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::DesktopDirectory), "${AppConf.appShortCutName}");
|
||||
\$shell = New-Object -ComObject WScript.Shell
|
||||
\$shortcut = \$shell.CreateShortcut(\$shortcutPath)
|
||||
if (\$shortcut -eq \$null) {
|
||||
Write-Host "Failed to create shortcut."
|
||||
} else {
|
||||
\$shortcut.TargetPath = \$targetPath
|
||||
\$shortcut.Save()
|
||||
Write-Host "Shortcut created successfully."
|
||||
}
|
||||
""";
|
||||
final r = await Process.run(SystemHelper.powershellPath, [script]);
|
||||
dPrint(r.exitCode);
|
||||
dPrint(r.stdout);
|
||||
dPrint(r.stderr);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user