Skip to content

Commit

Permalink
代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
Harlan-H committed Oct 10, 2022
1 parent 47133f5 commit 1e09a91
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 35 deletions.
62 changes: 34 additions & 28 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: main

on: push
on:
push:
branches:
- master
tags:
- "*"

jobs:
package:
Expand All @@ -16,59 +21,60 @@ jobs:
uses: actions/checkout@v3

- name: Install .NET
uses: actions/setup-dotnet@v2
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.100
dotnet-version: 6.0.x

- name: Publish
run: dotnet publish BiliDownloader/ -o BiliDownloader/bin/Publish --configuration Release
run: |
dotnet publish BiliDownloader/ -o BiliDownloader/bin/Publish --configuration Release
dotnet publish BiliDownloader/ -o BiliDownloader/bin/PublishSingleFile -c Release --self-contained true -r win7-x64 -p:PublishSingleFile=true
- name: Upload artifacts
- name: Upload artifacts normal
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
uses: actions/upload-artifact@v3
with:
name: BiliDownloader
path: BiliDownloader/bin/Publish

- name: Upload artifacts single file
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
uses: actions/upload-artifact@v3
with:
name: BiliDownloader-SingleFile
path: BiliDownloader/bin/PublishSingleFile

deploy:
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
needs: package
runs-on: ubuntu-latest

steps:
- name: Download artifacts
- name: Download artifacts normal
uses: actions/download-artifact@v3
with:
name: BiliDownloader
path: BiliDownloader

- name: Download artifacts single file
uses: actions/download-artifact@v3
with:
name: BiliDownloader-SingleFile
path: BiliDownloader-SingleFile

- name: Create package
run: Compress-Archive -Path BiliDownloader/* -DestinationPath BiliDownloader.zip -Force
run: |
Compress-Archive -Path BiliDownloader/* -DestinationPath BiliDownloader.zip -Force
Compress-Archive -Path BiliDownloader-SingleFile/* -DestinationPath BiliDownloader-SingleFile.zip -Force
shell: pwsh

- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: |
[Changelog](https://github.com/Harlan-H/BiliDownloader/blob/master/Changelog.md)
- [更新日志](https://github.com/Harlan-H/BiliDownloader/blob/master/Changelog.md)
draft: false
prerelease: false

- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_name: BiliDownloader.zip
asset_path: BiliDownloader.zip
asset_content_type: application/zip

- uses: geekyeggo/delete-artifact@v1
with:
name: BiliDownloader
files: |
BiliDownloader.zip
BiliDownloader-SingleFile.zip
4 changes: 1 addition & 3 deletions BiliDownloader/ViewModels/DownloadMultipleSetupViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public class DownloadMultipleSetupViewModel : DialogScreen<IReadOnlyList<Downloa
public IList<IPlaylist> AvailableVideos { get; set; } = Array.Empty<IPlaylist>();
public IList<IPlaylist> SelectedVideos { get; set; } = Array.Empty<IPlaylist>();

//todo 增加checkbox 如果字幕数组大于0 则可用
//todo 当checkbox选中说明需要下载字幕
public DownloadMultipleSetupViewModel(IViewModelFactory viewModelFactory, SettingsService settingsService)
{
this.viewModelFactory = viewModelFactory;
Expand Down Expand Up @@ -64,7 +62,7 @@ public void Confirm()

PathEx.CreateDirectoryForFile(filePath);

var download = viewModelFactory.CreateDownloadViewModel(playlist, filePath,true);
var download = viewModelFactory.CreateDownloadViewModel(playlist, filePath);
downloads.Add(download);
}

Expand Down
8 changes: 4 additions & 4 deletions BiliDownloader/ViewModels/DownloadViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ public void OnShowFile()
if (!CanOnShowFile)
return;

if (string.IsNullOrWhiteSpace(FilePath))
return;

try
{
if (string.IsNullOrWhiteSpace(FilePath))
return;

Process.Start("explorer", $"/select, \"{FilePath}\"");
}
catch (Exception)
Expand All @@ -143,7 +143,7 @@ public void Dispose()

public static class DownloadViewModelExtensions
{
public static DownloadViewModel CreateDownloadViewModel(this IViewModelFactory viewModelFactory, IPlaylist playlist,string filePath,bool isDownloadSubtitle)
public static DownloadViewModel CreateDownloadViewModel(this IViewModelFactory viewModelFactory, IPlaylist playlist,string filePath)
{
var view = viewModelFactory.CreateDownloadViewModel();
view.Playlist = playlist;
Expand Down

0 comments on commit 1e09a91

Please sign in to comment.