mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix UWP apps loading
This commit is contained in:
parent
fbeed5986c
commit
1675a48202
1 changed files with 14 additions and 17 deletions
|
|
@ -363,34 +363,37 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
||||||
BackgroundColor = manifestApp.GetStringValue("BackgroundColor");
|
BackgroundColor = manifestApp.GetStringValue("BackgroundColor");
|
||||||
Package = package;
|
Package = package;
|
||||||
|
|
||||||
DisplayName = ResourceFromPri(package.FullName, DisplayName);
|
DisplayName = ResourceFromPri(package.FullName, package.Name, DisplayName);
|
||||||
Description = ResourceFromPri(package.FullName, Description);
|
Description = ResourceFromPri(package.FullName, package.Name, Description);
|
||||||
LogoUri = LogoUriFromManifest(manifestApp);
|
LogoUri = LogoUriFromManifest(manifestApp);
|
||||||
LogoPath = LogoPathFromUri(LogoUri);
|
LogoPath = LogoPathFromUri(LogoUri);
|
||||||
|
|
||||||
Enabled = true;
|
Enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal string ResourceFromPri(string packageFullName, string resourceReference)
|
internal string ResourceFromPri(string packageFullName, string packageName, string resourceReference)
|
||||||
{
|
{
|
||||||
const string prefix = "ms-resource:";
|
const string prefix = "ms-resource:";
|
||||||
if (!string.IsNullOrWhiteSpace(resourceReference) && resourceReference.StartsWith(prefix))
|
if (!string.IsNullOrWhiteSpace(resourceReference) && resourceReference.StartsWith(prefix))
|
||||||
{
|
{
|
||||||
// magic comes from @talynone
|
|
||||||
// https://github.com/talynone/Wox.Plugin.WindowsUniversalAppLauncher/blob/master/StoreAppLauncher/Helpers/NativeApiHelper.cs#L139-L153
|
|
||||||
string key = resourceReference.Substring(prefix.Length);
|
string key = resourceReference.Substring(prefix.Length);
|
||||||
string parsed;
|
string parsed;
|
||||||
if (key.StartsWith("//"))
|
if (key.StartsWith("//"))
|
||||||
{
|
{
|
||||||
parsed = prefix + key;
|
parsed = $"{prefix}{key}";
|
||||||
}
|
|
||||||
else if (key.StartsWith("/"))
|
|
||||||
{
|
|
||||||
parsed = prefix + "//" + key;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parsed = prefix + "///resources/" + key;
|
if (!key.StartsWith("/"))
|
||||||
|
{
|
||||||
|
key = $"/{key}";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!key.ToLower().Contains("resources"))
|
||||||
|
{
|
||||||
|
key = $"/Resources{key}";
|
||||||
|
}
|
||||||
|
parsed = $"{prefix}//{packageName}{key}";
|
||||||
}
|
}
|
||||||
|
|
||||||
var outBuffer = new StringBuilder(128);
|
var outBuffer = new StringBuilder(128);
|
||||||
|
|
@ -413,12 +416,6 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// https://github.com/Wox-launcher/Wox/issues/964
|
|
||||||
// known hresult 2147942522:
|
|
||||||
// 'Microsoft Corporation' violates pattern constraint of '\bms-resource:.{1,256}'.
|
|
||||||
// for
|
|
||||||
// Microsoft.MicrosoftOfficeHub_17.7608.23501.0_x64__8wekyb3d8bbwe: ms-resource://Microsoft.MicrosoftOfficeHub/officehubintl/AppManifest_GetOffice_Description
|
|
||||||
// Microsoft.BingFoodAndDrink_3.0.4.336_x64__8wekyb3d8bbwe: ms-resource:AppDescription
|
|
||||||
var e = Marshal.GetExceptionForHR((int)hResult);
|
var e = Marshal.GetExceptionForHR((int)hResult);
|
||||||
ProgramLogger.LogException($"|UWP|ResourceFromPri|{Package.Location}|Load pri failed {source} with HResult {hResult} and location {Package.Location}", e);
|
ProgramLogger.LogException($"|UWP|ResourceFromPri|{Package.Location}|Load pri failed {source} with HResult {hResult} and location {Package.Location}", e);
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue