mirror of
https://github.com/nsnail/dot.git
synced 2025-06-17 21:13:21 +08:00
<adjust> * 多平台支持
This commit is contained in:
parent
ea75f46af3
commit
f4b7c5d0ad
@ -1,3 +1,4 @@
|
|||||||
dotnet build
|
dotnet build
|
||||||
dotnet publish -c Release -r win-x64 --sc -p:"PublishSingleFile=true" -o ./build/win-x64
|
dotnet publish -f net7.0-windows -c Release -r win-x64 --sc -p:"PublishSingleFile=true" -o ./build/win-x64
|
||||||
|
dotnet publish -f net7.0 -c Release -r linux-x64 --sc -p:"PublishSingleFile=true" -o ./build/linux-x64
|
||||||
Remove-Item -r ./build/temp
|
Remove-Item -r ./build/temp
|
@ -1,3 +1,4 @@
|
|||||||
|
#if NET7_0_WINDOWS
|
||||||
namespace Dot.Color;
|
namespace Dot.Color;
|
||||||
|
|
||||||
public sealed class Main : ToolBase<Option>
|
public sealed class Main : ToolBase<Option>
|
||||||
@ -11,3 +12,5 @@ public sealed class Main : ToolBase<Option>
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -1,3 +1,4 @@
|
|||||||
|
#if NET7_0_WINDOWS
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@ -73,3 +74,4 @@ public class MouseHook : IDisposable
|
|||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
@ -1,3 +1,4 @@
|
|||||||
|
#if NET7_0_WINDOWS
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using Size = System.Drawing.Size;
|
using Size = System.Drawing.Size;
|
||||||
|
|
||||||
@ -82,3 +83,4 @@ public class WinInfo : Form
|
|||||||
_pbox.Refresh();
|
_pbox.Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
@ -1,3 +1,4 @@
|
|||||||
|
#if NET7_0_WINDOWS
|
||||||
using TextCopy;
|
using TextCopy;
|
||||||
|
|
||||||
namespace Dot.Color;
|
namespace Dot.Color;
|
||||||
@ -53,8 +54,7 @@ public class WinMain : Form
|
|||||||
protected override void OnMouseDown(MouseEventArgs e)
|
protected override void OnMouseDown(MouseEventArgs e)
|
||||||
{
|
{
|
||||||
var color = _bmp.GetPixel(e.X, e.Y);
|
var color = _bmp.GetPixel(e.X, e.Y);
|
||||||
ClipboardService.SetText(
|
ClipboardService.SetText($"{e.X},{e.Y} #{color.R:X2}{color.G:X2}{color.B:X2}({color.R},{color.G},{color.B})");
|
||||||
$"{e.X},{e.Y} #{color.R.ToString("X2")}{color.G.ToString("X2")}{color.B.ToString("X2")}({color.R},{color.G},{color.B})");
|
|
||||||
Application.Exit();
|
Application.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,3 +70,5 @@ public class WinMain : Form
|
|||||||
Opacity = 1;
|
Opacity = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -1,4 +1,6 @@
|
|||||||
|
#if NET7_0_WINDOWS
|
||||||
using TextCopy;
|
using TextCopy;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Dot.Guid;
|
namespace Dot.Guid;
|
||||||
|
|
||||||
@ -11,8 +13,10 @@ public sealed class Main : ToolBase<Option>
|
|||||||
{
|
{
|
||||||
var guid = System.Guid.NewGuid().ToString();
|
var guid = System.Guid.NewGuid().ToString();
|
||||||
if (Opt.Upper) guid = guid.ToUpper();
|
if (Opt.Upper) guid = guid.ToUpper();
|
||||||
ClipboardService.SetText(guid);
|
|
||||||
Console.WriteLine(Str.Copied, guid);
|
Console.WriteLine(Str.Copied, guid);
|
||||||
|
#if NET7_0_WINDOWS
|
||||||
|
ClipboardService.SetText(guid);
|
||||||
|
#endif
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,9 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using NSExt.Extensions;
|
using NSExt.Extensions;
|
||||||
|
#if NET7_0_WINDOWS
|
||||||
using TextCopy;
|
using TextCopy;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace Dot.Json;
|
namespace Dot.Json;
|
||||||
|
|
||||||
@ -10,7 +13,11 @@ public class Main : ToolBase<Option>
|
|||||||
|
|
||||||
public Main(Option opt) : base(opt)
|
public Main(Option opt) : base(opt)
|
||||||
{
|
{
|
||||||
var inputText = ClipboardService.GetText();
|
var inputText = Opt.InputText;
|
||||||
|
|
||||||
|
#if NET7_0_WINDOWS
|
||||||
|
if (inputText.NullOrWhiteSpace()) inputText = ClipboardService.GetText();
|
||||||
|
#endif
|
||||||
if (inputText.NullOrWhiteSpace()) throw new ArgumentException(Str.InputTextIsEmpty);
|
if (inputText.NullOrWhiteSpace()) throw new ArgumentException(Str.InputTextIsEmpty);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -63,6 +70,8 @@ public class Main : ToolBase<Option>
|
|||||||
else if (Opt.Format) result = await JsonFormat();
|
else if (Opt.Format) result = await JsonFormat();
|
||||||
|
|
||||||
if (result.NullOrWhiteSpace()) return;
|
if (result.NullOrWhiteSpace()) return;
|
||||||
|
#if NET7_0_WINDOWS
|
||||||
await ClipboardService.SetTextAsync(result!);
|
await ClipboardService.SetTextAsync(result!);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,4 +12,7 @@ public class Option : OptionBase
|
|||||||
|
|
||||||
[Option('f', "format", HelpText = nameof(Str.FormatJson), Default = true, ResourceType = typeof(Str))]
|
[Option('f', "format", HelpText = nameof(Str.FormatJson), Default = true, ResourceType = typeof(Str))]
|
||||||
public bool Format { get; set; }
|
public bool Format { get; set; }
|
||||||
|
|
||||||
|
[Value(0, HelpText = nameof(Str.TextTobeProcessed), ResourceType = typeof(Str))]
|
||||||
|
public string InputText { get; set; }
|
||||||
}
|
}
|
@ -1,5 +1,8 @@
|
|||||||
using NSExt.Extensions;
|
using NSExt.Extensions;
|
||||||
|
#if NET7_0_WINDOWS
|
||||||
using TextCopy;
|
using TextCopy;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace Dot.Pwd;
|
namespace Dot.Pwd;
|
||||||
|
|
||||||
@ -46,8 +49,10 @@ public sealed class Main : ToolBase<Option>
|
|||||||
*(pDest + i) = *(pSource + randScope.Rand());
|
*(pDest + i) = *(pSource + randScope.Rand());
|
||||||
|
|
||||||
var result = new string(pDest, 0, Opt.Length);
|
var result = new string(pDest, 0, Opt.Length);
|
||||||
ClipboardService.SetText(result);
|
|
||||||
Console.WriteLine(Str.Copied, result);
|
Console.WriteLine(Str.Copied, result);
|
||||||
|
#if NET7_0_WINDOWS
|
||||||
|
ClipboardService.SetText(result);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
using System.Diagnostics;
|
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using NSExt.Extensions;
|
using NSExt.Extensions;
|
||||||
|
#if NET7_0_WINDOWS
|
||||||
using TextCopy;
|
using TextCopy;
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Dot.Text;
|
namespace Dot.Text;
|
||||||
|
|
||||||
@ -98,14 +100,18 @@ html-encode: {o.HtmlEncode}
|
|||||||
html-decode: {o.HtmlDecode}
|
html-decode: {o.HtmlDecode}
|
||||||
""";
|
""";
|
||||||
Console.WriteLine(outputTemp);
|
Console.WriteLine(outputTemp);
|
||||||
|
#if NET7_0_WINDOWS
|
||||||
var file = Path.Combine(Path.GetTempPath(), $"{System.Guid.NewGuid()}.html");
|
var file = Path.Combine(Path.GetTempPath(), $"{System.Guid.NewGuid()}.html");
|
||||||
File.WriteAllText(file, outputTemp.Text2Html());
|
File.WriteAllText(file, outputTemp.Text2Html());
|
||||||
Process.Start("explorer", file);
|
Process.Start("explorer", file);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task Core()
|
protected override async Task Core()
|
||||||
{
|
{
|
||||||
|
#if NET7_0_WINDOWS
|
||||||
if (Opt.Text.NullOrEmpty()) Opt.Text = await ClipboardService.GetTextAsync();
|
if (Opt.Text.NullOrEmpty()) Opt.Text = await ClipboardService.GetTextAsync();
|
||||||
|
#endif
|
||||||
if (Opt.Text.NullOrEmpty()) throw new ArgumentException(Str.InputTextIsEmpty);
|
if (Opt.Text.NullOrEmpty()) throw new ArgumentException(Str.InputTextIsEmpty);
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,7 +14,9 @@ public static class ToolsFactory
|
|||||||
, Text.Option o => new Text.Main(o)
|
, Text.Option o => new Text.Main(o)
|
||||||
, Guid.Option o => new Guid.Main(o)
|
, Guid.Option o => new Guid.Main(o)
|
||||||
, Time.Option o => new Time.Main(o)
|
, Time.Option o => new Time.Main(o)
|
||||||
|
#if NET7_0_WINDOWS
|
||||||
, Color.Option o => new Color.Main(o)
|
, Color.Option o => new Color.Main(o)
|
||||||
|
#endif
|
||||||
, IP.Option o => new IP.Main(o)
|
, IP.Option o => new IP.Main(o)
|
||||||
, Git.Option o => new Git.Main(o)
|
, Git.Option o => new Git.Main(o)
|
||||||
, Json.Option o => new Json.Main(o)
|
, Json.Option o => new Json.Main(o)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net7.0-windows</TargetFramework>
|
<TargetFrameworks>net7.0-windows;net7.0</TargetFrameworks>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms Condition="'$(TargetFramework)' == 'net7.0-windows'">true</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<RootNamespace>Dot</RootNamespace>
|
<RootNamespace>Dot</RootNamespace>
|
||||||
<AssemblyName>dot</AssemblyName>
|
<AssemblyName>dot</AssemblyName>
|
||||||
@ -13,6 +13,9 @@
|
|||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<AssemblyTitle>功能全面的实用工具 - 程序员的瑞士军刀</AssemblyTitle>
|
<AssemblyTitle>功能全面的实用工具 - 程序员的瑞士军刀</AssemblyTitle>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(TargetFramework)' == 'net7.0-windows'">
|
||||||
|
<DefineConstants>$(DefineConstants);NET7_0_WINDOWS</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@ -23,7 +26,7 @@
|
|||||||
<PackageReference Include="CommandLineParser" Version="2.9.1"/>
|
<PackageReference Include="CommandLineParser" Version="2.9.1"/>
|
||||||
<PackageReference Include="NSExt" Version="1.0.8"/>
|
<PackageReference Include="NSExt" Version="1.0.8"/>
|
||||||
<PackageReference Include="Spectre.Console" Version="0.45.1-preview.0.46"/>
|
<PackageReference Include="Spectre.Console" Version="0.45.1-preview.0.46"/>
|
||||||
<PackageReference Include="TextCopy" Version="6.2.0"/>
|
<PackageReference Condition="'$(TargetFramework)' == 'net7.0-windows'" Include="TextCopy" Version="6.2.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Update="Lang\Str.resx">
|
<EmbeddedResource Update="Lang\Str.resx">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user