Merge branch '2dust:master' into patch-1

This commit is contained in:
alphax-hue3682 2025-01-10 12:33:34 +03:30 committed by GitHub
commit 5bf2304fa4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 167 additions and 164 deletions

View file

@ -0,0 +1,13 @@
namespace ServiceLib.Enums
{
public enum ETheme
{
FollowSystem,
Dark,
Light,
Aquatic,
Desert,
Dusk,
NightSky
}
}

View file

@ -105,6 +105,7 @@
public bool ColorModeDark { get; set; }
public bool FollowSystemTheme { get; set; }
public string? ColorPrimaryName { get; set; }
public string? CurrentTheme { get; set; }
public string CurrentLanguage { get; set; }
public string CurrentFontFamily { get; set; }
public int CurrentFontSize { get; set; }

View file

@ -3463,6 +3463,15 @@ namespace ServiceLib.Resx {
}
}
/// <summary>
/// 查找类似 Theme 的本地化字符串。
/// </summary>
public static string TbSettingsTheme {
get {
return ResourceManager.GetString("TbSettingsTheme", resourceCulture);
}
}
/// <summary>
/// 查找类似 Enable Security Protocol TLS v1.3 (subscription/update) 的本地化字符串。
/// </summary>

View file

@ -1402,4 +1402,7 @@
<data name="TbRoutingInboundTagTips" xml:space="preserve">
<value>socks:پورت محلی، socks2: پورت دوم محلی، socks3: پورت LAN</value>
</data>
</root>
<data name="TbSettingsTheme" xml:space="preserve">
<value>Theme</value>
</data>
</root>

View file

@ -1402,4 +1402,7 @@
<data name="TbRoutingInboundTagTips" xml:space="preserve">
<value>socks: local port, socks2: second local port, socks3: LAN port</value>
</data>
<data name="TbSettingsTheme" xml:space="preserve">
<value>Theme</value>
</data>
</root>

View file

@ -1402,4 +1402,7 @@
<data name="TbRoutingInboundTagTips" xml:space="preserve">
<value>socks: local port, socks2: second local port, socks3: LAN port</value>
</data>
<data name="TbSettingsTheme" xml:space="preserve">
<value>Theme</value>
</data>
</root>

View file

@ -1402,4 +1402,7 @@
<data name="TbRoutingInboundTagTips" xml:space="preserve">
<value>socks: local port, socks2: second local port, socks3: LAN port</value>
</data>
<data name="TbSettingsTheme" xml:space="preserve">
<value>Theme</value>
</data>
</root>

View file

@ -1399,4 +1399,7 @@
<data name="TbRoutingInboundTagTips" xml:space="preserve">
<value>socks本地端口socks2第二个本地端口socks3局域网端口</value>
</data>
<data name="TbSettingsTheme" xml:space="preserve">
<value>主题</value>
</data>
</root>

View file

@ -1400,4 +1400,7 @@
<data name="TbRoutingInboundTagTips" xml:space="preserve">
<value>socks本地端口socks2第二個本地端口socks3區域網路端口</value>
</data>
<data name="TbSettingsTheme" xml:space="preserve">
<value>主題</value>
</data>
</root>

View file

@ -1259,7 +1259,8 @@ namespace ServiceLib.Services.CoreConfig
singboxConfig.experimental ??= new Experimental4Sbox();
singboxConfig.experimental.cache_file = new CacheFile4Sbox()
{
enabled = true
enabled = true,
path = Utils.GetConfigPath("cache.db")
};
}

View file

@ -6,14 +6,14 @@ using Avalonia.Media;
using Avalonia.Styling;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Semi.Avalonia;
using System.Reactive.Linq;
namespace v2rayN.Desktop.ViewModels
{
public class ThemeSettingViewModel : MyReactiveObject
{
[Reactive] public bool ColorModeDark { get; set; }
[Reactive] public bool FollowSystemTheme { get; set; }
[Reactive] public string CurrentTheme { get; set; }
[Reactive] public int CurrentFontSize { get; set; }
@ -36,28 +36,16 @@ namespace v2rayN.Desktop.ViewModels
private void BindingUI()
{
ColorModeDark = _config.UiItem.ColorModeDark;
FollowSystemTheme = _config.UiItem.FollowSystemTheme;
CurrentTheme = _config.UiItem.CurrentTheme;
CurrentFontSize = _config.UiItem.CurrentFontSize;
CurrentLanguage = _config.UiItem.CurrentLanguage;
this.WhenAnyValue(x => x.ColorModeDark)
this.WhenAnyValue(x => x.CurrentTheme)
.Subscribe(c =>
{
if (_config.UiItem.ColorModeDark != ColorModeDark)
if (_config.UiItem.CurrentTheme != CurrentTheme)
{
_config.UiItem.ColorModeDark = ColorModeDark;
ModifyTheme();
ConfigHandler.SaveConfig(_config);
}
});
this.WhenAnyValue(x => x.FollowSystemTheme,
y => y == true)
.Subscribe(c =>
{
if (_config.UiItem.FollowSystemTheme != FollowSystemTheme)
{
_config.UiItem.FollowSystemTheme = FollowSystemTheme;
_config.UiItem.CurrentTheme = CurrentTheme;
ModifyTheme();
ConfigHandler.SaveConfig(_config);
}
@ -96,7 +84,16 @@ namespace v2rayN.Desktop.ViewModels
var app = Application.Current;
if (app is not null)
{
app.RequestedThemeVariant = FollowSystemTheme ? ThemeVariant.Default : (ColorModeDark ? ThemeVariant.Dark : ThemeVariant.Light);
app.RequestedThemeVariant = CurrentTheme switch
{
nameof(ETheme.Dark) => ThemeVariant.Dark,
nameof(ETheme.Light) => ThemeVariant.Light,
nameof(ETheme.Aquatic) => SemiTheme.Aquatic,
nameof(ETheme.Desert) => SemiTheme.Desert,
nameof(ETheme.Dusk) => SemiTheme.Dusk,
nameof(ETheme.NightSky) => SemiTheme.NightSky,
_ => ThemeVariant.Default,
};
}
}

View file

@ -5,11 +5,15 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
d:DesignHeight="450"
d:DesignWidth="800"
x:DataType="vms:BackupAndRestoreViewModel"
mc:Ignorable="d">
<UserControl.Styles>
<Style Selector="Button">
<Setter Property="MinWidth" Value="180" />
</Style>
</UserControl.Styles>
<DockPanel Classes="Margin8">
<DockPanel Classes="Margin8" DockPanel.Dock="Bottom">
@ -23,7 +27,7 @@
<Border
Margin="4"
VerticalAlignment="Center"
Theme="{StaticResource CardBorder}">
Theme="{DynamicResource CardBorder}">
<Grid
Classes="Margin8"
@ -49,7 +53,10 @@
Classes="Margin8"
Content="{x:Static resx:ResUI.menuLocalBackup}" />
<Separator Grid.Row="2" Grid.ColumnSpan="2" />
<Separator
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2" />
<TextBlock
Grid.Row="3"
@ -69,17 +76,16 @@
<Border
Margin="4"
VerticalAlignment="Center"
Theme="{StaticResource CardBorder}">
Theme="{DynamicResource CardBorder}">
<Grid
Classes="Margin8"
ColumnDefinitions="300,200"
RowDefinitions="Auto,Auto,Auto,Auto,Auto">
<StackPanel Orientation="Horizontal">
<TextBlock
Grid.Row="0"
Grid.Column="0"
Classes="Margin8"
Text="{x:Static resx:ResUI.menuRemoteBackupAndRestore}" />
<StackPanel
Grid.Row="0"
Grid.Column="0"
Orientation="Horizontal">
<TextBlock Classes="Margin8" Text="{x:Static resx:ResUI.menuRemoteBackupAndRestore}" />
<Button
Width="30"
@ -184,7 +190,10 @@
Classes="Margin8"
Content="{x:Static resx:ResUI.menuRemoteBackup}" />
<Separator Grid.Row="2" Grid.ColumnSpan="3" />
<Separator
Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="2" />
<TextBlock
Grid.Row="3"
Grid.Column="0"

View file

@ -9,7 +9,12 @@ namespace v2rayN.Desktop.Views
{
public partial class BackupAndRestoreView : ReactiveUserControl<BackupAndRestoreViewModel>
{
private Window _window;
private Window? _window;
public BackupAndRestoreView()
{
InitializeComponent();
}
public BackupAndRestoreView(Window window)
{

View file

@ -35,11 +35,16 @@
Content="{x:Static resx:ResUI.menuCheckUpdate}" />
</StackPanel>
<StackPanel>
<Border
Margin="4"
VerticalAlignment="Center"
Theme="{DynamicResource CardBorder}">
<ListBox
x:Name="lstCheckUpdates"
BorderThickness="1"
ItemsSource="{Binding CheckUpdateModels}">
ItemsSource="{Binding CheckUpdateModels}"
Theme="{StaticResource ButtonRadioGroupListBox}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
@ -47,12 +52,7 @@
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border
Width="500"
Height="80"
Margin="-8"
VerticalAlignment="Center"
Theme="{StaticResource CardBorder}">
<Panel Width="500" VerticalAlignment="Center">
<Grid ColumnDefinitions="1*,1*,3*" RowDefinitions="Auto">
<ToggleSwitch
x:Name="togAutoRefresh"
@ -73,11 +73,10 @@
Text="{Binding Remarks}"
TextWrapping="WrapWithOverflow" />
</Grid>
</Border>
</Panel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ListBox>
</StackPanel>
</Border>
</DockPanel>
</UserControl>

View file

@ -95,7 +95,8 @@
<ListBox
x:Name="lstProxyGroups"
DockPanel.Dock="Left"
ItemsSource="{Binding ProxyGroups}">
ItemsSource="{Binding ProxyGroups}"
Theme="{StaticResource ButtonRadioGroupListBox}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
@ -105,24 +106,25 @@
<DataTemplate>
<Border
Width="160"
Margin="-6"
Margin="-8,-4"
Padding="0"
Theme="{StaticResource CardBorder}">
<DockPanel>
<Grid Classes="Margin8" RowDefinitions="1*,8,1*">
<DockPanel Grid.Row="0">
<TextBlock DockPanel.Dock="Right" Text="{Binding Type}" />
<TextBlock Text="{Binding Name}" />
</DockPanel>
<TextBlock Grid.Row="2" Text="{Binding Now}" />
</Grid>
</DockPanel>
<Grid Classes="Margin8" RowDefinitions="1*,8,1*">
<DockPanel Grid.Row="0">
<TextBlock DockPanel.Dock="Right" Text="{Binding Type}" />
<TextBlock Text="{Binding Name}" />
</DockPanel>
<TextBlock Grid.Row="2" Text="{Binding Now}" />
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ListBox>
<ListBox x:Name="lstProxyDetails" ItemsSource="{Binding ProxyDetails}">
<ListBox
x:Name="lstProxyDetails"
ItemsSource="{Binding ProxyDetails}"
Theme="{StaticResource ButtonRadioGroupListBox}">
<ItemsControl.ContextMenu>
<ContextMenu>
<MenuItem x:Name="menuProxiesDelaytestPart" Header="{x:Static resx:ResUI.menuProxiesDelaytestPart}" />
@ -138,7 +140,7 @@
<DataTemplate>
<Border
Width="160"
Margin="-6"
Margin="-12,-4"
Padding="0"
Theme="{StaticResource CardBorder}">
<DockPanel>

View file

@ -150,71 +150,20 @@
x:Name="tabMain1"
Grid.Row="2"
TabStripPlacement="Left">
<TabItem x:Name="tabMsgView1">
<TabItem.Header>
<StackPanel>
<TextBlock HorizontalAlignment="Center" Text="{x:Static resx:ResUI.MsgInformationTitle}" />
</StackPanel>
</TabItem.Header>
</TabItem>
<TabItem x:Name="tabClashProxies1">
<TabItem.Header>
<StackPanel>
<TextBlock HorizontalAlignment="Center" Text="{x:Static resx:ResUI.TbProxies}" />
</StackPanel>
</TabItem.Header>
</TabItem>
<TabItem x:Name="tabClashConnections1">
<TabItem.Header>
<StackPanel>
<TextBlock HorizontalAlignment="Center" Text="{x:Static resx:ResUI.TbConnections}" />
</StackPanel>
</TabItem.Header>
</TabItem>
<TabItem x:Name="tabMsgView1" Header="{x:Static resx:ResUI.MsgInformationTitle}" />
<TabItem x:Name="tabClashProxies1" Header="{x:Static resx:ResUI.TbProxies}" />
<TabItem x:Name="tabClashConnections1" Header="{x:Static resx:ResUI.TbConnections}" />
</TabControl>
</Grid>
<Grid x:Name="gridMain2" IsVisible="False">
<TabControl x:Name="tabMain2" TabStripPlacement="Left">
<TabItem x:Name="tabProfiles2">
<TabItem.Header>
<StackPanel>
<TextBlock HorizontalAlignment="Center" Text="{x:Static resx:ResUI.menuServers}" />
</StackPanel>
</TabItem.Header>
</TabItem>
<TabItem x:Name="tabMsgView2">
<TabItem.Header>
<StackPanel>
<TextBlock HorizontalAlignment="Center" Text="{x:Static resx:ResUI.MsgInformationTitle}" />
</StackPanel>
</TabItem.Header>
</TabItem>
<TabItem x:Name="tabClashProxies2">
<TabItem.Header>
<StackPanel>
<TextBlock HorizontalAlignment="Center" Text="{x:Static resx:ResUI.TbProxies}" />
</StackPanel>
</TabItem.Header>
</TabItem>
<TabItem x:Name="tabClashConnections2">
<TabItem.Header>
<StackPanel>
<TextBlock HorizontalAlignment="Center" Text="{x:Static resx:ResUI.TbConnections}" />
</StackPanel>
</TabItem.Header>
</TabItem>
<TabItem x:Name="tabProfiles2" Header="{x:Static resx:ResUI.menuServers}" />
<TabItem x:Name="tabMsgView2" Header="{x:Static resx:ResUI.MsgInformationTitle}" />
<TabItem x:Name="tabClashProxies2" Header="{x:Static resx:ResUI.TbProxies}" />
<TabItem x:Name="tabClashConnections2" Header="{x:Static resx:ResUI.TbConnections}" />
</TabControl>
</Grid>
</Grid>
</DockPanel>
</dialogHost:DialogHost>
</Window>

View file

@ -65,7 +65,7 @@
Margin="8,0"
HorizontalAlignment="Left"
IsChecked="True"
Theme="{StaticResource SimpleToggleSwitch}" />
Theme="{DynamicResource SimpleToggleSwitch}" />
<TextBlock
Margin="8,0"
VerticalAlignment="Center"
@ -75,7 +75,7 @@
Margin="8,0"
HorizontalAlignment="Left"
IsChecked="True"
Theme="{StaticResource SimpleToggleSwitch}" />
Theme="{DynamicResource SimpleToggleSwitch}" />
</WrapPanel>
<TextBox
Name="txtMsg"

View file

@ -114,7 +114,7 @@
Grid.ColumnSpan="2"
HorizontalAlignment="Left"
Classes="Margin8"
SelectionMode="Multiple"
SelectionMode="Multiple,Toggle"
Theme="{DynamicResource CardCheckGroupListBox}" />
<TextBlock

View file

@ -165,7 +165,7 @@
Classes="Solid Red"
Content="{x:Static resx:ResUI.TipActiveServer}"
IsVisible="{Binding IsActive}"
Theme="{StaticResource TagLabel}" />
Theme="{DynamicResource TagLabel}" />
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"

View file

@ -15,7 +15,12 @@ namespace v2rayN.Desktop.Views
public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
{
private static Config _config;
private Window _window;
private Window? _window;
public ProfilesView()
{
InitializeComponent();
}
public ProfilesView(Window window)
{

View file

@ -4,12 +4,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
d:DesignHeight="480"
d:DesignWidth="400"
mc:Ignorable="d">
<Grid Margin="30" RowDefinitions="Auto,Auto">
<Image
Name="imgQrcode"
Width="300"
@ -24,6 +22,5 @@
IsReadOnly="True"
MaxLines="1" />
</Grid>
</UserControl>

View file

@ -5,6 +5,11 @@ namespace v2rayN.Desktop.Views
{
public partial class QrcodeView : UserControl
{
public QrcodeView()
{
InitializeComponent();
}
public QrcodeView(string? url)
{
InitializeComponent();

View file

@ -94,7 +94,7 @@
Grid.Column="1"
HorizontalAlignment="Left"
Classes="Margin8"
SelectionMode="Multiple"
SelectionMode="Multiple,Toggle"
Theme="{DynamicResource CardCheckGroupListBox}" />
<TextBlock
@ -108,7 +108,7 @@
Grid.Row="4"
Grid.Column="1"
Classes="Margin8"
SelectionMode="Multiple"
SelectionMode="Multiple,Toggle"
Theme="{DynamicResource CardCheckGroupListBox}" />
<TextBlock
Grid.Row="4"

View file

@ -18,40 +18,29 @@
<StackPanel
Classes="Margin8"
DockPanel.Dock="Top"
Orientation="Horizontal">
Orientation="Horizontal"
Spacing="4">
<Menu>
<MenuItem x:Name="menuRoutingAdvancedAdd2" Header="{x:Static resx:ResUI.menuRoutingAdvancedAdd}" />
<MenuItem x:Name="menuRoutingAdvancedImportRules2" Header="{x:Static resx:ResUI.menuRoutingAdvancedImportRules}" />
</Menu>
<TextBlock Margin="8,0,0,0" VerticalAlignment="Center">
<TextBlock VerticalAlignment="Center">
<HyperlinkButton Classes="WithIcon" Click="linkdomainStrategy_Click">
<TextBlock Text="{x:Static resx:ResUI.TbdomainStrategy}" />
</HyperlinkButton>
</TextBlock>
<ComboBox
x:Name="cmbdomainStrategy"
Width="110"
Margin="8,0,0,0" />
<ComboBox x:Name="cmbdomainStrategy" Width="110" />
<Separator />
<TextBlock
Margin="8,0,0,0"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbdomainMatcher}" />
<ComboBox
x:Name="cmbdomainMatcher"
Width="60"
Margin="8,0,0,0" />
<TextBlock VerticalAlignment="Center" Text="{x:Static resx:ResUI.TbdomainMatcher}" />
<ComboBox x:Name="cmbdomainMatcher" Width="60" />
<Separator />
<TextBlock Margin="8,0,0,0" VerticalAlignment="Center">
<TextBlock VerticalAlignment="Center">
<HyperlinkButton Classes="WithIcon" Click="linkdomainStrategy4Singbox_Click">
<TextBlock Text="{x:Static resx:ResUI.TbdomainStrategy4Singbox}" />
</HyperlinkButton>
</TextBlock>
<ComboBox
x:Name="cmbdomainStrategy4Singbox"
Width="100"
Margin="8,0,0,0" />
<ComboBox x:Name="cmbdomainStrategy4Singbox" Width="100" />
</StackPanel>
<StackPanel

View file

@ -45,7 +45,7 @@
x:Name="togEnableTun"
HorizontalAlignment="Center"
Classes="Margin8"
Theme="{StaticResource SimpleToggleSwitch}" />
Theme="{DynamicResource SimpleToggleSwitch}" />
</StackPanel>
<StackPanel

View file

@ -10,6 +10,15 @@
d:DesignWidth="800"
x:DataType="vms:ThemeSettingViewModel"
mc:Ignorable="d">
<UserControl.Styles>
<Style Selector="TextBlock">
<Setter Property="Width" Value="100" />
</Style>
<Style Selector="ComboBox">
<Setter Property="Width" Value="150" />
</Style>
</UserControl.Styles>
<Button
Width="30"
Height="30"
@ -27,40 +36,32 @@
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock
Width="100"
VerticalAlignment="Center"
Classes="Margin8"
Text="{x:Static resx:ResUI.TbSettingsColorMode}" />
<ToggleSwitch x:Name="togDarkMode" Classes="Margin8" />
Text="{x:Static resx:ResUI.TbSettingsTheme}" />
<ComboBox
x:Name="cmbCurrentTheme"
HorizontalAlignment="Center"
Classes="Margin8" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock
Width="100"
VerticalAlignment="Center"
Classes="Margin8"
Text="{x:Static resx:ResUI.TbSettingsFollowSystemTheme}" />
<ToggleSwitch x:Name="togFollowSystemTheme" Classes="Margin8" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock
Width="100"
VerticalAlignment="Center"
Classes="Margin8"
Text="{x:Static resx:ResUI.TbSettingsFontSize}" />
<ComboBox
x:Name="cmbCurrentFontSize"
Width="100"
HorizontalAlignment="Center"
Classes="Margin8" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock
Width="100"
VerticalAlignment="Center"
Classes="Margin8"
Text="{x:Static resx:ResUI.TbSettingsLanguage}" />
<ComboBox
x:Name="cmbCurrentLanguage"
Width="100"
HorizontalAlignment="Center"
Classes="Margin8" />
</StackPanel>
</StackPanel>

View file

@ -16,6 +16,11 @@ namespace v2rayN.Desktop.Views
InitializeComponent();
ViewModel = new ThemeSettingViewModel();
foreach (ETheme it in Enum.GetValues(typeof(ETheme)))
{
cmbCurrentTheme.Items.Add(it.ToString());
}
for (int i = Global.MinFontSize; i <= Global.MinFontSize + 10; i++)
{
cmbCurrentFontSize.Items.Add(i);
@ -28,8 +33,7 @@ namespace v2rayN.Desktop.Views
this.WhenActivated(disposables =>
{
this.Bind(ViewModel, vm => vm.ColorModeDark, v => v.togDarkMode.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.FollowSystemTheme, v => v.togFollowSystemTheme.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CurrentTheme, v => v.cmbCurrentTheme.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CurrentFontSize, v => v.cmbCurrentFontSize.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CurrentLanguage, v => v.cmbCurrentLanguage.SelectedValue).DisposeWith(disposables);
});

View file

@ -64,7 +64,6 @@
<DataTemplate>
<Border
Width="500"
Height="50"
Margin="{StaticResource Margin8}"
Padding="0"
VerticalAlignment="Center">