| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <Window x:Class="LocalizationTool.Views.TranslationSettingsWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:hc="https://handyorg.github.io/handycontrol"
- Title="翻译设置" Height="580" Width="700"
- WindowStartupLocation="CenterScreen"
- Background="#F5F6FA">
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="*"/>
- <RowDefinition Height="Auto"/>
- </Grid.RowDefinitions>
- <ScrollViewer Grid.Row="0" VerticalScrollBarVisibility="Auto" Padding="24">
- <StackPanel>
- <TextBlock Text="🌐 自动翻译设置" FontSize="20" FontWeight="Bold" Foreground="#333" Margin="0,0,0,16"/>
- <!-- 翻译引擎选择 -->
- <GroupBox Header="翻译引擎" Style="{StaticResource GroupBoxOriginal}">
- <StackPanel Margin="12" Orientation="Horizontal">
- <RadioButton Content="OpenAI (ChatGPT)" GroupName="Provider" Margin="5"
- IsChecked="{Binding IsOpenAi}" Command="{Binding SwitchToOpenAiCommand}"/>
- <RadioButton Content="百度翻译" GroupName="Provider" Margin="5"
- IsChecked="{Binding IsBaidu}" Command="{Binding SwitchToBaiduCommand}"/>
- </StackPanel>
- </GroupBox>
- <!-- OpenAI 设置 -->
- <GroupBox Header="OpenAI 配置" Style="{StaticResource GroupBoxOriginal}"
- Visibility="{Binding IsOpenAi, Converter={StaticResource BoolToVis}}">
- <hc:UniformSpacingPanel Spacing="12" Orientation="Vertical" Margin="12">
- <DockPanel>
- <TextBlock Text="Base URL:" Width="100" VerticalAlignment="Center"/>
- <TextBox hc:InfoElement.Placeholder="留空 = 内置默认" Style="{StaticResource TextBoxExtend}"
- Text="{Binding BaseUrl, UpdateSourceTrigger=PropertyChanged}"/>
- </DockPanel>
- <DockPanel>
- <TextBlock Text="Model:" Width="100" VerticalAlignment="Center"/>
- <Button DockPanel.Dock="Right" Content="获取模型" Width="80"
- Margin="8,0,0,0" Style="{StaticResource ButtonDefault}"
- Command="{Binding FetchModelsCommand}"
- ToolTip="从 {BaseUrl}/models 接口获取可用模型列表"/>
- <ComboBox IsEditable="True" hc:InfoElement.Placeholder="手输或点“获取模型”后筛选选择"
- Text="{Binding Model, UpdateSourceTrigger=PropertyChanged}"
- ItemsSource="{Binding FilteredModels, Mode=OneWay}"/>
- </DockPanel>
- <DockPanel>
- <TextBlock Text="最大上下文:" Width="100" VerticalAlignment="Center"/>
- <TextBox hc:InfoElement.Placeholder="留空 = 内置默认 512K"
- Style="{StaticResource TextBoxExtend}"
- Text="{Binding MaxContextTokensText, UpdateSourceTrigger=PropertyChanged}"
- ToolTip="模型上下文窗口上限(token),用于 AI 助手上下文用量指示器。留空 = 内置默认(agnes-2.5-flash 512K)"/>
- </DockPanel>
- <DockPanel>
- <TextBlock Text="API Key:" Width="100" VerticalAlignment="Center"/>
- <PasswordBox x:Name="TxtOpenAIKey" hc:InfoElement.Placeholder="sk-..." Style="{StaticResource PasswordBoxExtend}"
- PasswordChanged="OpenAiKey_PasswordChanged"/>
- </DockPanel>
- <DockPanel Margin="0,2,0,0">
- <Button DockPanel.Dock="Right" Content="↺ 恢复默认" Width="90"
- Margin="8,0,0,0" Style="{StaticResource ButtonDefault}"
- Command="{Binding ResetOpenAICommand}"
- ToolTip="清空自定义 Base URL / Model / API Key,回到程序内置默认 AI"/>
- <TextBlock FontSize="11" VerticalAlignment="Center"
- Foreground="{DynamicResource SecondaryTextBrush}"
- Text="{Binding OpenAiStatus}"/>
- </DockPanel>
- </hc:UniformSpacingPanel>
- </GroupBox>
- <!-- 百度翻译设置 -->
- <GroupBox Header="百度翻译配置" Style="{StaticResource GroupBoxOriginal}"
- Visibility="{Binding IsBaidu, Converter={StaticResource BoolToVis}}">
- <hc:UniformSpacingPanel Spacing="12" Orientation="Vertical" Margin="12">
- <DockPanel>
- <TextBlock Text="APP ID:" Width="100" VerticalAlignment="Center"/>
- <TextBox hc:InfoElement.Placeholder="留空 = 内置默认" Style="{StaticResource TextBoxExtend}"
- Text="{Binding BaiduAppIdInput, UpdateSourceTrigger=PropertyChanged}"/>
- </DockPanel>
- <DockPanel>
- <TextBlock Text="密钥:" Width="100" VerticalAlignment="Center"/>
- <PasswordBox x:Name="TxtBaiduSecret" hc:InfoElement.Placeholder="留空 = 内置默认" Style="{StaticResource PasswordBoxExtend}"
- PasswordChanged="BaiduSecret_PasswordChanged"/>
- </DockPanel>
- <DockPanel>
- <TextBlock Text="翻译模式:" Width="100" VerticalAlignment="Center"/>
- <StackPanel Orientation="Horizontal">
- <RadioButton Content="NMT 机器翻译(默认·快)" GroupName="BaiduModelType"
- Margin="0,0,16,0" IsChecked="{Binding IsNmt}"/>
- <RadioButton Content="LLM 大模型翻译(质量好·需开通)" GroupName="BaiduModelType"
- IsChecked="{Binding IsLlm}"/>
- </StackPanel>
- </DockPanel>
- <StackPanel>
- <TextBlock Text="翻译指令 reference(llm 模式生效 · 如保留数字/符号只翻文本):" FontSize="11"
- Foreground="{DynamicResource SecondaryTextBrush}" Margin="0,0,0,4"/>
- <TextBox TextWrapping="Wrap" AcceptsReturn="False" FontSize="12" Height="46"
- VerticalScrollBarVisibility="Auto" VerticalContentAlignment="Top"
- Text="{Binding Reference, UpdateSourceTrigger=PropertyChanged}"/>
- </StackPanel>
- <DockPanel Margin="0,2,0,0">
- <Button DockPanel.Dock="Right" Content="↺ 恢复默认" Width="90"
- Margin="8,0,0,0" Style="{StaticResource ButtonDefault}"
- Command="{Binding ResetBaiduCommand}"
- ToolTip="清空自定义 APP ID / 密钥,回到程序内置默认百度凭证"/>
- <TextBlock FontSize="11" VerticalAlignment="Center"
- Foreground="{DynamicResource SecondaryTextBrush}"
- Text="{Binding BaiduStatus}"/>
- </DockPanel>
- </hc:UniformSpacingPanel>
- </GroupBox>
- <!-- 测试翻译 -->
- <GroupBox Header="测试翻译" Style="{StaticResource GroupBoxOriginal}">
- <hc:UniformSpacingPanel Spacing="12" Orientation="Vertical" Margin="12">
- <DockPanel>
- <TextBlock Text="目标语言:" Width="100" VerticalAlignment="Center"/>
- <ComboBox Width="280" HorizontalAlignment="Left" DisplayMemberPath="Display"
- ItemsSource="{Binding TestLanguages}"
- SelectedItem="{Binding TestLang}"
- ToolTip="来自语言目录(LanguageCatalog),百度自动映射语言代码;OpenAI 直接使用语言代码"/>
- </DockPanel>
- <DockPanel>
- <TextBlock Text="测试文本:" Width="100" VerticalAlignment="Top" Margin="0,8,0,0"/>
- <TextBox Height="60" TextWrapping="Wrap" AcceptsReturn="True"
- hc:InfoElement.Placeholder="输入中文测试..." Style="{StaticResource TextBoxExtend}"
- Text="{Binding TestText, UpdateSourceTrigger=PropertyChanged}"/>
- </DockPanel>
- <Button Content="🧪 测试翻译" Width="120" HorizontalAlignment="Left"
- Style="{StaticResource ButtonPrimary}" Command="{Binding TestCommand}"
- IsEnabled="{Binding IsBusy, Converter={StaticResource InverseBool}}"/>
- <Border Background="#FFFFFF" CornerRadius="4" Padding="12" MinHeight="80" BorderBrush="#E4E7EC" BorderThickness="1">
- <TextBlock Text="{Binding TestResult}" TextWrapping="Wrap" Foreground="#333"/>
- </Border>
- </hc:UniformSpacingPanel>
- </GroupBox>
- </StackPanel>
- </ScrollViewer>
- <!-- 底部按钮 -->
- <Border Grid.Row="1" Background="White" BorderBrush="#E4E7EC" BorderThickness="0,1,0,0" Padding="16">
- <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
- <Button Content="保存" Width="88" Style="{StaticResource ButtonPrimary}"
- Command="{Binding SaveCommand}" Margin="0,0,10,0"/>
- <Button Content="取消" Width="88" Style="{StaticResource ButtonDefault}"
- Command="{Binding CancelCommand}"/>
- </StackPanel>
- </Border>
- </Grid>
- </Window>
|