Files
client/Views/SettingsView.xaml
2026-05-23 18:16:50 +08:00

77 lines
5.4 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<UserControl x:Class="CloudPrint.Client.Views.SettingsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Border Background="White" CornerRadius="14" Padding="22">
<Grid MaxWidth="820" HorizontalAlignment="Left">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" Grid.ColumnSpan="3" Margin="0,0,0,20">
<TextBlock Text="系统设置" FontSize="20" FontWeight="Bold" />
<TextBlock Text="配置真实后端地址、打印客户端 API Key、本地文库目录API Key 和 token 会用 Windows DPAPI 加密保存。"
Foreground="#64748B" Margin="0,6,0,0" />
</StackPanel>
<TextBlock Grid.Row="1" Grid.Column="0" Text="服务器地址" VerticalAlignment="Center" Margin="0,0,12,12" />
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Settings.ServerAddress, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,0,12" />
<TextBlock Grid.Row="2" Grid.Column="0" Text="API Key" VerticalAlignment="Center" Margin="0,0,12,12" />
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Settings.ApiKey, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,0,12" />
<TextBlock Grid.Row="3" Grid.Column="0" Text="门店名称" VerticalAlignment="Center" Margin="0,0,12,12" />
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Settings.StoreName, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,0,12" />
<TextBlock Grid.Row="4" Grid.Column="0" Text="本地文库目录" VerticalAlignment="Center" Margin="0,0,12,12" />
<TextBox Grid.Row="4" Grid.Column="1" Text="{Binding Settings.LibraryRoot, UpdateSourceTrigger=PropertyChanged}" Margin="0,0,8,12" />
<Button Grid.Row="4" Grid.Column="2" Content="选择" Command="{Binding SelectLibraryRootCommand}" Margin="0,0,0,12" />
<StackPanel Grid.Row="5" Grid.Column="1" Orientation="Horizontal" Margin="0,4,0,0">
<CheckBox Content="允许 HTTP gRPC" IsChecked="{Binding Settings.AllowInsecureGrpc}" VerticalAlignment="Center" Margin="0,0,24,0" />
<TextBlock Text="最大上传 MB" VerticalAlignment="Center" Margin="0,0,8,0" />
<TextBox Text="{Binding Settings.MaxUploadSizeMb, UpdateSourceTrigger=PropertyChanged}" Width="70" Margin="0,0,16,0" />
<TextBlock Text="心跳秒" VerticalAlignment="Center" Margin="0,0,8,0" />
<TextBox Text="{Binding Settings.HeartbeatIntervalSeconds, UpdateSourceTrigger=PropertyChanged}" Width="55" Margin="0,0,16,0" />
<Button Content="保存设置" Command="{Binding SaveCommand}" />
<TextBlock Text="{Binding StatusMessage}" Foreground="#64748B" VerticalAlignment="Center" Margin="8,0,0,0" />
</StackPanel>
<StackPanel Grid.Row="6" Grid.Column="1" Orientation="Horizontal" Margin="0,12,0,0">
<TextBlock Text="日志目录" VerticalAlignment="Center" Margin="0,0,8,0" />
<TextBlock Text="{Binding LogDirectory}" Foreground="#64748B" VerticalAlignment="Center" Margin="0,0,12,0" />
<Button Content="打开日志目录" Command="{Binding OpenLogDirectoryCommand}" Style="{StaticResource SecondaryButtonStyle}" />
</StackPanel>
<Separator Grid.Row="7" Grid.ColumnSpan="3" Margin="0,22,0,18" />
<StackPanel Grid.Row="8" Grid.ColumnSpan="3" Margin="0,0,0,14">
<TextBlock Text="管理员登录" FontSize="18" FontWeight="Bold" />
<TextBlock Text="登录后会保存 access token并在真实 gRPC 请求中附加 Authorization metadata。"
Foreground="#64748B" Margin="0,6,0,0" />
</StackPanel>
<TextBlock Grid.Row="9" Grid.Column="0" Text="管理员账号" VerticalAlignment="Center" Margin="0,0,12,0" />
<StackPanel Grid.Row="9" Grid.Column="1" Grid.ColumnSpan="2" Orientation="Horizontal">
<TextBox Text="{Binding Settings.AdminUsername, UpdateSourceTrigger=PropertyChanged}" Width="180" Margin="0,0,10,0" />
<PasswordBox x:Name="PART_AdminPasswordBox" Width="180" PasswordChanged="AdminPasswordBox_OnPasswordChanged" Margin="0,0,10,0" />
<Button Content="登录" Command="{Binding LoginAdminCommand}" />
<Button Content="退出" Command="{Binding LogoutAdminCommand}" Style="{StaticResource SecondaryButtonStyle}" />
<TextBlock Text="{Binding AdminLoginStatus}" Foreground="#64748B" VerticalAlignment="Center" Margin="8,0,0,0" />
</StackPanel>
</Grid>
</Border>
</UserControl>