mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Added button to settings to clear cache
This commit is contained in:
parent
2d457ad12d
commit
ed649cde26
@ -127,6 +127,8 @@ namespace Wabbajack.Common
|
||||
public static AbsolutePath SettingsFile => LocalAppDataPath.Combine("settings.json");
|
||||
public static RelativePath SettingsIni = (RelativePath)"settings.ini";
|
||||
public static byte SettingsVersion => 2;
|
||||
public static AbsolutePath CefCacheLocation = @"CEF".RelativeTo(LocalAppDataPath);
|
||||
|
||||
public static Extension SeqExtension = new Extension(".seq");
|
||||
|
||||
public static RelativePath SettingsJson = (RelativePath)"settings.json";
|
||||
|
@ -12,6 +12,7 @@ using CefSharp;
|
||||
using CefSharp.OffScreen;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.Serialization.Json;
|
||||
using Cookie = CefSharp.Cookie;
|
||||
|
||||
namespace Wabbajack.Lib.LibCefHelpers
|
||||
{
|
||||
@ -89,11 +90,31 @@ namespace Wabbajack.Lib.LibCefHelpers
|
||||
if (Inited) return;
|
||||
Inited = true;
|
||||
CefSettings settings = new CefSettings();
|
||||
settings.CachePath = Path.Combine(Consts.LocalAppDataPath + @"\CEF");
|
||||
settings.CachePath = Consts.CefCacheLocation.ToString();
|
||||
Cef.Initialize(settings);
|
||||
}
|
||||
|
||||
public static bool Inited { get; set; }
|
||||
|
||||
public static void ClearCookies()
|
||||
{
|
||||
var manager = Cef.GetGlobalCookieManager();
|
||||
var visitor = new CookieDeleter();
|
||||
manager.VisitAllCookies(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
class CookieDeleter : ICookieVisitor
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public bool Visit(Cookie cookie, int count, int total, ref bool deleteCookie)
|
||||
{
|
||||
deleteCookie = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ModuleInitializer
|
||||
|
@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using CefSharp;
|
||||
using CefSharp.OffScreen;
|
||||
using Wabbajack.Lib.LibCefHelpers;
|
||||
|
||||
namespace Wabbajack.Lib.WebAutomation
|
||||
{
|
||||
@ -53,5 +54,10 @@ namespace Wabbajack.Lib.WebAutomation
|
||||
{
|
||||
_browser.Dispose();
|
||||
}
|
||||
|
||||
public static void ClearCache()
|
||||
{
|
||||
Helpers.ClearCookies();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,11 +38,15 @@
|
||||
FontFamily="Lucida Sans"
|
||||
FontSize="20"
|
||||
FontWeight="Bold"
|
||||
Text="Modlist Gallery" />
|
||||
Text="Misc Settings" />
|
||||
<Grid
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.Resources>
|
||||
<Style BasedOn="{StaticResource MainButtonStyle}" TargetType="Button">
|
||||
<Style.Triggers>
|
||||
@ -54,11 +58,12 @@
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Grid.Resources>
|
||||
<CheckBox Name="FilterPersistCheckBox" Content="Filters are saved on exit" HorizontalAlignment="Left" Margin="0,5,0,0" VerticalAlignment="Top">
|
||||
<CheckBox Name="FilterPersistCheckBox" Content="Gallery filters are saved on exit" HorizontalAlignment="Left" Margin="0,5,0,0" VerticalAlignment="Top" Grid.Row = "0">
|
||||
<CheckBox.LayoutTransform>
|
||||
<ScaleTransform ScaleX="1.2" ScaleY="1.2" />
|
||||
</CheckBox.LayoutTransform>
|
||||
</CheckBox>
|
||||
<Button Name="ClearCefCache" Content="Clear In-App Browser Cache" Margin="0,5,0,0" Grid.Row="1"></Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
@ -16,6 +16,7 @@ using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using ReactiveUI;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib.WebAutomation;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
@ -33,6 +34,8 @@ namespace Wabbajack
|
||||
// Bind Values
|
||||
this.Bind(this.ViewModel, x => x.IsPersistent, x => x.FilterPersistCheckBox.IsChecked)
|
||||
.DisposeWith(disposable);
|
||||
|
||||
this.ClearCefCache.Click += (sender, args) => {Driver.ClearCache();};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user