diff --git a/TIDALDL-UI-PRO/.vs/TIDALDL-UI/v16/.suo b/TIDALDL-UI-PRO/.vs/TIDALDL-UI/v16/.suo index 22606ff..2982413 100644 Binary files a/TIDALDL-UI-PRO/.vs/TIDALDL-UI/v16/.suo and b/TIDALDL-UI-PRO/.vs/TIDALDL-UI/v16/.suo differ diff --git a/TIDALDL-UI-PRO/Else/Global.cs b/TIDALDL-UI-PRO/Else/Global.cs index 5b0b0fc..ac5332f 100644 --- a/TIDALDL-UI-PRO/Else/Global.cs +++ b/TIDALDL-UI-PRO/Else/Global.cs @@ -26,7 +26,8 @@ public class Global : ViewMoudleBase public static string PATH_BASE = SystemHelper.GetUserFolders().PersonalPath + "\\Tidal-gui\\"; public static string PATH_SETTINGS = PATH_BASE + "data\\settings.json"; public static string PATH_USERSETTINGS = PATH_BASE + "data\\usersettings.json"; - public static string PATH_UPDATE = PATH_BASE + "download\\"; + public static string PATH_UPDATE = PATH_BASE + "update\\"; + public static string PATH_UPDATEBAT = PATH_UPDATE + "update.bat"; //url public static string URL_TIDAL_GROUP = "https://t.me/tidal_group"; diff --git a/TIDALDL-UI-PRO/Pages/AboutView.xaml b/TIDALDL-UI-PRO/Pages/AboutView.xaml index 57fccc0..ca11fcf 100644 --- a/TIDALDL-UI-PRO/Pages/AboutView.xaml +++ b/TIDALDL-UI-PRO/Pages/AboutView.xaml @@ -50,6 +50,7 @@ + @@ -57,14 +58,17 @@ - + + - + + + @@ -97,7 +101,12 @@ - + + + + + + diff --git a/TIDALDL-UI-PRO/Pages/AboutViewModel.cs b/TIDALDL-UI-PRO/Pages/AboutViewModel.cs index bc9f05b..fc5ca20 100644 --- a/TIDALDL-UI-PRO/Pages/AboutViewModel.cs +++ b/TIDALDL-UI-PRO/Pages/AboutViewModel.cs @@ -1,5 +1,6 @@ using System; using System.Collections.ObjectModel; +using System.IO; using System.Threading.Tasks; using System.Windows; using AIGS.Common; @@ -7,20 +8,31 @@ using HandyControl.Controls; using Stylet; using TIDALDL_UI.Else; +using TidalLib; namespace TIDALDL_UI.Pages { public class AboutViewModel : ModelBase { + public MainViewModel MainVM; public string Type { get; set; } = "(BETA)"; - public Visibility ShowDonate { get; set; } = Visibility.Collapsed; public string Version { get; set; } = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); public string LastVersion { get; set; } - + public Visibility ShowDonate { get; set; } = Visibility.Collapsed; + public Visibility ShowProgress { get; set; } = Visibility.Collapsed; + public Visibility EnableUpdate { get; set; } = Visibility.Collapsed; + public ProgressHelper Progress { get; set; } = new ProgressHelper(false); + public string DownloadStatusInfo { get; set; } + System.DateTime StartTime { get; set; } + public string CurSizeString { get; set; } + public string TotalSizeString { get; set; } + public long CountIncreSize { get; set; } = 0; + public string DownloadSpeedString { get; set; } public void Feedback() => NetHelper.OpenWeb(Global.URL_TIDAL_ISSUES); public void Telegram() => NetHelper.OpenWeb(Global.URL_TIDAL_GROUP); public void ClickPaypal() => NetHelper.OpenWeb(Global.URL_PAYPAL); public void ClickBuymeacoffee() => NetHelper.OpenWeb(Global.URL_PAYPAL); + public void Donate() { if (ShowDonate == Visibility.Collapsed) @@ -32,52 +44,78 @@ public void Donate() public void WindowClose() => this.ViewVisibility = Visibility.Hidden; - + public void EndUpdate() + { + ShowProgress = Visibility.Collapsed; + } //Update - public void StartUpdate(string sVersion) + public void StartUpdate() { - string url = GithubHelper.getFileUrl(Global.NAME_GITHUB_AUTHOR, Global.NAME_GITHUB_PROJECT, sVersion, Global.NAME_GITHUB_FILE); + Progress.ValueInt = 0; + CountIncreSize = 0; + ShowProgress = Visibility.Visible; + DownloadStatusInfo = "Get new version file-url..."; - if(PathHelper.Mkdirs(Global.PATH_UPDATE) == false) + string url = GithubHelper.getFileUrl(Global.NAME_GITHUB_AUTHOR, Global.NAME_GITHUB_PROJECT, LastVersion, Global.NAME_GITHUB_FILE); + if (PathHelper.Mkdirs(Global.PATH_UPDATE) == false) { - Dialog.Show(new MessageView(MessageBoxImage.Error, "Creat folder falied!", false)); + DownloadStatusInfo = "Creat update folder falied!"; + EndUpdate(); return; } - DownloadFileHepler.StartAsync(url, Global.PATH_UPDATE + Global.NAME_GITHUB_FILE, null, UpdateDownloadNotify, CompleteDownloadNotify, ErrDownloadNotify, 3); + DownloadStatusInfo = "Start update..."; + Progress.SetStatus(ProgressHelper.STATUS.RUNNING); + StartTime = TimeHelper.GetCurrentTime(); + LoginKey key = Tools.GetKey(); + DownloadFileHepler.StartAsync(url, Global.PATH_UPDATE + Global.NAME_GITHUB_FILE, null, UpdateDownloadNotify, CompleteDownloadNotify, ErrDownloadNotify, 3, Proxy: key.Proxy); } public bool UpdateDownloadNotify(long lTotalSize, long lAlreadyDownloadSize, long lIncreSize, object data) { - //int progress = (int)(lAlreadyDownloadSize * 100 / lTotalSize); - //if (progress > ProgressValue) - // ProgressValue = progress; - - //float Size; - //if (TotalSize.IsBlank()) - //{ - // Size = (float)lTotalSize / 1048576; - // TotalSize = Size.ToString("#0.00"); - //} - - //Size = (float)lAlreadyDownloadSize / 1048576; - //DownloadSize = Size.ToString("#0.00"); + Progress.UpdateInt(lAlreadyDownloadSize, lTotalSize); + if (Progress.GetStatus() != ProgressHelper.STATUS.RUNNING) + return false; + + CountIncreSize += lIncreSize; + long consumeTime = TimeHelper.CalcConsumeTime(StartTime); + + if (consumeTime >= 1000) + { + DownloadSpeedString = AIGS.Common.Convert.ConverStorageUintToString(CountIncreSize, AIGS.Common.Convert.UnitType.BYTE) + "/S"; + CountIncreSize = 0; + StartTime = TimeHelper.GetCurrentTime(); + } + + CurSizeString = AIGS.Common.Convert.ConverStorageUintToString(lAlreadyDownloadSize, AIGS.Common.Convert.UnitType.BYTE); + if (TotalSizeString.IsBlank()) + TotalSizeString = AIGS.Common.Convert.ConverStorageUintToString(lTotalSize, AIGS.Common.Convert.UnitType.BYTE); + + DownloadStatusInfo = CurSizeString + " / " + TotalSizeString + " " + DownloadSpeedString; return true; } public void CompleteDownloadNotify(long lTotalSize, object data) { - //ProgressValue = 100; + Progress.ValueInt = 100; + Progress.SetStatus(ProgressHelper.STATUS.COMPLETE); + DownloadStatusInfo = "Download complete, start update..."; + + string sBat = "ping -n 5 127.0.0.1\n"; + sBat += string.Format("move {0} {1}\\tidal-gui.exe\n", Global.PATH_UPDATE + Global.NAME_GITHUB_FILE, Path.GetFullPath(".\\")); + sBat += string.Format("start {0}\\tidal-gui.exe\n", Path.GetFullPath(".\\")); + FileHelper.Write(sBat, true, Global.PATH_UPDATEBAT); - //if (UnzipRequire()) - // Action((true, "Download success!")); - //else - // ShowErr(); + Application.Current.Dispatcher.BeginInvoke((Action)delegate () + { + CmdHelper.StartExe(Global.PATH_UPDATEBAT, null, IsShowWindow: false); + MainVM.WindowClose(); + }); } public void ErrDownloadNotify(long lTotalSize, long lAlreadyDownloadSize, string sErrMsg, object data) { - //ShowErr(); + DownloadStatusInfo = sErrMsg; } } } diff --git a/TIDALDL-UI-PRO/Pages/MainViewModel.cs b/TIDALDL-UI-PRO/Pages/MainViewModel.cs index 50482b4..13f5fa2 100644 --- a/TIDALDL-UI-PRO/Pages/MainViewModel.cs +++ b/TIDALDL-UI-PRO/Pages/MainViewModel.cs @@ -39,7 +39,8 @@ protected override async void OnViewLoaded() Settings.Change(Global.Settings); //Show about - if(Global.Settings.Version != VMAbout.Version) + VMAbout.MainVM = this; + if (Global.Settings.Version != VMAbout.Version) { Global.Settings.Version = VMAbout.Version; Global.Settings.Save(); @@ -47,10 +48,10 @@ protected override async void OnViewLoaded() } //Update new version - string version = await GithubHelper.getLastReleaseVersionAsync(Global.NAME_GITHUB_AUTHOR, Global.NAME_GITHUB_PROJECT); - VMAbout.LastVersion = version; - if (version != null && version != VMAbout.Version) + VMAbout.LastVersion = await GithubHelper.getLastReleaseVersionAsync(Global.NAME_GITHUB_AUTHOR, Global.NAME_GITHUB_PROJECT); + if (VMAbout.LastVersion != null && VMAbout.LastVersion != VMAbout.Version) { + VMAbout.EnableUpdate = Visibility.Visible; ShowPage("about"); } } diff --git a/TIDALDL-UI-PRO/Properties/AssemblyInfo.cs b/TIDALDL-UI-PRO/Properties/AssemblyInfo.cs index 7260da3..ac6934b 100644 --- a/TIDALDL-UI-PRO/Properties/AssemblyInfo.cs +++ b/TIDALDL-UI-PRO/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.1.1")] -[assembly: AssemblyFileVersion("1.2.1.1")] +[assembly: AssemblyVersion("1.2.1.2")] +[assembly: AssemblyFileVersion("1.2.1.2")] diff --git a/TIDALDL-UI-PRO/Properties/Geometries.xaml b/TIDALDL-UI-PRO/Properties/Geometries.xaml index 546d5cf..db916db 100644 --- a/TIDALDL-UI-PRO/Properties/Geometries.xaml +++ b/TIDALDL-UI-PRO/Properties/Geometries.xaml @@ -25,7 +25,8 @@ M 11.5,3C 16.7467,3 21,7.25329 21,12.5C 21,17.7467 16.7467,22 11.5,22C 6.25329,22 2,17.7467 2,12.5C 2,7.25329 6.25329,3 11.5,3 Z M 11.5,4C 6.80557,4 3,7.80558 3,12.5C 3,17.1944 6.80558,21 11.5,21C 16.1944,21 20,17.1944 20,12.5C 20,7.80558 16.1944,4 11.5,4 Z M 11,17L 11,15L 12,15L 12,17L 11,17 Z M 11,13L 11,8.00001L 12,8.00001L 12,13L 11,13 Z M 18,19C 18,20.6569 16.6568,22 15,22L 7.99999,22C 6.34314,22 5,20.6569 5,19L 4.99999,7.00003L 4,7.00001L 4,4.00002L 8.49999,4.00001L 9.49999,3.00001L 13.5,3.00002L 14.5,4.00002L 19,4.00002L 19,7.00001L 18,7.00003L 18,19 Z M 5.99998,7.00003L 5.99999,19C 5.99999,20.1046 6.89542,21 7.99999,21L 15,21C 16.1046,21 17,20.1046 17,19L 17,7.00003L 5.99998,7.00003 Z M 18,6.00002L 18,5.00002L 14,5.00001L 13,4.00001L 10,4.00001L 8.99999,5.00001L 4.99999,5.00002L 4.99999,6.00002L 18,6.00002 Z M 7.99999,9.00001L 8.99999,9.00001L 8.99999,19L 7.99999,19L 7.99999,9.00001 Z M 14,9.00001L 15,9.00001L 15,19L 14,19L 14,9.00001 Z M 15.1716,16.7426L 14.4645,16.0355L 18,12.5L 14.4645,8.96446L 15.1716,8.25735L 19.4142,12.5L 15.1716,16.7426 Z M 7.82842,16.7426L 3.58577,12.5L 7.82842,8.25735L 8.53552,8.96446L 4.99999,12.5L 8.53553,16.0355L 7.82842,16.7426 Z - + M448 437c23 0 43 -19 43 -42v-299c0 -23 -20 -43 -43 -43h-384c-23 0 -43 20 -43 43v299c0 23 20 42 43 42h128v-42h-128v-299h384v299h-128v42h128zM256 160l-85 85h64v192h42v-192h64z + M9.78,18.65L10.06,14.42L17.74,7.5C18.08,7.19 17.67,7.04 17.22,7.31L7.74,13.3L3.64,12C2.76,11.75 2.75,11.14 3.84,10.7L19.81,4.54C20.54,4.21 21.24,4.72 20.96,5.84L18.24,18.65C18.05,19.56 17.5,19.78 16.74,19.36L12.6,16.3L10.61,18.23C10.38,18.46 10.19,18.65 9.78,18.65Z M310.204 242.638c27.73-14.18 45.377-39.39 41.28-81.3-5.358-57.351-52.458-76.573-114.85-81.929V0h-48.528v77.203c-12.605 0-25.525.315-38.444.63V0h-48.528v79.409c-17.842.539-38.622.276-97.37 0v51.678c38.314-.678 58.417-3.14 63.023 21.427v217.429c-2.925 19.492-18.524 16.685-53.255 16.071L3.765 443.68c88.481 0 97.37.315 97.37.315V512h48.528v-67.06c13.234.315 26.154.315 38.444.315V512h48.528v-68.005c81.299-4.412 135.647-24.894 142.895-101.467 5.671-61.446-23.32-88.862-69.326-99.89zM150.608 134.553c27.415 0 113.126-8.507 113.126 48.528 0 54.515-85.71 48.212-113.126 48.212v-96.74zm0 251.776V279.821c32.772 0 133.127-9.138 133.127 53.255-.001 60.186-100.355 53.253-133.127 53.253z M111.4 295.9c-3.5 19.2-17.4 108.7-21.5 134-.3 1.8-1 2.5-3 2.5H12.3c-7.6 0-13.1-6.6-12.1-13.9L58.8 46.6c1.5-9.6 10.1-16.9 20-16.9 152.3 0 165.1-3.7 204 11.4 60.1 23.3 65.6 79.5 44 140.3-21.5 62.6-72.5 89.5-140.1 90.3-43.4.7-69.5-7-75.3 24.2zM357.1 152c-1.8-1.3-2.5-1.8-3 1.3-2 11.4-5.1 22.5-8.8 33.6-39.9 113.8-150.5 103.9-204.5 103.9-6.1 0-10.1 3.3-10.9 9.4-22.6 140.4-27.1 169.7-27.1 169.7-1 7.1 3.5 12.9 10.6 12.9h63.5c8.6 0 15.7-6.3 17.4-14.9.7-5.4-1.1 6.1 14.4-91.3 4.6-22 14.3-19.7 29.3-19.7 71 0 126.4-28.8 142.9-112.3 6.5-34.8 4.6-71.4-23.8-92.6z diff --git a/TIDALDL-UI-PRO/Properties/Lang/StringResource.xaml b/TIDALDL-UI-PRO/Properties/Lang/StringResource.xaml index 5fc9889..0b8bd60 100644 --- a/TIDALDL-UI-PRO/Properties/Lang/StringResource.xaml +++ b/TIDALDL-UI-PRO/Properties/Lang/StringResource.xaml @@ -24,6 +24,7 @@ Cloud Music Spotify Tidal + Update Platform diff --git a/TIDALDL-UI-PRO/UPDATE_LOG.md b/TIDALDL-UI-PRO/UPDATE_LOG.md index d9c24c7..c958bd2 100644 --- a/TIDALDL-UI-PRO/UPDATE_LOG.md +++ b/TIDALDL-UI-PRO/UPDATE_LOG.md @@ -3,6 +3,7 @@ - [x] Fix: download playlist +- [X] About-Page: show update-button when a new version released #### v1.2.1.1 - [x] Fix: download video