Skip to content

Commit

Permalink
修复导出设置错误
Browse files Browse the repository at this point in the history
  • Loading branch information
ywmoyue committed Jul 22, 2024
1 parent 563a6e2 commit 782b58f
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/BiliLite.UWP/Services/SettingsImportExportService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -148,11 +149,21 @@ private byte[] Encode(string text)
return bin;
}

private async Task<StorageFile> GetExportFile()
{
var savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
savePicker.FileTypeChoices.Add("bililite设置文件", new List<string>() { ".bililiteSettings" });
var fileName = $"{DateTime.Now.ToString("yyyy-M-d-HH_mm_ss")}";
savePicker.SuggestedFileName = fileName;
var file = await savePicker.PickSaveFileAsync();
return file;
}

public async Task<bool> ExportSettings()
{
var folder = await new FolderPicker().PickSingleFolderAsync();
if (folder == null) return false;
var file = await folder.CreateFileAsync($"{DateTime.Now.ToString("yyyy-M-d-HH_mm_ss")}.bililiteSettings");
var file = await GetExportFile();
if (file == null) return false;

try
{
Expand Down Expand Up @@ -185,9 +196,8 @@ public async Task<bool> ExportSettings()

public async Task<bool> ExportSettingsWithAccount()
{
var folder = await new FolderPicker().PickSingleFolderAsync();
if (folder == null) return false;
var file = await folder.CreateFileAsync($"{DateTime.Now.ToString("yyyy-M-d-HH_mm_ss")}.bililiteSettings");
var file = await GetExportFile();
if (file == null) return false;

try
{
Expand Down

0 comments on commit 782b58f

Please sign in to comment.