mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-12 18:39:45 +00:00
Support .wgt and .wgtu
This commit is contained in:
@@ -165,6 +165,7 @@
|
|||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Grid.ColumnSpan="2"
|
Grid.ColumnSpan="2"
|
||||||
Margin="0,0,16,16"
|
Margin="0,0,16,16"
|
||||||
|
BorderThickness="0.4"
|
||||||
Header="Capabilities">
|
Header="Capabilities">
|
||||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||||
<ScrollViewer.Resources>
|
<ScrollViewer.Resources>
|
||||||
|
@@ -48,7 +48,7 @@ public class Plugin : IViewer
|
|||||||
//".har", // HarmonyOS Archive
|
//".har", // HarmonyOS Archive
|
||||||
|
|
||||||
// Others
|
// Others
|
||||||
//".wgt", ".wgtu", // UniApp Widget
|
".wgt", ".wgtu", // UniApp Widget
|
||||||
];
|
];
|
||||||
|
|
||||||
private IAppInfoPanel _ip;
|
private IAppInfoPanel _ip;
|
||||||
@@ -70,7 +70,8 @@ public class Plugin : IViewer
|
|||||||
context.PreferredSize = Path.GetExtension(path).ToLower() switch
|
context.PreferredSize = Path.GetExtension(path).ToLower() switch
|
||||||
{
|
{
|
||||||
".msi" => new Size { Width = 520, Height = 230 },
|
".msi" => new Size { Width = 520, Height = 230 },
|
||||||
".msix" or ".msixbundle" or ".appx" or ".appxbundle" => new Size { Width = 560, Height = 320 },
|
".msix" or ".msixbundle" or ".appx" or ".appxbundle" => new Size { Width = 560, Height = 328 },
|
||||||
|
".wgt" or ".wgtu" => new Size { Width = 600, Height = 328 },
|
||||||
_ => throw new NotSupportedException("Extension is not supported."),
|
_ => throw new NotSupportedException("Extension is not supported."),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -82,6 +83,7 @@ public class Plugin : IViewer
|
|||||||
{
|
{
|
||||||
".msi" => new MsiInfoPanel(),
|
".msi" => new MsiInfoPanel(),
|
||||||
".msix" or ".msixbundle" or ".appx" or ".appxbundle" => new AppxInfoPanel(),
|
".msix" or ".msixbundle" or ".appx" or ".appxbundle" => new AppxInfoPanel(),
|
||||||
|
".wgt" or ".wgtu" => new WgtInfoPanel(),
|
||||||
_ => throw new NotSupportedException("Extension is not supported."),
|
_ => throw new NotSupportedException("Extension is not supported."),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -59,6 +59,11 @@
|
|||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="Resources\*.png" />
|
||||||
|
<Resource Include="Resources\*.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\..\GitVersion.cs">
|
<Compile Include="..\..\GitVersion.cs">
|
||||||
<Link>Properties\GitVersion.cs</Link>
|
<Link>Properties\GitVersion.cs</Link>
|
||||||
@@ -67,8 +72,10 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.IO.Compression" />
|
||||||
<PackageReference Include="WixToolset.Dtf.WindowsInstaller" Version="6.0.0" />
|
<PackageReference Include="WixToolset.Dtf.WindowsInstaller" Version="6.0.0" />
|
||||||
<PackageReference Include="SharpZipLib" Version="1.4.2" />
|
<PackageReference Include="SharpZipLib" Version="1.4.2" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -77,4 +84,9 @@
|
|||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Resources\" />
|
||||||
|
<Folder Include="WgtPackageParser\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
@@ -9,6 +9,10 @@
|
|||||||
<LAST_MODIFIED>Last Modified</LAST_MODIFIED>
|
<LAST_MODIFIED>Last Modified</LAST_MODIFIED>
|
||||||
<PUBLISHER>Publisher</PUBLISHER>
|
<PUBLISHER>Publisher</PUBLISHER>
|
||||||
<CAPABILITIES>Capabilities</CAPABILITIES>
|
<CAPABILITIES>Capabilities</CAPABILITIES>
|
||||||
|
<APP_NAME>Application</APP_NAME>
|
||||||
|
<APP_VERSION>Version</APP_VERSION>
|
||||||
|
<APP_VERSION_CODE>Version Code</APP_VERSION_CODE>
|
||||||
|
<PERMISSIONS>Permissions</PERMISSIONS>
|
||||||
</en>
|
</en>
|
||||||
<pt-BR>
|
<pt-BR>
|
||||||
<PRODUCT_VERSION>Versão do produto</PRODUCT_VERSION>
|
<PRODUCT_VERSION>Versão do produto</PRODUCT_VERSION>
|
||||||
@@ -18,6 +22,10 @@
|
|||||||
<LAST_MODIFIED>Modificado em</LAST_MODIFIED>
|
<LAST_MODIFIED>Modificado em</LAST_MODIFIED>
|
||||||
<PUBLISHER>Editora</PUBLISHER>
|
<PUBLISHER>Editora</PUBLISHER>
|
||||||
<CAPABILITIES>Recursos</CAPABILITIES>
|
<CAPABILITIES>Recursos</CAPABILITIES>
|
||||||
|
<APP_NAME>Nome do aplicativo</APP_NAME>
|
||||||
|
<APP_VERSION>Versão</APP_VERSION>
|
||||||
|
<APP_VERSION_CODE>Código da versão</APP_VERSION_CODE>
|
||||||
|
<PERMISSIONS>Permissões</PERMISSIONS>
|
||||||
</pt-BR>
|
</pt-BR>
|
||||||
<zh-CN>
|
<zh-CN>
|
||||||
<PRODUCT_VERSION>产品版本</PRODUCT_VERSION>
|
<PRODUCT_VERSION>产品版本</PRODUCT_VERSION>
|
||||||
@@ -27,6 +35,10 @@
|
|||||||
<LAST_MODIFIED>修改时间</LAST_MODIFIED>
|
<LAST_MODIFIED>修改时间</LAST_MODIFIED>
|
||||||
<PUBLISHER>发布者</PUBLISHER>
|
<PUBLISHER>发布者</PUBLISHER>
|
||||||
<CAPABILITIES>功能</CAPABILITIES>
|
<CAPABILITIES>功能</CAPABILITIES>
|
||||||
|
<APP_NAME>应用名称</APP_NAME>
|
||||||
|
<APP_VERSION>版本名称</APP_VERSION>
|
||||||
|
<APP_VERSION_CODE>版本号</APP_VERSION_CODE>
|
||||||
|
<PERMISSIONS>权限</PERMISSIONS>
|
||||||
</zh-CN>
|
</zh-CN>
|
||||||
<zh-TW>
|
<zh-TW>
|
||||||
<PRODUCT_VERSION>產品版本</PRODUCT_VERSION>
|
<PRODUCT_VERSION>產品版本</PRODUCT_VERSION>
|
||||||
@@ -36,6 +48,10 @@
|
|||||||
<LAST_MODIFIED>修改時間</LAST_MODIFIED>
|
<LAST_MODIFIED>修改時間</LAST_MODIFIED>
|
||||||
<PUBLISHER>發行者</PUBLISHER>
|
<PUBLISHER>發行者</PUBLISHER>
|
||||||
<CAPABILITIES>功能</CAPABILITIES>
|
<CAPABILITIES>功能</CAPABILITIES>
|
||||||
|
<APP_NAME>程式名稱</APP_NAME>
|
||||||
|
<APP_VERSION>版本名稱</APP_VERSION>
|
||||||
|
<APP_VERSION_CODE>版本號</APP_VERSION_CODE>
|
||||||
|
<PERMISSIONS>權限</PERMISSIONS>
|
||||||
</zh-TW>
|
</zh-TW>
|
||||||
<ja>
|
<ja>
|
||||||
<PRODUCT_VERSION>製品バージョン</PRODUCT_VERSION>
|
<PRODUCT_VERSION>製品バージョン</PRODUCT_VERSION>
|
||||||
@@ -45,5 +61,9 @@
|
|||||||
<LAST_MODIFIED>更新日時</LAST_MODIFIED>
|
<LAST_MODIFIED>更新日時</LAST_MODIFIED>
|
||||||
<PUBLISHER>発行元</PUBLISHER>
|
<PUBLISHER>発行元</PUBLISHER>
|
||||||
<CAPABILITIES>機能</CAPABILITIES>
|
<CAPABILITIES>機能</CAPABILITIES>
|
||||||
|
<APP_NAME>アプリケーションネーム</APP_NAME>
|
||||||
|
<APP_VERSION>バージョン</APP_VERSION>
|
||||||
|
<APP_VERSION_CODE>バージョンコード</APP_VERSION_CODE>
|
||||||
|
<PERMISSIONS>権限</PERMISSIONS>
|
||||||
</ja>
|
</ja>
|
||||||
</Translations>
|
</Translations>
|
||||||
|
173
QuickLook.Plugin/QuickLook.Plugin.AppViewer/WgtInfoPanel.xaml
Normal file
173
QuickLook.Plugin/QuickLook.Plugin.AppViewer/WgtInfoPanel.xaml
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
<UserControl x:Class="QuickLook.Plugin.AppViewer.WgtInfoPanel"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:QuickLook.Plugin.AppViewer"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
FontSize="14"
|
||||||
|
UseLayoutRounding="True"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="15" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="150" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Image x:Name="image"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="0"
|
||||||
|
Width="120"
|
||||||
|
Height="120"
|
||||||
|
Margin="8"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Source="/QuickLook.Plugin.AppViewer;component/Resources/uni-app.png"
|
||||||
|
Stretch="Fill" />
|
||||||
|
<Grid Grid.Row="1" Grid.Column="1">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="5" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="10" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="10" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="10" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="* " />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Grid.ColumnSpan="2">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Grid.Column="0"
|
||||||
|
MaxHeight="60"
|
||||||
|
Padding="3"
|
||||||
|
FontSize="19"
|
||||||
|
FontWeight="SemiBold"
|
||||||
|
LineHeight="25"
|
||||||
|
TextTrimming="CharacterEllipsis"
|
||||||
|
TextWrapping="Wrap">
|
||||||
|
<TextBlock.Inlines>
|
||||||
|
<Run x:Name="filename" Text="FilenameFilenameFilenameFilenameFilenameFilenameFilenameFilenameFilenameFilename.ext" />
|
||||||
|
</TextBlock.Inlines>
|
||||||
|
</TextBlock>
|
||||||
|
</Grid>
|
||||||
|
<!-- Application Name -->
|
||||||
|
<TextBlock x:Name="applicationNameTitle"
|
||||||
|
Grid.Row="3"
|
||||||
|
Grid.Column="1"
|
||||||
|
Padding="3"
|
||||||
|
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||||
|
Text="Application Name" />
|
||||||
|
<TextBlock x:Name="applicationName"
|
||||||
|
Grid.Row="3"
|
||||||
|
Grid.Column="2"
|
||||||
|
Margin="8,0,0,0"
|
||||||
|
Padding="3"
|
||||||
|
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||||
|
Text="Searching..."
|
||||||
|
TextTrimming="CharacterEllipsis"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
|
<!-- Version -->
|
||||||
|
<TextBlock x:Name="versionTitle"
|
||||||
|
Grid.Row="4"
|
||||||
|
Grid.Column="1"
|
||||||
|
Padding="3"
|
||||||
|
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||||
|
Text="Version" />
|
||||||
|
<TextBlock x:Name="version"
|
||||||
|
Grid.Row="4"
|
||||||
|
Grid.Column="2"
|
||||||
|
Margin="8,0,0,0"
|
||||||
|
Padding="3"
|
||||||
|
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||||
|
Text="Searching..."
|
||||||
|
TextTrimming="CharacterEllipsis"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
|
<!-- Version Code -->
|
||||||
|
<TextBlock x:Name="versionCodeTitle"
|
||||||
|
Grid.Row="5"
|
||||||
|
Grid.Column="1"
|
||||||
|
Padding="3"
|
||||||
|
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||||
|
Text="Version Code" />
|
||||||
|
<TextBlock x:Name="versionCode"
|
||||||
|
Grid.Row="5"
|
||||||
|
Grid.Column="2"
|
||||||
|
Margin="8,0,0,0"
|
||||||
|
Padding="3"
|
||||||
|
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||||
|
Text="Searching..."
|
||||||
|
TextTrimming="CharacterEllipsis"
|
||||||
|
TextWrapping="Wrap" />
|
||||||
|
<!-- Total Size -->
|
||||||
|
<TextBlock x:Name="totalSizeTitle"
|
||||||
|
Grid.Row="6"
|
||||||
|
Grid.Column="1"
|
||||||
|
Padding="3"
|
||||||
|
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||||
|
Text="Total Size" />
|
||||||
|
<TextBlock x:Name="totalSize"
|
||||||
|
Grid.Row="6"
|
||||||
|
Grid.Column="2"
|
||||||
|
Margin="8,0,0,0"
|
||||||
|
Padding="3"
|
||||||
|
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||||
|
Text="Calculating size..." />
|
||||||
|
<!-- Last Modified -->
|
||||||
|
<TextBlock x:Name="modDateTitle"
|
||||||
|
Grid.Row="7"
|
||||||
|
Grid.Column="1"
|
||||||
|
Padding="3"
|
||||||
|
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||||
|
Text="Last Modified" />
|
||||||
|
<TextBlock x:Name="modDate"
|
||||||
|
Grid.Row="7"
|
||||||
|
Grid.Column="2"
|
||||||
|
Margin="8,0,0,0"
|
||||||
|
Padding="3"
|
||||||
|
Foreground="{DynamicResource WindowTextForegroundAlternative}"
|
||||||
|
Text="Searching..."
|
||||||
|
TextTrimming="CharacterEllipsis" />
|
||||||
|
<!-- Permissions -->
|
||||||
|
<GroupBox x:Name="permissionsGroupBox"
|
||||||
|
Grid.Row="8"
|
||||||
|
Grid.Column="1"
|
||||||
|
Grid.ColumnSpan="2"
|
||||||
|
Margin="0,0,16,16"
|
||||||
|
BorderThickness="0.4"
|
||||||
|
Header="Capabilities">
|
||||||
|
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||||
|
<ScrollViewer.Resources>
|
||||||
|
<Style TargetType="{x:Type TextBox}">
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
|
||||||
|
<Setter Property="BorderThickness" Value="0" />
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
</Style>
|
||||||
|
</ScrollViewer.Resources>
|
||||||
|
<ItemsControl x:Name="permissions">
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextBox Margin="8,3,16,3"
|
||||||
|
IsReadOnly="True"
|
||||||
|
Text="{Binding ., Mode=OneTime}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
</ScrollViewer>
|
||||||
|
</GroupBox>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
@@ -0,0 +1,70 @@
|
|||||||
|
// Copyright © 2017-2025 QL-Win Contributors
|
||||||
|
//
|
||||||
|
// This file is part of QuickLook program.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using QuickLook.Common.ExtensionMethods;
|
||||||
|
using QuickLook.Common.Helpers;
|
||||||
|
using QuickLook.Plugin.AppViewer.WgtPackageParser;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace QuickLook.Plugin.AppViewer;
|
||||||
|
|
||||||
|
public partial class WgtInfoPanel : UserControl, IAppInfoPanel
|
||||||
|
{
|
||||||
|
public WgtInfoPanel()
|
||||||
|
{
|
||||||
|
DataContext = this;
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
string translationFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Translations.config");
|
||||||
|
applicationNameTitle.Text = TranslationHelper.Get("APP_NAME", translationFile);
|
||||||
|
versionTitle.Text = TranslationHelper.Get("APP_VERSION", translationFile);
|
||||||
|
versionCodeTitle.Text = TranslationHelper.Get("APP_VERSION_CODE", translationFile);
|
||||||
|
totalSizeTitle.Text = TranslationHelper.Get("TOTAL_SIZE", translationFile);
|
||||||
|
modDateTitle.Text = TranslationHelper.Get("LAST_MODIFIED", translationFile);
|
||||||
|
permissionsGroupBox.Header = TranslationHelper.Get("PERMISSIONS", translationFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisplayInfo(string path)
|
||||||
|
{
|
||||||
|
var name = Path.GetFileName(path);
|
||||||
|
filename.Text = string.IsNullOrEmpty(name) ? path : name;
|
||||||
|
|
||||||
|
_ = Task.Run(() =>
|
||||||
|
{
|
||||||
|
if (File.Exists(path))
|
||||||
|
{
|
||||||
|
var size = new FileInfo(path).Length;
|
||||||
|
WgtInfo wgtInfo = WgtParser.Parse(path);
|
||||||
|
var last = File.GetLastWriteTime(path);
|
||||||
|
|
||||||
|
Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
applicationName.Text = wgtInfo.AppNameLocale ?? wgtInfo.AppName;
|
||||||
|
version.Text = wgtInfo.AppVersion;
|
||||||
|
versionCode.Text = wgtInfo.AppVersionCode;
|
||||||
|
totalSize.Text = size.ToPrettySize(2);
|
||||||
|
modDate.Text = last.ToString(CultureInfo.CurrentCulture);
|
||||||
|
permissions.ItemsSource = wgtInfo.Permissions;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,115 @@
|
|||||||
|
// Copyright © 2017-2025 QL-Win Contributors
|
||||||
|
//
|
||||||
|
// This file is part of QuickLook program.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using QuickLook.Plugin.AppViewer.AppxPackageParser;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Resources;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace QuickLook.Plugin.AppViewer.WgtPackageParser;
|
||||||
|
|
||||||
|
public sealed class WgtInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Json path: @platforms
|
||||||
|
/// </summary>
|
||||||
|
public string[] Platforms { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Json path: id
|
||||||
|
/// </summary>
|
||||||
|
public string AppId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Json path: name
|
||||||
|
/// </summary>
|
||||||
|
public string AppName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Json path: plus.locales.xxx.name
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, string> AppNameLocales { get; set; } = [];
|
||||||
|
|
||||||
|
public string AppNameLocale
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CultureInfo culture = CultureInfo.CurrentCulture;
|
||||||
|
|
||||||
|
while (!AppNameLocales.ContainsKey(culture.Name))
|
||||||
|
{
|
||||||
|
if (culture.Parent == CultureInfo.InvariantCulture)
|
||||||
|
{
|
||||||
|
culture = CultureInfo.InvariantCulture;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
culture = culture.Parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return AppNameLocales[culture.Name];
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Json path: plus.uni-app.vueVersion
|
||||||
|
/// </summary>
|
||||||
|
public string VueVersion { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Json path: plus.uni-app.compilerVersion
|
||||||
|
/// </summary>
|
||||||
|
public string CompilerVersion { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Json path: version.name
|
||||||
|
/// </summary>
|
||||||
|
public string AppVersion { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Json path: version.code
|
||||||
|
/// </summary>
|
||||||
|
public string AppVersionCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Json path: description
|
||||||
|
/// </summary>
|
||||||
|
public string AppDescription { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Json path: descriptionLocales
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, string> AppDescriptionLocales { get; set; } = [];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Json path: descriptionLocales
|
||||||
|
/// </summary>
|
||||||
|
public string[] Permissions { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Json path: fallbackLocale
|
||||||
|
/// </summary>
|
||||||
|
public string FallbackLocale { get; set; }
|
||||||
|
}
|
@@ -0,0 +1,130 @@
|
|||||||
|
// Copyright © 2017-2025 QL-Win Contributors
|
||||||
|
//
|
||||||
|
// This file is part of QuickLook program.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace QuickLook.Plugin.AppViewer.WgtPackageParser;
|
||||||
|
|
||||||
|
internal static class WgtParser
|
||||||
|
{
|
||||||
|
public static WgtInfo Parse(string path)
|
||||||
|
{
|
||||||
|
using var fileStream = File.OpenRead(path);
|
||||||
|
using var zipArchive = new ZipArchive(fileStream, ZipArchiveMode.Read);
|
||||||
|
var manifestEntry = zipArchive.GetEntry("manifest.json");
|
||||||
|
|
||||||
|
if (manifestEntry != null)
|
||||||
|
{
|
||||||
|
using var stream = manifestEntry.Open();
|
||||||
|
using var reader = new StreamReader(stream, Encoding.UTF8);
|
||||||
|
string content = reader.ReadToEnd();
|
||||||
|
var dict = JsonConvert.DeserializeObject<Dictionary<string, object>>(content);
|
||||||
|
|
||||||
|
if (dict == null) return null;
|
||||||
|
|
||||||
|
var wgtInfo = new WgtInfo();
|
||||||
|
|
||||||
|
if (dict.ContainsKey("@platforms"))
|
||||||
|
{
|
||||||
|
wgtInfo.Platforms = ((JArray)dict["@platforms"]).Values().Select(v => v.ToString()).ToArray();
|
||||||
|
}
|
||||||
|
if (dict.ContainsKey("id")) wgtInfo.AppId = dict["id"].ToString();
|
||||||
|
if (dict.ContainsKey("name")) wgtInfo.AppName = dict["name"].ToString();
|
||||||
|
if (dict.ContainsKey("version"))
|
||||||
|
{
|
||||||
|
var version = (JObject)dict["version"];
|
||||||
|
|
||||||
|
if (version != null)
|
||||||
|
{
|
||||||
|
if (version.ContainsKey("name")) wgtInfo.AppVersion = version["name"].ToString();
|
||||||
|
if (version.ContainsKey("code")) wgtInfo.AppVersionCode = version["code"].ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dict.ContainsKey("description")) wgtInfo.AppDescription = dict["description"].ToString();
|
||||||
|
if (dict.ContainsKey("permissions"))
|
||||||
|
{
|
||||||
|
var permissions = (JObject)dict["permissions"];
|
||||||
|
|
||||||
|
if (permissions != null)
|
||||||
|
{
|
||||||
|
List<string> permissionNames = [];
|
||||||
|
foreach (var permission in permissions)
|
||||||
|
{
|
||||||
|
permissionNames.Add(permission.Key);
|
||||||
|
}
|
||||||
|
wgtInfo.Permissions = [.. permissionNames];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dict.ContainsKey("plus"))
|
||||||
|
{
|
||||||
|
var plus = (JObject)dict["plus"];
|
||||||
|
|
||||||
|
if (plus != null)
|
||||||
|
{
|
||||||
|
if (plus.ContainsKey("locales"))
|
||||||
|
{
|
||||||
|
var locales = plus["locales"];
|
||||||
|
var dictionary = locales.ToObject<Dictionary<string, Dictionary<string, object>>>();
|
||||||
|
|
||||||
|
foreach (var locale in dictionary)
|
||||||
|
{
|
||||||
|
foreach (var kv in locale.Value)
|
||||||
|
{
|
||||||
|
if (kv.Key == "name")
|
||||||
|
{
|
||||||
|
wgtInfo.AppNameLocales.Add(locale.Key, kv.Value.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plus.ContainsKey("uni-app"))
|
||||||
|
{
|
||||||
|
var uni_app = plus["uni-app"];
|
||||||
|
var dictionary = uni_app.ToObject<Dictionary<string, object>>();
|
||||||
|
|
||||||
|
if (dictionary.ContainsKey("vueVersion")) wgtInfo.VueVersion = dictionary["vueVersion"].ToString();
|
||||||
|
if (dictionary.ContainsKey("compilerVersion")) wgtInfo.CompilerVersion = dictionary["compilerVersion"].ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dict.ContainsKey("descriptionLocales"))
|
||||||
|
{
|
||||||
|
var descriptionLocales = (JObject)dict["descriptionLocales"];
|
||||||
|
|
||||||
|
if (descriptionLocales != null)
|
||||||
|
{
|
||||||
|
foreach (var descriptionLocale in descriptionLocales)
|
||||||
|
{
|
||||||
|
wgtInfo.AppDescriptionLocales.Add(descriptionLocale.Key, descriptionLocale.Value.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dict.ContainsKey("fallbackLocale")) wgtInfo.FallbackLocale = dict["fallbackLocale"].ToString();
|
||||||
|
|
||||||
|
return wgtInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user