Skip to content

Commit 7c8bd54

Browse files
committed
修复桌面快捷方式的创建
1 parent e8a51a1 commit 7c8bd54

File tree

7 files changed

+17
-20
lines changed

7 files changed

+17
-20
lines changed

src/Snap.Hutao.Remastered/Snap.Hutao.Remastered/Core/Shell/IShellLinkInterop.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ namespace Snap.Hutao.Remastered.Core.Shell;
55

66
internal interface IShellLinkInterop
77
{
8-
bool TryCreateDesktopShortcutForElevatedLaunch();
8+
bool TryCreateDesktopShortcut();
99
}

src/Snap.Hutao.Remastered/Snap.Hutao.Remastered/Core/Shell/ShellLinkInterop.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,26 @@
33

44
using Snap.Hutao.Remastered.Core.IO;
55
using System.IO;
6+
using Windows.ApplicationModel;
67

78
namespace Snap.Hutao.Remastered.Core.Shell;
89

910
[Service(ServiceLifetime.Transient, typeof(IShellLinkInterop))]
1011
internal sealed class ShellLinkInterop : IShellLinkInterop
1112
{
12-
public bool TryCreateDesktopShortcutForElevatedLaunch()
13+
public bool TryCreateDesktopShortcut()
1314
{
1415
string targetLogoPath = HutaoRuntime.GetDataDirectoryFile("ShellLinkLogo.ico");
15-
string elevatedLauncherPath = HutaoRuntime.GetDataDirectoryFile("Snap.Hutao.Remastered.Elevated.Launcher.exe");
1616

1717
try
1818
{
1919
InstalledLocation.CopyFileFromApplicationUri("ms-appx:///Assets/Logo.ico", targetLogoPath);
20-
InstalledLocation.CopyFileFromApplicationUri("ms-appx:///Snap.Hutao.Remastered.Elevated.Launcher.exe", elevatedLauncherPath);
2120

2221
string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
2322
string target = Path.Combine(desktop, $"{SH.FormatAppNameAndVersion(HutaoRuntime.Version)}.lnk");
24-
FileSystem.CreateLink(elevatedLauncherPath, HutaoRuntime.FamilyName, targetLogoPath, target);
23+
24+
FileSystem.CreateLink("hutao://", "", targetLogoPath, target);
25+
2526
return true;
2627
}
2728
catch

src/Snap.Hutao.Remastered/Snap.Hutao.Remastered/Resource/Localization/SH.en.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3180,7 +3180,7 @@ Space Available: {2}</value>
31803180
<value>Create</value>
31813181
</data>
31823182
<data name="ViewPageSettingCreateDesktopShortcutDescription" xml:space="preserve">
3183-
<value>Create desktop shortcut with administrator privilege</value>
3183+
<value>Create desktop shortcut</value>
31843184
</data>
31853185
<data name="ViewPageSettingCreateDesktopShortcutHeader" xml:space="preserve">
31863186
<value>Create Desktop Shortcut</value>

src/Snap.Hutao.Remastered/Snap.Hutao.Remastered/Resource/Localization/SH.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3211,7 +3211,7 @@
32113211
<value>创建</value>
32123212
</data>
32133213
<data name="ViewPageSettingCreateDesktopShortcutDescription" xml:space="preserve">
3214-
<value>在桌面上创建默认以管理员身份启动的快捷方式</value>
3214+
<value>在桌面上创建快捷方式</value>
32153215
</data>
32163216
<data name="ViewPageSettingCreateDesktopShortcutHeader" xml:space="preserve">
32173217
<value>创建快捷方式</value>

src/Snap.Hutao.Remastered/Snap.Hutao.Remastered/Snap.Hutao.Remastered.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,6 @@
270270
<PackageReference Include="Snap.HPatch" Version="0.0.2">
271271
<PrivateAssets>all</PrivateAssets>
272272
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
273-
</PackageReference>
274-
<PackageReference Include="Snap.Hutao.Remastered.Elevated.Launcher" Version="1.0.0">
275-
<PrivateAssets>all</PrivateAssets>
276-
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
277273
</PackageReference>
278274
<PackageReference Include="Snap.Hutao.Remastered.Native" Version="1.0.2">
279275
<PrivateAssets>all</PrivateAssets>

src/Snap.Hutao.Remastered/Snap.Hutao.Remastered/UI/Xaml/View/Page/SettingPage.xaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@
134134
<StackPanel
135135
Grid.Row="0"
136136
Grid.Column="1"
137-
VerticalAlignment="Center"
138-
Spacing="12">
137+
VerticalAlignment="Center">
139138
<cwc:UniformGrid
140139
VerticalAlignment="Center"
141140
ColumnSpacing="8"
@@ -178,17 +177,18 @@
178177
HeaderIcon="{shuxm:FontIcon Glyph=&#xE895;}"
179178
IsClickEnabled="True"/>
180179

180+
<cwc:SettingsCard
181+
ActionIconToolTip="{shuxm:ResourceString Name=ViewPageSettingCreateDesktopShortcutAction}"
182+
Command="{Binding CreateDesktopShortcutCommand}"
183+
Description="{shuxm:ResourceString Name=ViewPageSettingCreateDesktopShortcutDescription}"
184+
Header="{shuxm:ResourceString Name=ViewPageSettingCreateDesktopShortcutHeader}"
185+
IsClickEnabled="True"/>
186+
181187
<cwc:SettingsExpander
182188
Header="{shuxm:ResourceString Name=ViewPageSettingElevatedModeHeader}"
183189
HeaderIcon="{shuxm:FontIcon Glyph=&#xE7EF;}"
184190
IsExpanded="True">
185191
<cwc:SettingsExpander.Items>
186-
<cwc:SettingsCard
187-
ActionIconToolTip="{shuxm:ResourceString Name=ViewPageSettingCreateDesktopShortcutAction}"
188-
Command="{Binding CreateDesktopShortcutCommand}"
189-
Description="{shuxm:ResourceString Name=ViewPageSettingCreateDesktopShortcutDescription}"
190-
Header="{shuxm:ResourceString Name=ViewPageSettingCreateDesktopShortcutHeader}"
191-
IsClickEnabled="True"/>
192192
<cwc:SettingsCard
193193
Description="{shuxm:ResourceString Name=ViewPageSettingAutoRestartAsAdminDescription}"
194194
Header="{shuxm:ResourceString Name=ViewPageSettingAutoRestartAsAdminHeader}"

src/Snap.Hutao.Remastered/Snap.Hutao.Remastered/ViewModel/Setting/SettingViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private void CreateDesktopShortcutForElevatedLaunchAsync()
117117
{
118118
SentrySdk.AddBreadcrumb(BreadcrumbFactory.CreateUI("Create desktop shortcut for elevated launch", "SettingViewModel.Command"));
119119

120-
_ = shellLinkInterop.TryCreateDesktopShortcutForElevatedLaunch()
120+
_ = shellLinkInterop.TryCreateDesktopShortcut()
121121
? messenger.Send(InfoBarMessage.Success(SH.ViewModelSettingActionComplete))
122122
: messenger.Send(InfoBarMessage.Warning(SH.ViewModelSettingCreateDesktopShortcutFailed));
123123
}

0 commit comments

Comments
 (0)