Skip to content

Commit

Permalink
release:v3.0.9.0 紧急修复商店无法打开
Browse files Browse the repository at this point in the history
  • Loading branch information
GiantappMan committed Feb 7, 2024
1 parent e974a4d commit 07bb56b
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 39 deletions.
8 changes: 8 additions & 0 deletions docs/2.更新记录.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@

---

## v3.0.9-alpha.9 发布日期:2024.2.8

### 修复

- [x] 修复商店版无法使用

---

## v3.0.8-alpha.8 发布日期:2024.2.7

### 修复
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Identity
Name="24765mscoder.3"
Publisher="CN=49BC8659-1B4C-4520-B1FB-ED98CFA366C4"
Version="3.0.8.0" />
Version="3.0.9.0" />

<Properties>
<DisplayName>巨应壁纸3</DisplayName>
Expand Down
2 changes: 1 addition & 1 deletion src/giantapp-wallpaper-client/Client/Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Platforms>x64</Platforms>
<AssemblyName>LiveWallpaper3</AssemblyName>
<ApplicationIcon>Assets\Img\logo.ico</ApplicationIcon>
<Version>3.0.8-alpha8</Version>
<Version>3.0.9-alpha9</Version>
<PackageProjectUrl>https://giantapp.cn</PackageProjectUrl>
<Authors>巨应君 | Giantapp Studio</Authors>
<ApplicationManifest>app.manifest</ApplicationManifest>
Expand Down
38 changes: 2 additions & 36 deletions src/giantapp-wallpaper-client/Client/Libs/AutoStart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public AutoStart(string key, string executablePath)

public async Task<bool> Set(bool enabled)
{
if (IsRunningAsUwp())
if (UWPHelper.IsRunningAsUwp())
return await UWPSet(enabled);
else
return DeskTopSet(enabled);
}

public async Task<bool> Check()
{
if (IsRunningAsUwp())
if (UWPHelper.IsRunningAsUwp())
return await UWPCheck();
else
return DeskTopCheck();
Expand Down Expand Up @@ -210,40 +210,6 @@ public bool DeskTopCheck()
return null;
}
}
const long APPMODEL_ERROR_NO_PACKAGE = 15700L;

[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
static extern int GetCurrentPackageFullName(ref int packageFullNameLength, StringBuilder packageFullName);

public bool IsRunningAsUwp()
{
if (IsWindows7OrLower)
{
return false;
}
else
{
int length = 0;
StringBuilder sb = new(0);
GetCurrentPackageFullName(ref length, sb);

sb = new StringBuilder(length);
int result = GetCurrentPackageFullName(ref length, sb);

return result != APPMODEL_ERROR_NO_PACKAGE;
}
}

private bool IsWindows7OrLower
{
get
{
int versionMajor = Environment.OSVersion.Version.Major;
int versionMinor = Environment.OSVersion.Version.Minor;
double version = versionMajor + (double)versionMinor / 10;
return version <= 6.1;
}
}
#endregion
}
}
44 changes: 44 additions & 0 deletions src/giantapp-wallpaper-client/Client/Libs/UWPHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Runtime.InteropServices;
using System.Text;

namespace Client.Libs;

public class UWPHelper
{
public static bool IsRunningAsUwp()
{
if (IsWindows7OrLower)
{
return false;
}
else
{
int length = 0;
StringBuilder sb = new(0);
GetCurrentPackageFullName(ref length, sb);

sb = new StringBuilder(length);
int result = GetCurrentPackageFullName(ref length, sb);

return result != APPMODEL_ERROR_NO_PACKAGE;
}
}

private static bool IsWindows7OrLower
{
get
{
int versionMajor = Environment.OSVersion.Version.Major;
int versionMinor = Environment.OSVersion.Version.Minor;
double version = versionMajor + (double)versionMinor / 10;
return version <= 6.1;
}
}

const long APPMODEL_ERROR_NO_PACKAGE = 15700L;

[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
static extern int GetCurrentPackageFullName(ref int packageFullNameLength, StringBuilder packageFullName);

}
5 changes: 4 additions & 1 deletion src/giantapp-wallpaper-client/Client/UI/ShellWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ public static void ApplyCustomFolderMapping(Dictionary<string, string> mapping,

foreach (var item in mapping)
{
if (!Directory.Exists(item.Value))
bool isAbsoluteFilePath = Path.IsPathRooted(item.Value);
bool isUWP = UWPHelper.IsRunningAsUwp();
//必须判断,商店版无法创建相对路径
if ((!isUWP || isAbsoluteFilePath) && !Directory.Exists(item.Value))
Directory.CreateDirectory(item.Value);
webview2?.CoreWebView2?.SetVirtualHostNameToFolderMapping(item.Key, item.Value, CoreWebView2HostResourceAccessKind.Allow);
}
Expand Down

0 comments on commit 07bb56b

Please sign in to comment.