Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
增加下载接口选择 (#341)
Browse files Browse the repository at this point in the history
* 添加下载接口类型选择

* 在仅有一个分P时,不显示分P选择
  • Loading branch information
Richasy authored Sep 29, 2021
1 parent 02c5af9 commit c615f95
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 4 deletions.
12 changes: 11 additions & 1 deletion src/App/Controls/Player/DownloadOptionsPanel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="{loc:LocaleLocator Name=DownloadTip}"
TextWrapping="Wrap" />
<ComboBox
x:Name="InterfaceComboBox"
HorizontalAlignment="Stretch"
Header="{loc:LocaleLocator Name=InterfaceType}"
SelectionChanged="OnInterfaceComboBoxSelectionChanged">
<ComboBoxItem Content="{loc:LocaleLocator Name=None}" Tag="None" />
<ComboBoxItem Content="{loc:LocaleLocator Name=MobileApp}" Tag="App" />
<ComboBoxItem Content="{loc:LocaleLocator Name=TVApp}" Tag="TV" />
<ComboBoxItem Content="{loc:LocaleLocator Name=InternationalApp}" Tag="International" />
</ComboBox>
<ComboBox
x:Name="CodecComboBox"
HorizontalAlignment="Stretch"
Expand Down Expand Up @@ -47,7 +57,7 @@
HorizontalAlignment="Left"
Header="{loc:LocaleLocator Name=UseMultiThread}"
IsOn="{x:Bind ViewModel.UseMultiThread, Mode=TwoWay}" />
<StackPanel Spacing="8">
<StackPanel Spacing="8" Visibility="{x:Bind ViewModel.IsShowPart, Mode=OneWay}">
<TextBlock Text="{loc:LocaleLocator Name=Parts}" />
<ScrollViewer
MaxHeight="132"
Expand Down
47 changes: 47 additions & 0 deletions src/App/Controls/Player/DownloadOptionsPanel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ private void Initialize()
{
CodecComboBox.SelectedIndex = 0;
}

if (ViewModel.UseAppInterface)
{
InterfaceComboBox.SelectedIndex = 1;
}
else if (ViewModel.UseTvInterface)
{
InterfaceComboBox.SelectedIndex = 2;
}
else if (ViewModel.UseInternationalInterface)
{
InterfaceComboBox.SelectedIndex = 3;
}
else
{
InterfaceComboBox.SelectedIndex = 0;
}
}

private void OnDownloadTypeComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
Expand Down Expand Up @@ -140,5 +157,35 @@ private async void OnGenerateButtonClickAsync(object sender, RoutedEventArgs e)
Clipboard.SetContent(package);
appVM.ShowTip(resourceToolkit.GetLocaleString(Models.Enums.LanguageNames.Copied));
}

private void OnInterfaceComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
{
var item = InterfaceComboBox.SelectedItem as ComboBoxItem;
switch (item.Tag)
{
case "None":
ViewModel.UseAppInterface = false;
ViewModel.UseTvInterface = false;
ViewModel.UseInternationalInterface = false;
break;
case "App":
ViewModel.UseAppInterface = true;
ViewModel.UseTvInterface = false;
ViewModel.UseInternationalInterface = false;
break;
case "TV":
ViewModel.UseAppInterface = false;
ViewModel.UseTvInterface = true;
ViewModel.UseInternationalInterface = false;
break;
case "International":
ViewModel.UseAppInterface = false;
ViewModel.UseTvInterface = false;
ViewModel.UseInternationalInterface = true;
break;
default:
break;
}
}
}
}
15 changes: 15 additions & 0 deletions src/App/Resources/Strings/zh-CN/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,12 @@
<data name="InputCaptchaTip" xml:space="preserve">
<value>请输入验证码</value>
</data>
<data name="InterfaceType" xml:space="preserve">
<value>接口类型</value>
</data>
<data name="InternationalApp" xml:space="preserve">
<value>国际应用</value>
</data>
<data name="InvalidUserNameOrPassword" xml:space="preserve">
<value>用户名或密码错误</value>
</data>
Expand Down Expand Up @@ -581,6 +587,9 @@
<data name="Minutes" xml:space="preserve">
<value>分钟</value>
</data>
<data name="MobileApp" xml:space="preserve">
<value>移动应用</value>
</data>
<data name="MorePeople" xml:space="preserve">
<value>等人</value>
</data>
Expand Down Expand Up @@ -632,6 +641,9 @@
<data name="NoMessage" xml:space="preserve">
<value>正在等待发言</value>
</data>
<data name="None" xml:space="preserve">
<value>无</value>
</data>
<data name="NoReply" xml:space="preserve">
<value>目前还没有评论</value>
</data>
Expand Down Expand Up @@ -1100,6 +1112,9 @@
<data name="TV" xml:space="preserve">
<value>电视剧</value>
</data>
<data name="TVApp" xml:space="preserve">
<value>电视</value>
</data>
<data name="UnFavorite" xml:space="preserve">
<value>取消收藏</value>
</data>
Expand Down
5 changes: 5 additions & 0 deletions src/Models/Models.Enums/App/LanguageNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ public enum LanguageNames
Subtitle,
ShowSubtitle,
SubtitleList,
InterfaceType,
None,
MobileApp,
TVApp,
InternationalApp,
#pragma warning restore SA1602 // Enumeration items should be documented
}
}
48 changes: 45 additions & 3 deletions src/ViewModels/ViewModels.Uwp/Common/DownloadViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class DownloadViewModel : ViewModelBase
protected DownloadViewModel()
{
UseMultiThread = true;
UseAppInterface = true;
TotalPartCollection = new ObservableCollection<NumberPartViewModel>();
}

Expand Down Expand Up @@ -77,12 +78,36 @@ protected DownloadViewModel()
[Reactive]
public bool UseMultiThread { get; set; }

/// <summary>
/// 使用TV接口.
/// </summary>
[Reactive]
public bool UseTvInterface { get; set; }

/// <summary>
/// 使用App接口.
/// </summary>
[Reactive]
public bool UseAppInterface { get; set; }

/// <summary>
/// 使用国际版接口.
/// </summary>
[Reactive]
public bool UseInternationalInterface { get; set; }

/// <summary>
/// 全部分P集合.
/// </summary>
[Reactive]
public ObservableCollection<NumberPartViewModel> TotalPartCollection { get; set; }

/// <summary>
/// 是否显示分P.
/// </summary>
[Reactive]
public bool IsShowPart { get; set; }

/// <summary>
/// 加载.
/// </summary>
Expand All @@ -96,6 +121,8 @@ public void Load(string downloadUrl, List<int> partList)
{
TotalPartCollection.Add(new NumberPartViewModel(item, true));
}

IsShowPart = TotalPartCollection.Count > 1;
}

/// <summary>
Expand All @@ -113,9 +140,24 @@ public async Task<string> CreateDownloadCommandAsync()
{
var authProvider = ServiceLocator.Instance.GetService<IAuthorizeProvider>();
var token = await authProvider.GetTokenAsync();
list.Add("-app");
list.Add("-token");
list.Add(token);
if (UseAppInterface)
{
list.Add("-app");
}
else if (UseTvInterface)
{
list.Add("-tv");
}
else if (UseInternationalInterface)
{
list.Add("-intl");
}

if (UseAppInterface || UseInternationalInterface || UseTvInterface)
{
list.Add("-token");
list.Add(token);
}
}

if (UseMp4Box)
Expand Down

0 comments on commit c615f95

Please sign in to comment.