1.0.1 (beta) 更新

This commit is contained in:
Space Time 2022-04-30 21:16:39 +08:00
parent 971e7adab7
commit dff4ce4a70
10 changed files with 129 additions and 51 deletions

View File

@ -1,8 +1,7 @@
<Application x:Class="Sheas_Cealer.App" <Application x:Class="Sheas_Cealer.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
StartupUri="Windows/MainWindow.xaml">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>

View File

@ -4,5 +4,9 @@ namespace Sheas_Cealer
{ {
public partial class App : Application public partial class App : Application
{ {
protected override void OnStartup(StartupEventArgs e)
{
new MainWindow(e.Args).Show();
}
} }
} }

BIN
Cealing-Clash.exe Normal file

Binary file not shown.

View File

@ -1,11 +1,12 @@
[ [
[["*pixiv.net"],"fanbox.cc","172.64.151.90"],
[["*pximg.net"],"pxi","210.140.92.149"],
[["*pinterest.com"],"pin","2.18.233.9"],
[["*e-hentai.org"],"ehe","104.20.134.21"], [["*e-hentai.org"],"ehe","104.20.134.21"],
[["*exhentai.org"],"exh","178.175.129.254"], [["*exhentai.org"],"exh","178.175.129.254"],
[["*wikipedia.org","*wikimedia.org"],"wik","91.198.174.192"], [["*wikipedia.org","*wikimedia.org"],"wik","91.198.174.192"],
[["*steamcommunity.com"],"ste","104.92.74.217"], [["*steamcommunity.com"],"ste","104.92.74.217"],
[["*instagram.com"],"ins","157.240.236.174"], [["*instagram.com"],"ins","157.240.236.174"],
[["*pinterest.com"],"pin","2.18.233.9"],
[["*amazon.co.jp"],"ama","52.222.208.138"], [["*amazon.co.jp"],"ama","52.222.208.138"],
[["*pixiv.net"],"fanbox.cc","172.64.151.90"], [["*github.com"],"git","140.82.121.3"]
[["*pximg.net"],"pxi","210.140.92.149"]
] ]

23
Commons/Clash.cs Normal file
View File

@ -0,0 +1,23 @@
using System;
using System.Diagnostics;
using SheasCore;
namespace Sheas_Cealer
{
internal class Clash : Proc
{
internal Clash() : base("Cealing-Clash.exe")
{
}
public override void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
}
public override void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
}
public override void Process_Exited(object sender, EventArgs e)
{
}
}
}

View File

@ -6,9 +6,8 @@ namespace Sheas_Cealer
{ {
internal class Cmd : Proc internal class Cmd : Proc
{ {
public Cmd() : base("Cmd.exe") internal Cmd() : base("Cmd.exe")
{ {
//Control.CheckForIllegalCrossThreadCalls = false;
} }
public override void Process_OutputDataReceived(object sender, DataReceivedEventArgs e) public override void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)

View File

@ -8,10 +8,10 @@
<PackageReleaseNotes>Just Ceal It</PackageReleaseNotes> <PackageReleaseNotes>Just Ceal It</PackageReleaseNotes>
<Authors>Space Time</Authors> <Authors>Space Time</Authors>
<Company>Space Time</Company> <Company>Space Time</Company>
<AssemblyVersion>1.0.0</AssemblyVersion> <AssemblyVersion>1.0.1</AssemblyVersion>
<Version>1.0.0</Version> <Version>1.0.1</Version>
<FileVersion>1.0.0</FileVersion> <FileVersion>1.0.1</FileVersion>
<InformationalVersion>1.0.0</InformationalVersion> <InformationalVersion>1.0.1</InformationalVersion>
<PackageTags>Tool;Sheas;Cealer;Sni</PackageTags> <PackageTags>Tool;Sheas;Cealer;Sni</PackageTags>
<ApplicationIcon>Sheas-Cealer-Logo.ico</ApplicationIcon> <ApplicationIcon>Sheas-Cealer-Logo.ico</ApplicationIcon>
<PackageIcon>Sheas Cealer Logo.png</PackageIcon> <PackageIcon>Sheas Cealer Logo.png</PackageIcon>
@ -48,6 +48,11 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Remove=".gitattributes" />
<None Remove=".gitignore" />
<None Remove="Cealing-Clash.exe" />
<None Remove="Cealing-Host.json" />
<None Remove="Clash.exe" />
<None Remove="README.md" /> <None Remove="README.md" />
<None Remove="Sheas-Cealer-Logo.ico" /> <None Remove="Sheas-Cealer-Logo.ico" />
</ItemGroup> </ItemGroup>

View File

@ -9,14 +9,13 @@ namespace Sheas_Cealer
{ {
public partial class AboutWindow : Window public partial class AboutWindow : Window
{ {
public AboutWindow() internal AboutWindow()
{ {
InitializeComponent(); InitializeComponent();
} }
private void AboutWin_Loaded(object sender, RoutedEventArgs e) private void AboutWin_Loaded(object sender, RoutedEventArgs e)
{ {
try { UpdateButton.Content = "版本号: " + Assembly.GetExecutingAssembly().GetName().Version!.ToString()[0..^2]; } UpdateButton.Content = "版本号: " + Assembly.GetExecutingAssembly().GetName().Version!.ToString()[0..^2];
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
} }
private void AboutButton_Click(object sender, RoutedEventArgs e) private void AboutButton_Click(object sender, RoutedEventArgs e)

View File

@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" mc:Ignorable="d"
Style="{DynamicResource CommonWindow}" Style="{DynamicResource CommonWindow}"
WindowStartupLocation="CenterScreen" SizeToContent="Height" ResizeMode="CanMinimize" Width="500" MinWidth="500" Loaded="MainWin_Loaded" KeyDown="MainWin_KeyDown"> WindowStartupLocation="CenterScreen" SizeToContent="Height" ResizeMode="CanMinimize" Width="500" MinWidth="500" AllowDrop="True" Loaded="MainWin_Loaded" Closing="MainWin_Closing" KeyDown="MainWin_KeyDown" DragEnter="MainWin_DragEnter" Drop="MainWin_Drop">
<Grid Margin="5"> <Grid Margin="5">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*" /> <RowDefinition Height="*" />
@ -17,7 +17,7 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TextBox x:Name="ShowBox" Text="(填入任意以 Chromium 为内核的浏览器的路径)" Foreground="#FFBFCDDB" Grid.Column="0" Margin="0,0,10,0" VerticalContentAlignment="Center" GotFocus="ShowBox_GotFocus" LostFocus="ShowBox_LostFocus" TextChanged="ShowBox_TextChanged" /> <TextBox x:Name="ShowBox" Text="(填入任意以 Chromium 为内核的浏览器的路径)" Foreground="#FFBFCDDB" Grid.Column="0" Margin="0,0,10,0" VerticalContentAlignment="Center" GotFocus="ShowBox_GotFocus" LostFocus="ShowBox_LostFocus" TextChanged="ShowBox_TextChanged" PreviewDragOver="MainWin_DragEnter" />
<Button x:Name="ViewButton" Grid.Column="2" Content="浏览" Click="ViewButton_Click" /> <Button x:Name="ViewButton" Grid.Column="2" Content="浏览" Click="ViewButton_Click" />
</Grid> </Grid>
@ -26,10 +26,12 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button x:Name="EditButton" Content="编辑" Grid.Column="0" Margin="0,0,5,0" Click="EditButton_Click" /> <Button x:Name="EditButton" Content="编辑" Grid.Column="0" Margin="0,0,5,0" Click="EditButton_Click" />
<Button x:Name="OpenButton" Content="启动" Grid.Column="1" Margin="5,0,5,0" IsDefault="True" IsEnabled="False" Click="OpenButton_Click" /> <Button x:Name="ClashButton" Content="代理" Grid.Column="1" Margin="5,0,5,0" Click="ClashButton_Click" />
<Button x:Name="AboutButton" Content="关于" Grid.Column="2" Margin="5,0,0,0" Click="AboutButton_Click" /> <Button x:Name="OpenButton" Content="启动" Grid.Column="2" Margin="5,0,5,0" IsDefault="True" IsEnabled="False" Click="OpenButton_Click" />
<Button x:Name="AboutButton" Content="关于" Grid.Column="3" Margin="5,0,0,0" Click="AboutButton_Click" />
</Grid> </Grid>
</Grid> </Grid>
</Window> </Window>

View File

@ -5,6 +5,7 @@ using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Threading;
using IWshRuntimeLibrary; using IWshRuntimeLibrary;
using Microsoft.Win32; using Microsoft.Win32;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
@ -15,8 +16,9 @@ namespace Sheas_Cealer
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
private static string? CEALING_ARGUMENT; private static string? CEALING_ARGUMENT;
private static readonly DispatcherTimer MONITOR_TIMER = new() { Interval = new TimeSpan(1000000) }; //0.1s
public MainWindow() internal MainWindow(string[] args)
{ {
InitializeComponent(); InitializeComponent();
@ -24,17 +26,23 @@ namespace Sheas_Cealer
{ {
Task.Run(() => Task.Run(() =>
{ {
MONITOR_TIMER.Tick += MONITOR_TIMER_Tick;
MONITOR_TIMER.Start();
if (args.Length > 0)
Dispatcher.Invoke(() => ShowBox.Text = args[0]);
else if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.BrowserPath))
Dispatcher.Invoke(() => ShowBox.Text = Properties.Settings.Default.BrowserPath);
string hostRules = string.Empty, hostResolverRules = string.Empty; string hostRules = string.Empty, hostResolverRules = string.Empty;
FileStream hostStream = new(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Cealing-Host.json"), FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); FileStream hostStream = new(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, @"Cealing-Host.json"), FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
JArray hostJArray = JArray.Parse(new StreamReader(hostStream).ReadToEnd()); JArray hostJArray = JArray.Parse(new StreamReader(hostStream).ReadToEnd());
foreach (var hostJToken in hostJArray) foreach (var hostJToken in hostJArray)
{ {
hostResolverRules += "MAP " + hostJToken[1]!.ToString() + " " + hostJToken[2]!.ToString() + ","; hostResolverRules += "MAP " + hostJToken[1]!.ToString() + " " + hostJToken[2]!.ToString() + ",";
foreach (var hostName in hostJToken[0]!) foreach (var hostName in hostJToken[0]!)
hostRules += "MAP " + hostName.ToString() + " " + hostJToken[1] + ","; hostRules += "MAP " + hostName.ToString() + " " + hostJToken[1] + ",";
} }
CEALING_ARGUMENT = @"/c @start .\""Uncealed-Browser.lnk"" --host-rules=""" + hostRules[0..^1] + @""" --host-resolver-rules=""" + hostResolverRules[0..^1] + @""" --test-type --ignore-certificate-errors"; CEALING_ARGUMENT = @"/c @start .\""Uncealed-Browser.lnk"" --host-rules=""" + hostRules[0..^1] + @""" --host-resolver-rules=""" + hostResolverRules[0..^1] + @""" --test-type --ignore-certificate-errors";
}); });
} }
@ -42,40 +50,29 @@ namespace Sheas_Cealer
} }
private void MainWin_Loaded(object sender, RoutedEventArgs e) private void MainWin_Loaded(object sender, RoutedEventArgs e)
{ {
try ShowBox.Focus();
{ }
ShowBox.Focus(); private void MainWin_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.BrowserPath)) Environment.Exit(0);
ShowBox.Text = Properties.Settings.Default.BrowserPath;
}
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
} }
private void ShowBox_GotFocus(object sender, RoutedEventArgs e) private void ShowBox_GotFocus(object sender, RoutedEventArgs e)
{ {
try if (ShowBox.Foreground != Foreground)
{ {
if (ShowBox.Foreground != Foreground) //PlaceHold状态
{ ShowBox.Text = string.Empty;
//PlaceHold状态 ShowBox.Foreground = Foreground;
ShowBox.Text = string.Empty;
ShowBox.Foreground = Foreground;
}
} }
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
} }
private void ShowBox_LostFocus(object sender, RoutedEventArgs e) private void ShowBox_LostFocus(object sender, RoutedEventArgs e)
{ {
try if (string.IsNullOrEmpty(ShowBox.Text))
{ {
if (string.IsNullOrEmpty(ShowBox.Text)) ShowBox.Text = "(填入任意以 Chromium 为内核的浏览器的路径)";
{ ShowBox.Foreground = new SolidColorBrush(Color.FromRgb(191, 205, 219));
ShowBox.Text = "(填入任意以 Chromium 为内核的浏览器的路径)";
ShowBox.Foreground = new SolidColorBrush(Color.FromRgb(191, 205, 219));
}
} }
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
} }
private void ShowBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) private void ShowBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{ {
@ -97,6 +94,29 @@ namespace Sheas_Cealer
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
} }
private void MainWin_DragEnter(object sender, DragEventArgs e)
{
try
{
e.Handled = true;
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effects = DragDropEffects.Link;
else
e.Effects = DragDropEffects.None;
}
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
}
private void MainWin_Drop(object sender, DragEventArgs e)
{
try
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
ShowBox.Text = ((string[])e.Data.GetData(DataFormats.FileDrop))[0];
}
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
}
private void ViewButton_Click(object sender, RoutedEventArgs e) private void ViewButton_Click(object sender, RoutedEventArgs e)
{ {
try try
@ -121,6 +141,28 @@ namespace Sheas_Cealer
} }
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
} }
private void ClashButton_Click(object sender, RoutedEventArgs e)
{
try
{
RegistryKey proxyKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Internet Settings", true)!;
if (ClashButton.Content.ToString() == "代理")
{
proxyKey.SetValue("ProxyEnable", 1);
proxyKey.SetValue("ProxyServer", "127.0.0.1:7890");
new Clash().ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, string.Empty);
}
else
{
proxyKey.SetValue("ProxyEnable", 0);
foreach (Process clashProcess in Process.GetProcessesByName("Cealing-Clash"))
clashProcess.Kill();
}
}
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; }
}
private void OpenButton_Click(object sender, RoutedEventArgs e) private void OpenButton_Click(object sender, RoutedEventArgs e)
{ {
try try
@ -133,14 +175,10 @@ namespace Sheas_Cealer
uncealedBrowserShortcut.Description = "Created By Sheas Cealer"; uncealedBrowserShortcut.Description = "Created By Sheas Cealer";
uncealedBrowserShortcut.Save(); uncealedBrowserShortcut.Save();
string fileName = Path.GetFileNameWithoutExtension(ShowBox.Text); foreach (Process browserProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(ShowBox.Text)))
foreach (Process process in Process.GetProcesses())
{ {
if (process.ProcessName == fileName) browserProcess.Kill();
{ browserProcess.WaitForExit();
process.Kill();
process.WaitForExit();
}
} }
new Cmd().ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, CEALING_ARGUMENT); new Cmd().ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, CEALING_ARGUMENT);
@ -152,6 +190,14 @@ namespace Sheas_Cealer
new AboutWindow().ShowDialog(); new AboutWindow().ShowDialog();
} }
private void MONITOR_TIMER_Tick(object? sender, EventArgs e)
{
if (Process.GetProcessesByName("Cealing-Clash").Length == 0)
ClashButton.Content = "代理";
else
ClashButton.Content = "停代";
}
private void MainWin_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) private void MainWin_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{ {
if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.W) if (e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.W)