Skip to content

Commit

Permalink
✨ 添加禁用 GPU 功能
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiHuaDou committed Jan 13, 2024
1 parent 863e8de commit 38e4d40
Show file tree
Hide file tree
Showing 20 changed files with 91 additions and 62 deletions.
2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
* text=auto
*.dll filter=lfs diff=lfs merge=lfs -text
*.exe filter=lfs diff=lfs merge=lfs -text
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ jobs:
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: Application
name: App
path: ./极简浏览器/bin/Release/net462/*
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Custom
lib/
*.zip
*.7z
*.exe

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
Expand Down Expand Up @@ -187,8 +190,8 @@ publish/
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# *.pubxml
# *.publishproj

# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
Expand Down
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
> 1. 详细信息请参照 [Commit]
> 2. 用斜体显示的是正在开发的
## 3.7.2 (规划内)

## 3.4.7.2 (开发中)

### RC3 (开发中)

+ :sprakles: 可以选择禁用 GPU
+ :sparkles: 支持视频播放(`H.264`)
+ :sparkles: 支持 UI 样式变更
+ :libstick: 移动加载条至状态栏
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 极简浏览器

![][Shields CI] ![][Shields License]
![][Shields Release] ![][Shields Downloads]
![][Shields Lines] ![][Shields Commit]
![][Shields License] ![][Shields Release] ![][Shields Downloads] ![][Shields Commit] ![][Shields CI]

![][Shields CSharp] ![][Shields .NET] ![][Shields OS] ![][Shields IDE] ![][Shields Chromium]

[![Gitmoji][Gitmoji]](https://gitmoji.dev)

Expand Down Expand Up @@ -63,7 +63,11 @@
[Shields License]: https://img.shields.io/github/license/kaihuadou/easybrowseradvanced
[Shields Release]: https://img.shields.io/github/v/release/kaihuadou/easybrowseradvanced
[Shields Downloads]: https://img.shields.io/github/downloads/kaihuadou/easybrowseradvanced/total
[Shields Lines]: https://img.shields.io/tokei/lines/github/kaihuadou/easybrowseradvanced
[Shields Commit]: https://img.shields.io/github/commit-activity/y/kaihuadou/easybrowseradvanced
[Shields CSharp]: https://img.shields.io/badge/11.0-version?logo=csharp&label=C%23&color=%23512BD4
[Shields .NET]: https://img.shields.io/badge/>=4.6.2-version?logo=dotnet&label=.NET%20Framework&color=%23512BD4
[Shields OS]: https://img.shields.io/badge/>=Windows%207%20SP1-version?logo=windows&label=OS&color=%230078D4
[Shields IDE]: https://img.shields.io/badge/2022-version?logo=visual%20studio&label=Visual%20Studio&color=%235C2D91
[Shields Chromium]: https://img.shields.io/badge/87.1.132-version?logo=googlechrome&label=Chromium&color=%234285F4%logoColor=white
[Gitmoji]: https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg
[Cef H.264 库]: https://github.com/KaiHuaDou/EasyBrowserAdvanced/releases/download/v3.4.7.2-h264test/cef-h264-library.zip
12 changes: 8 additions & 4 deletions docs/README.en-US.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# EasyBrowser

![][Shields CI] ![][Shields License]
![][Shields Release] ![][Shields Downloads]
![][Shields Lines] ![][Shields Commit]
![][Shields License] ![][Shields Release] ![][Shields Downloads] ![][Shields Commit] ![][Shields CI]

![][Shields CSharp] ![][Shields .NET] ![][Shields OS] ![][Shields IDE] ![][Shields Chromium]

[![Gitmoji][Gitmoji]](https://gitmoji.dev)

Expand Down Expand Up @@ -63,7 +63,11 @@ Use `dotnet build` to build independently. To build a version that supports vide
[Shields License]: https://img.shields.io/github/license/kaihuadou/easybrowseradvanced
[Shields Release]: https://img.shields.io/github/v/release/kaihuadou/easybrowseradvanced
[Shields Downloads]: https://img.shields.io/github/downloads/kaihuadou/easybrowseradvanced/total
[Shields Lines]: https://img.shields.io/tokei/lines/github/kaihuadou/easybrowseradvanced
[Shields Commit]: https://img.shields.io/github/commit-activity/y/kaihuadou/easybrowseradvanced
[Shields CSharp]: https://img.shields.io/badge/11.0-version?logo=csharp&label=C%23&color=%23512BD4
[Shields .NET]: https://img.shields.io/badge/>=4.6.2-version?logo=dotnet&label=.NET%20Framework&color=%23512BD4
[Shields OS]: https://img.shields.io/badge/>=Windows%207%20SP1-version?logo=windows&label=OS&color=%230078D4
[Shields IDE]: https://img.shields.io/badge/2022-version?logo=visual%20studio&label=Visual%20Studio&color=%235C2D91
[Shields Chromium]: https://img.shields.io/badge/87.1.132-version?logo=googlechrome&label=Chromium&color=%234285F4%logoColor=white
[Gitmoji]: https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg
[Cef H.264 Library]: https://github.com/KaiHuaDou/EasyBrowserAdvanced/releases/download/v3.4.7.2-h264test/cef-h264-library.zip
8 changes: 5 additions & 3 deletions 极简浏览器/Api/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class Config
// 静态对象
public const string mainPageDefault = "about:blank";
public const string searchEngineDefault = "https://cn.bing.com/search?q=";
public const string UIThemeDefault = "Aero.NormalColor";
public const string UANormal = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Easy/3.4.7.2 Chrome/87.0.4280.141 Safari/537.36";
public const string UACheated = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Easy/3.4.7.2 Chrome/114.0.0.0 Safari/537.36";

Expand All @@ -39,6 +38,9 @@ public string SearchEngine
[DefaultValue(false)]
public bool CheatUA { get; set; }

[DefaultValue(UIThemes.AeroNormalColor)]
public UIThemes UITheme { get; set; }
[DefaultValue(false)]
public bool DisableGPU { get; set; }

[DefaultValue((int) UIThemes.AeroNormalColor)]
public int UITheme { get; set; }
}
21 changes: 12 additions & 9 deletions 极简浏览器/Api/DataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,26 @@ public class DataStore<T> : IDisposable where T : new()
{
public List<T> Content { get; private set; }

private string XmlFile;
private string File;
private bool InitEmpty;
private FileStream XmlStream;
private FileStream Stream;
private XmlReader Reader;

public DataStore(string xmlFile, bool initEmpty = true)
{
XmlFile = new FileInfo(xmlFile).FullName;
File = new FileInfo(xmlFile).FullName;
InitEmpty = initEmpty;
XmlStream = new(XmlFile, FileMode.OpenOrCreate);
Stream = new(File, FileMode.OpenOrCreate);
Reader = XmlReader.Create(Stream);
Read( );
}

public void Read( )
{
XmlReader reader = XmlReader.Create(XmlStream);
XmlSerializer serializer = new(typeof(List<T>));
try
{
Content = reader.ReadContentAs(typeof(List<T>), null) as List<T>;
Content = serializer.Deserialize(Reader) as List<T>;
if (Content.Count == 0 && !InitEmpty)
Content.Add(new T( ));
}
Expand All @@ -49,14 +51,15 @@ public void Read( )

public void Save( )
{
XmlStream.SetLength(0);
Stream.SetLength(0);
XmlSerializer serializer = new(typeof(List<T>));
serializer.Serialize(XmlStream, Content);
serializer.Serialize(Stream, Content);
}

public void Dispose( )
{
XmlStream.Dispose( );
Reader.Dispose( );
Stream.Dispose( );
GC.SuppressFinalize(this);
}
}
15 changes: 8 additions & 7 deletions 极简浏览器/Api/Instance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ public static void Init( )
UserDataPath = $@"{FilePath.Runtime}\Profile",
UserAgent = App.Setting.Content[0].CheatUA ? Config.UACheated : Config.UANormal
};
settings.CefCommandLineArgs["enable-media-stream"] = "1";
settings.CefCommandLineArgs["disable-gpu"] = App.Setting.Content[0].DisableGPU ? "1" : "0";
settings.CefCommandLineArgs["disable-gpu-compositing"] = App.Setting.Content[0].DisableGPU ? "1" : "0";
settings.CefCommandLineArgs["enable-system-flash"] = "1";
settings.CefCommandLineArgs["ppapi-flash-path"] = "Resources/pepflashplayer.dll";
settings.CefCommandLineArgs["ppapi-flash-version"] = "99.9.9.999";
Cef.Initialize(settings);
Cef.Initialize(settings, true);
}

public static void PraseEasy(int id, string url)
Expand All @@ -90,10 +91,10 @@ public static async Task<string> PageSourceAsync(int id)
public static MenuItem[] ContextMenu(int Id)
=> new MenuItem[]
{
new MenuItem { Header = "前进", Command = new CustomCommand(( ) => GoForward(Id)) },
new MenuItem { Header = "后退", Command = new CustomCommand(( ) => GoBack(Id)) },
new MenuItem { Header = "刷新", Command = new CustomCommand(( ) => Refresh(Id)) },
new MenuItem { Header = "新窗口", Command = new CustomCommand(( ) => New( )) },
new MenuItem { Header = "网页源代码", Command = new CustomCommand(( ) => ViewSource(Id)) },
new( ) { Header = "前进", Command = new CustomCommand(( ) => GoForward(Id)) },
new( ) { Header = "后退", Command = new CustomCommand(( ) => GoBack(Id)) },
new( ) { Header = "刷新", Command = new CustomCommand(( ) => Refresh(Id)) },
new( ) { Header = "新窗口", Command = new CustomCommand(( ) => New( )) },
new( ) { Header = "网页源代码", Command = new CustomCommand(( ) => ViewSource(Id)) },
};
}
16 changes: 8 additions & 8 deletions 极简浏览器/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ protected override void OnStartup(StartupEventArgs e)
{
Source = new Uri(Setting.Content[0].UITheme switch
{
UIThemes.Classic => "pack://application:,,,/PresentationFramework.Classic,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/Classic.xaml",
UIThemes.LunaNormalColor => "pack://application:,,,/PresentationFramework.Luna,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/Luna.NormalColor.xaml",
UIThemes.LunaHomestead => "pack://application:,,,/PresentationFramework.Luna,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/Luna.Homestead.xaml",
UIThemes.LunaMetallic => "pack://application:,,,/PresentationFramework.Luna,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/Luna.Metallic.xaml",
UIThemes.RoyaleNormalColor => "pack://application:,,,/PresentationFramework.Luna,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/Royale.NormalColor.xaml",
UIThemes.AeroNormalColor => "pack://application:,,,/PresentationFramework.Aero,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/Aero.NormalColor.xaml",
UIThemes.Aero2NormalColor => "pack://application:,,,/PresentationFramework.Aero2,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/Aero2.NormalColor.xaml",
0 => "pack://application:,,,/PresentationFramework.Aero,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/Aero.NormalColor.xaml",
1 => "pack://application:,,,/PresentationFramework.Aero2,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/Aero2.NormalColor.xaml",
2 => "pack://application:,,,/PresentationFramework.Luna,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/Luna.NormalColor.xaml",
3 => "pack://application:,,,/PresentationFramework.Luna,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/Luna.Homestead.xaml",
4 => "pack://application:,,,/PresentationFramework.Luna,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/Luna.Metallic.xaml",
5 => "pack://application:,,,/PresentationFramework.Luna,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/Royale.NormalColor.xaml",
6 => "pack://application:,,,/PresentationFramework.Classic,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/Classic.xaml",
_ => "pack://application:,,,/PresentationFramework.Aero,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,ProcessorArchitecture=MSIL;component/themes/Aero.NormalColor.xaml",
})
});
Expand Down Expand Up @@ -98,7 +98,7 @@ private void AppExit(object o, ExitEventArgs e)

public bool SignalExternalCommandLineArgs(IList<string> args)
{
Instance.New(args.Count > 1 ? args[0] : "");
Instance.New(args.Count > 1 ? args[1] : "");
return true;
}
}
3 changes: 3 additions & 0 deletions 极简浏览器/BrowserExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public partial class MainWindow : Window
private void RefreshClick(object o, Args e) => Instance.Refresh(Id);
private void SettingClick(object o, Args e) => new Setting( ).Show( );
private void TopmostClick(object o, Args e) => Topmost = !Topmost;
private void MuteClick(object o, Args e)
=> _ = 0;

private void ViewSourceClick(object o, Args e) => Instance.ViewSource(Id);

private void SetBookMarkClick(object o, Args e)
Expand Down
5 changes: 4 additions & 1 deletion 极简浏览器/Dialog/Download.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ private void OpenClick(object o, RoutedEventArgs e)
=> Process.Start(filePath);

private void OpenFolderClick(object o, RoutedEventArgs e)
=> Process.Start(Directory.GetParent(filePath).FullName);
{
try { Process.Start(Directory.GetParent(filePath).FullName); }
catch(FileNotFoundException) {}
}

private void CancelTask( )
{
Expand Down
10 changes: 0 additions & 10 deletions 极简浏览器/Dialog/Help.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@
<TreeView Margin="10"
Background="White" BorderThickness="0"
FocusVisualStyle="{x:Null}">
<TreeViewItem Header="无法播放视频" IsExpanded="True">
<TreeViewItem>
<TreeViewItem.Header>
<TextBlock Width="370" Margin="0" TextWrapping="Wrap">
<Run>对不起,我们也解决不了这个问题,如果您有什么解决方案,请</Run>
<Hyperlink NavigateUri="https://github.com/KaiHuaDou/EasyBrowserAdvanced/issue/3">告诉我们</Hyperlink>
</TextBlock>
</TreeViewItem.Header>
</TreeViewItem>
</TreeViewItem>
<TreeViewItem Header="无法显示图标" IsExpanded="True">
<TreeViewItem>
<TreeViewItem.Header>
Expand Down
16 changes: 10 additions & 6 deletions 极简浏览器/Dialog/Setting.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Label Height="34" Margin="0,0,0,5" Content="主页:" />
<TextBox x:Name="MainPageBox"
Expand All @@ -39,31 +40,34 @@
Content="界面主题:" />
<StackPanel Grid.Row="2" Grid.Column="1" Margin="0,5,0,5">
<ComboBox x:Name="UIThemeBox" SelectedIndex="5" SelectionChanged="UIThemeBoxSelectionChanged">
<System:String>Classic</System:String>
<System:String>Aero.NormalColor</System:String>
<System:String>Aero2.NormalColor</System:String>
<System:String>Luna.NormalColor</System:String>
<System:String>Luna.Homestead</System:String>
<System:String>Luna.Metallic</System:String>
<System:String>Royale.NormalColor</System:String>
<System:String>Aero.NormalColor</System:String>
<System:String>Aero2.NormalColor</System:String>
<System:String>Classic</System:String>
</ComboBox>
<Label x:Name="UIThemeText" />
</StackPanel>
<CheckBox x:Name="CheckUaBox"
Grid.Row="3" Grid.ColumnSpan="2"
Margin="0,5,0,5"
Content="伪装 User-Agent" />
<StackPanel Grid.Row="4" Grid.ColumnSpan="2" Orientation="Horizontal">
<CheckBox x:Name="DisableGpuBox"
Grid.Row="4" Grid.ColumnSpan="2"
Margin="0,5,0,5"
Content="禁用 GPU 加速" />
<StackPanel Grid.Row="5" Grid.ColumnSpan="2" Orientation="Horizontal">
<Button x:Name="CacheButton"
Margin="0,5,5,5" Padding="30,3"
Click="ClearCache" Content="清除缓存" />
<Button x:Name="LogButton"
Margin="5,5,0,5" Padding="30,3"
Click="ClearLog" Content="清除日志" />
</StackPanel>

<Button x:Name="OKButton"
Grid.Row="5" Grid.Column="1"
Grid.Row="6" Grid.Column="1"
Margin="0,5,0,0" Padding="30,3" HorizontalAlignment="Right"
Click="OKClick" Content="确定" />
</Grid>
Expand Down
5 changes: 3 additions & 2 deletions 极简浏览器/Dialog/Setting.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public Setting( )
MainPageBox.Text = App.Setting.Content[0].MainPage;
SearchEngineBox.Text = App.Setting.Content[0].SearchEngine;
CheckUaBox.IsChecked = App.Setting.Content[0].CheatUA;
UIThemeBox.SelectedIndex = (int) App.Setting.Content[0].UITheme;
UIThemeBox.SelectedIndex = App.Setting.Content[0].UITheme;
}

private void OKClick(object o, RoutedEventArgs e)
Expand All @@ -26,7 +26,8 @@ private void OKClick(object o, RoutedEventArgs e)
MainPage = MainPageBox.Text,
SearchEngine = SearchEngineBox.Text,
CheatUA = (bool) CheckUaBox.IsChecked,
UITheme = (UIThemes) UIThemeBox.SelectedIndex
DisableGPU = (bool) DisableGpuBox.IsChecked,
UITheme = UIThemeBox.SelectedIndex
});
App.Setting.Save( );
Close( );
Expand Down
1 change: 1 addition & 0 deletions 极简浏览器/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
Click="GoForwardClick" Content="&#xE72A;" />
<Button x:Name="SubmenuButton"
DockPanel.Dock="Right"
Margin="4,8,8,8"
Style="{StaticResource NavButton}"
Click="SubmenuClick" Content="&#xE712;" />
<Button x:Name="NewPageButton"
Expand Down
2 changes: 1 addition & 1 deletion 极简浏览器/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace 极简浏览器;

/// <summary>
/// 主窗口的交互代码
/// 负责:ChromiumWebBrowser 的相关事宜、初始化
/// 负责:ChromiumWebBrowser 相关、初始化
/// </summary>
public partial class MainWindow : Window, IDisposable
{
Expand Down
12 changes: 12 additions & 0 deletions 极简浏览器/Properties/PublishProfiles/FolderProfile.pubxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>x86</Platform>
<PublishDir>bin\publish</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net462</TargetFramework>
<RuntimeIdentifier>win7-x86</RuntimeIdentifier>
</PropertyGroup>
</Project>
1 change: 1 addition & 0 deletions 极简浏览器/Resources/Error.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"ConnectionRefused": "访问被拒绝",
"ConnectionReset": "连接已重置",
"ConnectionTimedOut": "响应时间过长",
"InternetDisconnected": "网络未连接",
"FileNotFound": "找不到文件",
"InvalidUrl": "无效 URL 地址",
"NameNotResolved": "无法解析地址",
Expand Down
Binary file modified 极简浏览器/Resources/pepflashplayer.dll
Binary file not shown.

0 comments on commit 38e4d40

Please sign in to comment.