Сделан скелет плагина
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Platforms>x64;ARM64</Platforms>
|
||||
<PlatformTarget>$(Platform)</PlatformTarget>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<LangVersion>preview</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="plugin.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Images\*.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Images\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Community.PowerToys.Run.Plugin.Dependencies" Version="0.90.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
BIN
Community.PowerToys.Run.Plugin.YandexGPT/Images/Yandex_Black.png
Normal file
BIN
Community.PowerToys.Run.Plugin.YandexGPT/Images/Yandex_Black.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
135
Community.PowerToys.Run.Plugin.YandexGPT/Main.cs
Normal file
135
Community.PowerToys.Run.Plugin.YandexGPT/Main.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Microsoft.PowerToys.Settings.UI.Library;
|
||||
using Wox.Plugin;
|
||||
using Wox.Plugin.Logger;
|
||||
|
||||
namespace Community.PowerToys.Run.Plugin.YandexGPT;
|
||||
|
||||
public class Main : IPlugin, IContextMenu, ISettingProvider, IDisposable
|
||||
{
|
||||
#region Plugin Info
|
||||
public static string PluginId => "C2218AB0D86F4345B55C60F9418A811C";
|
||||
public string Name => "Yandex GPT";
|
||||
public string Description => "Плагин для выполнения поисковых запросов через Yandex GPT";
|
||||
public IEnumerable<PluginAdditionalOption> AdditionalOptions =>
|
||||
[
|
||||
new PluginAdditionalOption()
|
||||
{
|
||||
Key = nameof(Token),
|
||||
DisplayLabel = "Токен",
|
||||
DisplayDescription = "Ключ доступа к YandexGPT",
|
||||
PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Textbox,
|
||||
TextValue = Token
|
||||
}
|
||||
];
|
||||
#endregion
|
||||
|
||||
private bool _disposed;
|
||||
|
||||
private string? Token { get; set; }
|
||||
private PluginInitContext? Context { get; set; }
|
||||
private string? IconPath { get; set; }
|
||||
|
||||
public void Init(PluginInitContext context)
|
||||
{
|
||||
Log.Info("Init", GetType());
|
||||
Context = context ?? throw new ArgumentNullException(nameof(context));
|
||||
//Context.API.ThemeChanged += OnThemeChanged;
|
||||
//UpdateIconPath(Context.API.GetCurrentTheme());
|
||||
}
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
Log.Info("Query: " + query.Search, GetType());
|
||||
|
||||
return [
|
||||
new()
|
||||
{
|
||||
QueryTextDisplay = query.Search,
|
||||
IcoPath = IconPath,
|
||||
Title = $"YandexGPT: Чет такое",
|
||||
SubTitle = $"Ответ: иди туда!",
|
||||
ToolTipData = new ToolTipData("Ответы", $"Тут ответ\nИ тут ответ"),
|
||||
ContextData = Token,
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public List<ContextMenuResult> LoadContextMenus(Result selectedResult)
|
||||
{
|
||||
Log.Info("LoadContextMenus", GetType());
|
||||
|
||||
if (selectedResult?.ContextData is (int words, TimeSpan transcription))
|
||||
{
|
||||
return
|
||||
[
|
||||
new ContextMenuResult
|
||||
{
|
||||
PluginName = Name,
|
||||
Title = "Copy (Enter)",
|
||||
FontFamily = "Segoe Fluent Icons,Segoe MDL2 Assets",
|
||||
Glyph = "\xE8C8", // Copy
|
||||
AcceleratorKey = Key.Enter,
|
||||
Action = _ => CopyToClipboard(words.ToString()),
|
||||
},
|
||||
new ContextMenuResult
|
||||
{
|
||||
PluginName = Name,
|
||||
Title = "Copy time (Ctrl+Enter)",
|
||||
FontFamily = "Segoe Fluent Icons,Segoe MDL2 Assets",
|
||||
Glyph = "\xE916", // Stopwatch
|
||||
AcceleratorKey = Key.Enter,
|
||||
AcceleratorModifiers = ModifierKeys.Control,
|
||||
Action = _ => CopyToClipboard(transcription.ToString()),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
if (selectedResult?.ContextData is int characters)
|
||||
{
|
||||
return
|
||||
[
|
||||
new ContextMenuResult
|
||||
{
|
||||
PluginName = Name,
|
||||
Title = "Copy (Enter)",
|
||||
FontFamily = "Segoe Fluent Icons,Segoe MDL2 Assets",
|
||||
Glyph = "\xE8C8", // Copy
|
||||
AcceleratorKey = Key.Enter,
|
||||
Action = _ => CopyToClipboard(characters.ToString()),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public Control CreateSettingPanel() => throw new NotImplementedException();
|
||||
|
||||
public void UpdateSettings(PowerLauncherPluginSettings settings)
|
||||
{
|
||||
var tokenSettings = settings.AdditionalOptions.SingleOrDefault(x => x.Key == nameof(Token));
|
||||
if (tokenSettings is null)
|
||||
return;
|
||||
Token = tokenSettings.TextValue;
|
||||
}
|
||||
|
||||
|
||||
private static bool CopyToClipboard(string? value)
|
||||
{
|
||||
if (value != null)
|
||||
Clipboard.SetText(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Log.Info("Dispose", GetType());
|
||||
if (!_disposed)
|
||||
return;
|
||||
_disposed = true;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
14
Community.PowerToys.Run.Plugin.YandexGPT/plugin.json
Normal file
14
Community.PowerToys.Run.Plugin.YandexGPT/plugin.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"ID": "C2218AB0D86F4345B55C60F9418A811C",
|
||||
"ActionKeyword": "YandexGPT",
|
||||
"IsGlobal": false,
|
||||
"Name": "YandexGPT",
|
||||
"Author": "MikhailRaw",
|
||||
"Version": "1.0.0",
|
||||
"Language": "csharp",
|
||||
"Website": "https://git.shahovalov.ru/mikhail/PowerToys.Run.YandexGPT",
|
||||
"ExecuteFileName": "Community.PowerToys.Run.Plugin.YandexGPT.dll",
|
||||
"IcoPathDark": "Images\\Yandex_Black.png",
|
||||
"IcoPathLight": "Images\\Yandex_Black.png",
|
||||
"DynamicLoading": false
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerToys.Run.YandexGPT", "PowerToys.Run.YandexGPT\PowerToys.Run.YandexGPT.csproj", "{5CE18468-6AB9-476F-9935-E12740111946}"
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Items", "Items", "{4A6F7084-0B6D-4C57-8E46-C430B7F343C2}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
readme.md = readme.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Community.PowerToys.Run.Plugin.YandexGPT", "Community.PowerToys.Run.Plugin.YandexGPT\Community.PowerToys.Run.Plugin.YandexGPT.csproj", "{B65D8913-4679-46A0-84EA-DF11C641DDF5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -8,9 +13,9 @@ Global
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5CE18468-6AB9-476F-9935-E12740111946}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5CE18468-6AB9-476F-9935-E12740111946}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5CE18468-6AB9-476F-9935-E12740111946}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5CE18468-6AB9-476F-9935-E12740111946}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B65D8913-4679-46A0-84EA-DF11C641DDF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B65D8913-4679-46A0-84EA-DF11C641DDF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B65D8913-4679-46A0-84EA-DF11C641DDF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B65D8913-4679-46A0-84EA-DF11C641DDF5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user