From 07bb56bc851078dc292bf6566f438a127f886272 Mon Sep 17 00:00:00 2001 From: DaZiYuan Date: Wed, 7 Feb 2024 19:13:20 +0800 Subject: [PATCH] =?UTF-8?q?release:v3.0.9.0=20=E7=B4=A7=E6=80=A5=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=95=86=E5=BA=97=E6=97=A0=E6=B3=95=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...64\346\226\260\350\256\260\345\275\225.md" | 8 ++++ .../Client.App/Package.appxmanifest | 2 +- .../Client/Client.csproj | 2 +- .../Client/Libs/AutoStart.cs | 38 +--------------- .../Client/Libs/UWPHelper.cs | 44 +++++++++++++++++++ .../Client/UI/ShellWindow.xaml.cs | 5 ++- 6 files changed, 60 insertions(+), 39 deletions(-) create mode 100644 src/giantapp-wallpaper-client/Client/Libs/UWPHelper.cs diff --git "a/docs/2.\346\233\264\346\226\260\350\256\260\345\275\225.md" "b/docs/2.\346\233\264\346\226\260\350\256\260\345\275\225.md" index cb3edd18..5534a3cb 100644 --- "a/docs/2.\346\233\264\346\226\260\350\256\260\345\275\225.md" +++ "b/docs/2.\346\233\264\346\226\260\350\256\260\345\275\225.md" @@ -59,6 +59,14 @@ --- +## v3.0.9-alpha.9 发布日期:2024.2.8 + +### 修复 + +- [x] 修复商店版无法使用 + +--- + ## v3.0.8-alpha.8 发布日期:2024.2.7 ### 修复 diff --git a/src/giantapp-wallpaper-client/Client.App/Package.appxmanifest b/src/giantapp-wallpaper-client/Client.App/Package.appxmanifest index 98468cf7..e601475b 100644 --- a/src/giantapp-wallpaper-client/Client.App/Package.appxmanifest +++ b/src/giantapp-wallpaper-client/Client.App/Package.appxmanifest @@ -10,7 +10,7 @@ + Version="3.0.9.0" /> 巨应壁纸3 diff --git a/src/giantapp-wallpaper-client/Client/Client.csproj b/src/giantapp-wallpaper-client/Client/Client.csproj index 0bd1baab..ebf3523c 100644 --- a/src/giantapp-wallpaper-client/Client/Client.csproj +++ b/src/giantapp-wallpaper-client/Client/Client.csproj @@ -10,7 +10,7 @@ x64 LiveWallpaper3 Assets\Img\logo.ico - 3.0.8-alpha8 + 3.0.9-alpha9 https://giantapp.cn 巨应君 | Giantapp Studio app.manifest diff --git a/src/giantapp-wallpaper-client/Client/Libs/AutoStart.cs b/src/giantapp-wallpaper-client/Client/Libs/AutoStart.cs index 75857793..f15eb09d 100644 --- a/src/giantapp-wallpaper-client/Client/Libs/AutoStart.cs +++ b/src/giantapp-wallpaper-client/Client/Libs/AutoStart.cs @@ -29,7 +29,7 @@ public AutoStart(string key, string executablePath) public async Task Set(bool enabled) { - if (IsRunningAsUwp()) + if (UWPHelper.IsRunningAsUwp()) return await UWPSet(enabled); else return DeskTopSet(enabled); @@ -37,7 +37,7 @@ public async Task Set(bool enabled) public async Task Check() { - if (IsRunningAsUwp()) + if (UWPHelper.IsRunningAsUwp()) return await UWPCheck(); else return DeskTopCheck(); @@ -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 } } diff --git a/src/giantapp-wallpaper-client/Client/Libs/UWPHelper.cs b/src/giantapp-wallpaper-client/Client/Libs/UWPHelper.cs new file mode 100644 index 00000000..ecfb0dd8 --- /dev/null +++ b/src/giantapp-wallpaper-client/Client/Libs/UWPHelper.cs @@ -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); + +} diff --git a/src/giantapp-wallpaper-client/Client/UI/ShellWindow.xaml.cs b/src/giantapp-wallpaper-client/Client/UI/ShellWindow.xaml.cs index f114c798..335507a6 100644 --- a/src/giantapp-wallpaper-client/Client/UI/ShellWindow.xaml.cs +++ b/src/giantapp-wallpaper-client/Client/UI/ShellWindow.xaml.cs @@ -204,7 +204,10 @@ public static void ApplyCustomFolderMapping(Dictionary 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); }