Browse Source

1.Update UI.
2.Add retry logic in libfisp.

Justin 1 year ago
parent
commit
1c9a517764

+ 1 - 8
fisp/App.xaml.cs

@@ -1,11 +1,4 @@
-using fisp.Controls;
-using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Data;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Windows;
+using System.Windows;
 
 namespace fisp
 {

+ 0 - 63
fisp/Controls/LoadingControl.xaml

@@ -1,63 +0,0 @@
-<UserControl x:Class="fisp.Controls.LoadingControl"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-             xmlns:local="clr-namespace:fisp.Controls"
-             mc:Ignorable="d" 
-             IsVisibleChanged="OnVisibleChanged">
-    <UserControl.Background>
-        <SolidColorBrush Color="Transparent" />
-    </UserControl.Background>
-    <UserControl.Resources>
-        <SolidColorBrush Color="#FF007BE5" x:Key="CirclesColor" />
-    </UserControl.Resources>
-    <Viewbox Width="50" Height="50" HorizontalAlignment="Center" VerticalAlignment="Center">
-        <Canvas RenderTransformOrigin="0.5,0.5"    
-                    HorizontalAlignment="Center"    
-                    VerticalAlignment="Center" Width="120"    
-                    Height="120" Loaded="OnCanvasLoaded"    
-                    Unloaded="OnCanvasUnloaded"  >
-            <Ellipse x:Name="C0" Width="20" Height="20"    
-                         Canvas.Left="0"    
-                         Canvas.Top="0" Stretch="Fill"    
-                         Fill="{StaticResource CirclesColor}" Opacity="1.0"/>
-            <Ellipse x:Name="C1" Width="20" Height="20"    
-                         Canvas.Left="0"    
-                         Canvas.Top="0" Stretch="Fill"    
-                         Fill="{StaticResource CirclesColor}" Opacity="0.9"/>
-            <Ellipse x:Name="C2" Width="20" Height="20"    
-                         Canvas.Left="0"    
-                         Canvas.Top="0" Stretch="Fill"    
-                         Fill="{StaticResource CirclesColor}" Opacity="0.8"/>
-            <Ellipse x:Name="C3" Width="20" Height="20"    
-                         Canvas.Left="0"    
-                         Canvas.Top="0" Stretch="Fill"    
-                         Fill="{StaticResource CirclesColor}" Opacity="0.7"/>
-            <Ellipse x:Name="C4" Width="20" Height="20"    
-                         Canvas.Left="0"    
-                         Canvas.Top="0" Stretch="Fill"    
-                         Fill="{StaticResource CirclesColor}" Opacity="0.6"/>
-            <Ellipse x:Name="C5" Width="20" Height="20"    
-                         Canvas.Left="0"    
-                         Canvas.Top="0" Stretch="Fill"    
-                         Fill="{StaticResource CirclesColor}" Opacity="0.5"/>
-            <Ellipse x:Name="C6" Width="20" Height="20"    
-                         Canvas.Left="0"    
-                         Canvas.Top="0" Stretch="Fill"    
-                         Fill="{StaticResource CirclesColor}" Opacity="0.4"/>
-            <Ellipse x:Name="C7" Width="20" Height="20"    
-                         Canvas.Left="0"    
-                         Canvas.Top="0" Stretch="Fill"    
-                         Fill="{StaticResource CirclesColor}" Opacity="0.3"/>
-            <Ellipse x:Name="C8" Width="20" Height="20"    
-                         Canvas.Left="0"    
-                         Canvas.Top="0" Stretch="Fill"    
-                         Fill="{StaticResource CirclesColor}" Opacity="0.2"/>
-            <Canvas.RenderTransform>
-                <RotateTransform x:Name="SpinnerRotate"    
-                         Angle="0" />
-            </Canvas.RenderTransform>
-        </Canvas>
-    </Viewbox>
-</UserControl>

+ 0 - 92
fisp/Controls/LoadingControl.xaml.cs

@@ -1,92 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-using System.Windows.Threading;
-
-namespace fisp.Controls
-{
-    /// <summary>
-    /// Loading.xaml 的交互逻辑
-    /// </summary>
-    public partial class LoadingControl : UserControl
-    {
-        private readonly DispatcherTimer animationTimer;
-
-        public LoadingControl()
-        {
-            InitializeComponent();
-
-            animationTimer = new DispatcherTimer(DispatcherPriority.ContextIdle, Dispatcher);
-            animationTimer.Interval = new TimeSpan(0, 0, 0, 0, 1000/20);
-        }
-
-        private void OnVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
-        {
-            bool visible = (bool)e.NewValue;
-
-            if (visible)
-            {
-                Start();
-            }
-            else
-            {
-                Stop();
-            }
-        }
-
-        private void OnCanvasLoaded(object sender, RoutedEventArgs e)
-        {
-            const double offset = Math.PI;
-            const double step = Math.PI * 2 / 10.0;
-
-            SetPosition(C0, offset, 0.0, step);
-            SetPosition(C1, offset, 1.0, step);
-            SetPosition(C2, offset, 2.0, step);
-            SetPosition(C3, offset, 3.0, step);
-            SetPosition(C4, offset, 4.0, step);
-            SetPosition(C5, offset, 5.0, step);
-            SetPosition(C6, offset, 6.0, step);
-            SetPosition(C7, offset, 7.0, step);
-            SetPosition(C8, offset, 8.0, step);
-        }
-        private void OnCanvasUnloaded(object sender, RoutedEventArgs e)
-        {
-            Stop();
-        }
-
-        private void SetPosition(Ellipse ellipse, double offset, double posOffSet, double step)
-        {
-            ellipse.SetValue(Canvas.LeftProperty, 50.0 + Math.Sin(offset + posOffSet * step) * 50.0);
-
-            ellipse.SetValue(Canvas.TopProperty, 50 + Math.Cos(offset + posOffSet * step) * 50.0);
-        }
-
-        private void Start()
-        {
-            animationTimer.Tick += OnAnimationTick;
-            animationTimer.Start();
-        }
-
-        private void Stop()
-        {
-            animationTimer.Stop();
-            animationTimer.Tick -= OnAnimationTick;
-        }
-
-        private void OnAnimationTick(object sender, EventArgs e)
-        {
-            SpinnerRotate.Angle = (SpinnerRotate.Angle + 36) % 360;
-        }
-    }
-}

+ 117 - 54
fisp/MainWindow.xaml

@@ -2,71 +2,134 @@
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:busyIndicator="https://github.com/moh3ngolshani/BusyIndicator"
         mc:Ignorable="d"
-        Title="FLYINSONO PUBLISH TOOL" Height="200" Width="640" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Loaded="OnLoaded">
+        Title="FLYINSONO PUBLISH TOOL" Height="556" Width="800" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
     <busyIndicator:BusyMask x:Name="BusyIndicator" 
                         IsBusy="False" 
                         IndicatorType="ThreeDots" 
                         BusyContent="Please wait..." 
+                        FontSize="16"
                         BusyContentMargin="0,20,0,0" 
                         IsBusyAtStartup="False" >
-        <Grid>
-            <Grid.RowDefinitions>
-                <RowDefinition Height="40" />
-                <RowDefinition Height="Auto" />
-                <RowDefinition Height="Auto" />
-                <RowDefinition Height="Auto" />
-            </Grid.RowDefinitions>
-            <Button Grid.Row="0" x:Name="ButtonMaintenance" Content="Maintenance" Margin="8,8,8,8" Click="OnMaintenanceClick"></Button>
-            <StackPanel Margin="8" Grid.Row="1" Orientation="Horizontal">
-                <TextBlock Margin="0,4,4,4" Text="Target: " FontSize="14"></TextBlock>
-                <ComboBox x:Name="ComboBoxChannel" Width="100" SelectedValue="Embedded" Height="32" Margin="0,0,8,0" Padding="4,4,4,4" VerticalContentAlignment="Center" SelectionChanged="OnChannelSelectionChanged">
-                    <ComboBoxItem Content="Embedded"></ComboBoxItem>
-                    <ComboBoxItem Content="Public" ></ComboBoxItem>
-                </ComboBox>
-                <TextBlock VerticalAlignment="Center" Text="Folder:" FontSize="14"/>
-                <TextBox x:Name="SourceFolder" Height="32" Margin="8,0,0,0" Width="300" IsReadOnly="True" VerticalContentAlignment="Center" Padding="2" FontSize="14"/>
-                <Button x:Name="ButtonChooseSourceFolder" Content="..." Width="64" Click="OnChooseSourceFolderClick"/>
-            </StackPanel>
-            <StackPanel Grid.Row="2" Margin="8" Orientation="Horizontal">
-                <TextBlock Margin="16,0,0,0" VerticalAlignment="Center" Text="Package Name:" FontSize="14"/>
-                <TextBox x:Name="PackageName" Margin="6" BorderBrush="Transparent" BorderThickness="0" IsReadOnly="true" Text="0.0.0.0" Foreground="YellowGreen" FontSize="18" TextChanged="OnPackageNameChanged"/>
-                <Button x:Name="ButtonPackage" Content="Package" FontSize="14" Margin="8,0,8,0" Click="OnPackageClick"></Button>
-                <TextBlock x:Name="PackageConsole" Visibility="Collapsed" VerticalAlignment="Center" />
-            </StackPanel>
-            <!--CDN上传部分 Start-->
-            <Grid Grid.Row="3" x:Name="GridPublish" Visibility="Collapsed">
-                <Grid.RowDefinitions>
-                    <RowDefinition Height="Auto" />
-                    <RowDefinition Height="Auto" />
-                    <RowDefinition Height="Auto" />
-                    <RowDefinition Height="Auto" />
-                </Grid.RowDefinitions>
-                <Grid Margin="8" Grid.Row="0">
+        <TabControl x:Name="TopPanel">
+            <TabControl.Resources>
+                <Style TargetType="TextBlock">
+                    <Style.Triggers>
+                        <MultiTrigger>
+                            <MultiTrigger.Conditions>
+                                <Condition Property="IsEnabled" Value="False" />
+                            </MultiTrigger.Conditions>
+                            <Setter Property="Foreground" Value="Gray" />
+                        </MultiTrigger>
+                        <MultiTrigger>
+                            <MultiTrigger.Conditions>
+                                <Condition Property="IsEnabled" Value="True" />
+                            </MultiTrigger.Conditions>
+                            <Setter Property="Foreground" Value="Black" />
+                        </MultiTrigger>
+                    </Style.Triggers>
+                </Style>
+            </TabControl.Resources>
+            <TabItem Header="Publish" FontSize="14" FontWeight="Bold">
+                <Grid>
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="Auto" />
+                        <RowDefinition Height="*" />
+                    </Grid.RowDefinitions>
+                    <GroupBox x:Name="PublishStep1" Margin="4" Grid.Row="0">
+                        <GroupBox.Header>
+                            <TextBlock Text="Package"/>
+                        </GroupBox.Header>
+                        <StackPanel>
+                            <StackPanel Margin="8" Grid.Row="1" Orientation="Horizontal">
+                                <TextBlock Margin="0,4,8,4" Text="Target Channel:" VerticalAlignment="Center" FontSize="14" FontWeight="Normal"></TextBlock>
+                                <ComboBox x:Name="ComboBoxChannel" Width="120" SelectedIndex="0" VerticalAlignment="Center" Height="32" Margin="0,0,8,0" Padding="4" VerticalContentAlignment="Center">
+                                    <ComboBoxItem>
+                                        <TextBlock Text="Embedded"/>
+                                    </ComboBoxItem>
+                                    <ComboBoxItem>
+                                        <TextBlock Text="Public"/>
+                                    </ComboBoxItem>
+                                </ComboBox>
+                                <TextBlock Margin="16,0,0,0" VerticalAlignment="Center" Text="Source Folder:" FontSize="14" FontWeight="Normal"/>
+                                <TextBox x:Name="SourceFolder" Height="32" Margin="8,0,0,0" Width="330" IsReadOnly="True" VerticalContentAlignment="Center" Padding="2" FontSize="14"/>
+                                <Button x:Name="ButtonChooseSourceFolder" Content="..." Width="50" BorderThickness="0,1,1,1" Click="OnChooseSourceFolderClick"/>
+                            </StackPanel>
+                            <StackPanel Margin="8" Orientation="Horizontal">
+                                <TextBlock VerticalAlignment="Center" Text="Package Name:" FontSize="14" FontWeight="Normal"/>
+                                <TextBox x:Name="PackageName" Margin="6" BorderBrush="Transparent" BorderThickness="0" IsReadOnly="true" Text="0.0.0.0" Foreground="YellowGreen" FontSize="18" TextChanged="OnPackageNameChanged"/>
+                            </StackPanel>
+                            <StackPanel Orientation="Horizontal">
+                                <Button x:Name="PackageButton" Width="96" Height="48" Content="PACKAGE" FontSize="16" FontWeight="Bold" IsEnabled="False" Margin="8" Click="OnPackageClick"></Button>
+                                <TextBlock x:Name="PackageFolder" Margin="6" FontSize="18" VerticalAlignment="Center" TextDecorations="Underline" Cursor="Hand" ToolTip="Click to open the folder" MouseDown="OnPackageConsoleMouseDown" />
+                            </StackPanel>
+                        </StackPanel>
+                    </GroupBox>
+
+                    <GroupBox x:Name="PublishStep2" Margin="4" Grid.Row="1" IsEnabled="False">
+                        <GroupBox.Header>
+                            <TextBlock Text="Publish"/>
+                        </GroupBox.Header>
+                        <Grid>
+                            <Grid.RowDefinitions>
+                                <RowDefinition Height="Auto" />
+                                <RowDefinition Height="Auto" />
+                                <RowDefinition Height="Auto" />
+                            </Grid.RowDefinitions>
+                            <Grid Margin="8" Grid.Row="0">
+                                <Grid.RowDefinitions>
+                                    <RowDefinition Height="Auto"/>
+                                    <RowDefinition Height="Auto"/>
+                                    <RowDefinition Height="16"/>
+                                    <RowDefinition Height="Auto"/>
+                                    <RowDefinition Height="Auto"/>
+                                </Grid.RowDefinitions>
+                                <TextBlock Grid.Row="0" Text="Uploading Progress" FontSize="18" FontWeight="Bold"/>
+                                <StackPanel Grid.Row="1">
+                                    <TextBlock Margin="0,4,4,4" x:Name="UploadingProgressText" FontSize="12" FontWeight="Normal"/>
+                                    <ProgressBar x:Name="UploadingProgress" Height="36"  VerticalAlignment="Center"/>
+                                </StackPanel>
+                                <TextBlock Grid.Row="3" Text="Total Progress" FontSize="18" FontWeight="Bold"/>
+                                <StackPanel Grid.Row="4">
+                                    <TextBlock Margin="0,4,4,4" x:Name="TotalProgressText" FontSize="12" FontWeight="Normal"/>
+                                    <ProgressBar x:Name="TotalProgress" Height="36"  VerticalAlignment="Center"/>
+                                </StackPanel>
+                            </Grid>
+                            <StackPanel Grid.Row="1" Orientation="Horizontal">
+                                <Button x:Name="PublishButton" IsEnabled="False" Height="48" Width="96" Margin="8" Content="PUBLISH" VerticalAlignment="Center" FontSize="16" FontWeight="Bold" Click="OnPlulishClick"/>
+                                <TextBox x:Name="PublishUrl" Margin="6" VerticalAlignment="Center" BorderBrush="Transparent" BorderThickness="0" IsReadOnly="true" Foreground="Blue" FontSize="18" Visibility="Collapsed"/>
+                            </StackPanel>
+                        </Grid>
+                    </GroupBox>
+                   
+                </Grid>
+            </TabItem>
+            <TabItem Header="Maintenance" FontSize="14" FontWeight="Bold">
+                <Grid>
                     <Grid.RowDefinitions>
                         <RowDefinition Height="Auto"/>
-                        <RowDefinition Height="Auto"/>
-                        <RowDefinition Height="16"/>
-                        <RowDefinition Height="Auto"/>
-                        <RowDefinition Height="Auto"/>
+                        <RowDefinition Height="*"/>
                     </Grid.RowDefinitions>
-                    <TextBlock Grid.Row="0" Text="Uploading Progress" FontSize="18" FontWeight="Bold"/>
-                    <StackPanel Grid.Row="1">
-                        <TextBlock Margin="0,4,4,4" x:Name="UploadingProgressText"/>
-                        <ProgressBar x:Name="UploadingProgress" Height="36"  VerticalAlignment="Center"/>
-                    </StackPanel>
-                    <TextBlock Grid.Row="3" Text="Total Progress" FontSize="18" FontWeight="Bold"/>
-                    <StackPanel Grid.Row="4">
-                        <TextBlock Margin="0,4,4,4" x:Name="TotalProgressText"/>
-                        <ProgressBar x:Name="TotalProgress" Height="36"  VerticalAlignment="Center"/>
-                    </StackPanel>
+                    <TextBlock Margin="8" Text="Online Folders:" FontSize="14" FontWeight="Bold"/>
+                    <ListBox Grid.Row="1" x:Name="OnlineFolderList" Margin="8,0,8,8" HorizontalContentAlignment="Stretch">
+                        <ListBox.ItemTemplate>
+                            <DataTemplate>
+                                <Grid HorizontalAlignment="Stretch">
+                                    <Grid.ColumnDefinitions>
+                                        <ColumnDefinition Width="*"/>
+                                        <ColumnDefinition Width="48"/>
+                                    </Grid.ColumnDefinitions>
+                                    <TextBlock Grid.Column="0" Text="{Binding}" FontSize="14" VerticalAlignment="Center" HorizontalAlignment="Left"/>
+                                    <TextBlock Text="Delete" HorizontalAlignment="Center" FontSize="12" TextDecorations="Underline" Cursor="Hand"  Foreground="Red" VerticalAlignment="Center" Grid.Column="1" MouseDown="OnDeleteFolderClick"/>
+                                </Grid>
+                            </DataTemplate>
+                        </ListBox.ItemTemplate>
+                    </ListBox>
+                    <Border Width="0.5" Grid.Row="0" Background="Gray" Grid.RowSpan="2" HorizontalAlignment="Left"/>
                 </Grid>
-                <TextBox  Grid.Row="1" x:Name="PublishUrl" Margin="6" BorderBrush="Transparent" BorderThickness="0" IsReadOnly="true" Text="https://app.fis.plus/flyinsono20230711/" Foreground="Blue" FontSize="18"/>
-                <Button Grid.Row="2" x:Name="ButtonPublish" Height="48" Margin="8" Content="PUBLISH" VerticalAlignment="Center" FontSize="24" FontWeight="Bold" Click="OnPlulishClick"/>
-            </Grid>
-            <!--CDN上传部分 End-->
-        </Grid>
+            </TabItem>
+        </TabControl>
     </busyIndicator:BusyMask>
 </Window>

+ 157 - 83
fisp/MainWindow.xaml.cs

@@ -3,6 +3,7 @@ using System.Diagnostics;
 using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
+using System.Windows.Input;
 using WindowsAPICodePack.Dialogs;
 
 namespace fisp
@@ -12,7 +13,7 @@ namespace fisp
     /// </summary>
     public partial class MainWindow : Window
     {
-        private PackageHandler? packageHandler;
+        private PackageHandler? _packageHandler;
         public bool IsEmbedded => ComboBoxChannel.SelectedIndex == 0;
 
         public MainWindow()
@@ -22,12 +23,8 @@ namespace fisp
             UploadingProgress.Maximum = 100;
             TotalProgress.Minimum = 0;
             TotalProgress.Maximum = 100;
-            ComboBoxChannel.SelectedIndex = 0;
-            PublishUrl.Text = $"https://app.fis.plus/{PackageName.Text}/index.html";
-        }
-
-        private void OnLoaded(object sender, RoutedEventArgs e)
-        {
+            TopPanel.SelectionChanged += OnTabControlSelectionChanged;
+            ComboBoxChannel.SelectionChanged += OnChannelSelectionChanged;          
         }
 
         private void OnChooseSourceFolderClick(object sender, RoutedEventArgs e)
@@ -39,47 +36,70 @@ namespace fisp
             if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
             {
                 SourceFolder.Text = dialog.FileName;
-                packageHandler = new PackageHandler(SourceFolder.Text, IsEmbedded);
-                PackageName.Text = packageHandler.FullBuildName;
-                HidePublishPanel();
-                PackageConsole.Visibility = Visibility.Collapsed;
+                _packageHandler = new PackageHandler(SourceFolder.Text, IsEmbedded);
+                PackageName.Text = _packageHandler.FullBuildName;
+                PackageFolder.Visibility = Visibility.Collapsed;
+                if(_packageHandler.FullBuildName == "Error!")
+                {
+                    _packageHandler = null;
+                    PackageButton.IsEnabled = false;
+                    ResetPublishStep();
+                    PublishStep2.IsEnabled = false;
+                    MessageBox.Show(this, $"Please choose correct flutter web folder!", "Choose folder", MessageBoxButton.OK, MessageBoxImage.Error);
+                }
+                else
+                {
+                    PackageButton.IsEnabled = true;
+                }
             }
         }
 
-        private async void OnPackageClick(object sender, RoutedEventArgs e)
+        private void OnPackageClick(object sender, RoutedEventArgs e)
         {
-            if (packageHandler == null)
+            if (_packageHandler == null)
             {
                 return;
             }
-            ShowBusy();
-
-            await packageHandler.Handle();
-
-            await packageHandler.GenerateZip();
-
-            PackageConsole.Visibility = Visibility.Visible;
-            PackageConsole.Text = $"Success! Dist folder: {PackageHandler.WORKSPACE}";
+            BusyIndicator.IsBusy = true;
+            BusyIndicator.BusyContent = "Packaging...";
 
-            if (!IsEmbedded)
+            Task.Run(async () =>
             {
-                ShowPublishPanel();
-            }
+                try
+                {
+                    await _packageHandler.Handle();
+                    await _packageHandler.GenerateZip();
+                    Dispatcher.Invoke(() =>
+                    {
+                        PackageFolder.Visibility = Visibility.Visible;
+                        PackageFolder.Text = PackageHandler.WORKSPACE;
+                        BusyIndicator.IsBusy = false;
+                        if (!IsEmbedded)
+                        {
+                            PublishButton.IsEnabled = true;
+                        }
+                        MessageBox.Show(this, "Package successed!", "Package result", MessageBoxButton.OK, MessageBoxImage.Information);
+                    });
+                }
+                catch (Exception ex)
+                {
+                    BusyIndicator.IsBusy = false;
+                    MessageBox.Show(this, $"Package failed! \n\n {ex.Message}", "Package result", MessageBoxButton.OK, MessageBoxImage.Error);
+                }
 
-            HideBusy();
+            });
 
-            MessageBox.Show("Package successed!", "Package result", MessageBoxButton.OK, MessageBoxImage.Information);
         }
 
         private void OnPlulishClick(object sender, RoutedEventArgs e)
         {
-            if (packageHandler == null) return;
+            if (_packageHandler == null) return;
 
             LockActions();
             libfisp.fisp publisher = new libfisp.fisp();
             try
             {
-                var task = publisher.UploadDir(packageHandler.DistFolder, packageHandler.FullBuildName);
+                var task = publisher.UploadDir(_packageHandler.DistFolder, _packageHandler.FullBuildName);
                 task.UploadingProgress += (s, e) =>
                 {
                     Dispatcher.Invoke(() =>
@@ -100,8 +120,10 @@ namespace fisp
                 {
                     Dispatcher.Invoke(() =>
                     {
+                        PublishUrl.Text = $"https://app.fis.plus/{PackageName.Text}/index.html";
+                        PublishUrl.Visibility = Visibility.Visible;
                         UnlockActions();
-                        MessageBox.Show("Publish successed!", "Publish result", MessageBoxButton.OK, MessageBoxImage.Information);
+                        MessageBox.Show(this,"Publish successed!", "Publish result", MessageBoxButton.OK, MessageBoxImage.Information);
                     });
                 };
                 task.Failed += (s, m) =>
@@ -109,25 +131,36 @@ namespace fisp
                     Dispatcher.Invoke(() =>
                     {
                         UnlockActions();
-                        MessageBox.Show($"Publish failed:\n\n{m}", "Publish result", MessageBoxButton.OK, MessageBoxImage.Error);
+                        MessageBox.Show(this, $"Publish failed:\n\n{m}", "Publish result", MessageBoxButton.OK, MessageBoxImage.Error);
                     });
                 };
             }
             catch (Exception ex)
             {
                 UnlockActions();
-                MessageBox.Show($"Publish failed:\n\n{ex}", "Publish result", MessageBoxButton.OK, MessageBoxImage.Error);
+                MessageBox.Show(this, $"Publish failed:\n\n{ex}", "Publish result", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
 
         private void OnChannelSelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            HidePublishPanel();
-            PackageConsole.Visibility = Visibility.Collapsed;
-            if (packageHandler != null)
+            PackageFolder.Visibility = Visibility.Collapsed;
+            if (_packageHandler != null)
             {
-                packageHandler.IsEmbedded = IsEmbedded;
-            }
+                _packageHandler.IsEmbedded = IsEmbedded;
+            }          
+            ResetPublishStep();
+            PublishStep2.IsEnabled = !IsEmbedded;
+        }
+
+        private void ResetPublishStep()
+        {
+            PublishButton.IsEnabled = false;
+            UploadingProgressText.Text = string.Empty;
+            TotalProgressText.Text = string.Empty;
+            UploadingProgress.Value = 0;
+            TotalProgress.Value = 0;
+            PublishUrl.Visibility = Visibility.Collapsed;
         }
 
         private void OnPackageNameChanged(object sender, TextChangedEventArgs e)
@@ -135,74 +168,115 @@ namespace fisp
             if (PublishUrl != null)
             {
                 PublishUrl.Text = $"https://app.fis.plus/{PackageName.Text}/index.html";
+                PublishStep2.IsEnabled = true;
             }
         }
 
-        private void OnMaintenanceClick(object sender, EventArgs e)
-        {
-            new MaintenanceWindow().ShowDialog();
-        }
 
         /// <summary>
-        /// 显示推送面板
+        /// 锁住所用操作
         /// </summary>
-        private void ShowPublishPanel()
+        private void LockActions()
         {
-            if (GridPublish.Visibility != Visibility.Visible)
-            {
-                GridPublish.Visibility = Visibility.Visible;
-                Height = 480;
-            }
-
-            PublishUrl.Text = $"https://app.fis.plus/{PackageName.Text}/index.html";
+            TopPanel.IsEnabled = false;
         }
 
         /// <summary>
-        /// 隐藏推送面板
+        /// 解锁所有操作
         /// </summary>
-        private void HidePublishPanel()
-        {
-            if (GridPublish.Visibility == Visibility.Visible)
-            {
-                GridPublish.Visibility = Visibility.Collapsed;
-                Height = 200;
-            }
-        }
-
-        private void ShowBusy()
+        private void UnlockActions()
         {
-            BusyIndicator.IsBusy = true;
+            TopPanel.IsEnabled = true;
         }
 
-        private void HideBusy()
+        private void OnTabControlSelectionChanged(object sender, SelectionChangedEventArgs e)
         {
-            BusyIndicator.IsBusy = false;
+            var tabControl = (TabControl)sender;
+            if (tabControl.SelectedIndex == 1)
+            {
+                BusyIndicator.IsBusy = true;
+                OnlineFolderList.Items.Clear();
+                Task.Run(() =>
+                {
+                    libfisp.fisp publisher = new libfisp.fisp();
+                    try
+                    {
+                        var folders = publisher.ListFolders(string.Empty);
+                        Dispatcher.Invoke(() =>
+                        {
+                            foreach (var folder in folders)
+                            {
+                                OnlineFolderList.Items.Add(folder.Replace("/", ""));
+                            }
+                            BusyIndicator.IsBusy = false;
+                        });
+                    }
+                    catch (Exception ex)
+                    {
+                        Dispatcher.Invoke(() =>
+                        {
+                            BusyIndicator.IsBusy = false;
+                            MessageBox.Show(this, $"Load online folders failed:\n\n{ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+                        });
+                    }
+                });
+            }
+            else
+            {
+                OnlineFolderList.Items.Clear();
+            }
         }
 
-        /// <summary>
-        /// 锁住所用操作
-        /// </summary>
-        private void LockActions()
+        private void OnDeleteFolderClick(object sender, MouseButtonEventArgs e)
         {
-            SourceFolder.IsEnabled = false;
-            ComboBoxChannel.IsEnabled = false;
-            ButtonPackage.IsEnabled = false;
-            ButtonMaintenance.IsEnabled = false;
-            ButtonPublish.IsEnabled = false;
-            ButtonChooseSourceFolder.IsEnabled = false;
+            var obj = (TextBlock)sender;
+            var folder = (string)obj.DataContext;
+            if (MessageBox.Show(this, "Are you sure you want to delete this folder?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
+            {
+                LockActions();
+                BusyIndicator.IsBusy = true;
+                libfisp.fisp publisher = new libfisp.fisp();
+                try
+                {
+                    var task = publisher.DeleteFolder(folder + "/");
+                    task.Progress += (s, e) =>
+                    {
+                        Dispatcher.Invoke(() =>
+                        {
+                            BusyIndicator.BusyContent = $"Deleting folder {folder} ... {(int)e}%";
+                        });
+                    };
+                    task.Successed += (s, e) =>
+                    {
+                        Dispatcher.Invoke(() =>
+                        {
+                            OnlineFolderList.Items.Remove(folder);
+                            BusyIndicator.IsBusy = false;
+                            UnlockActions();
+                        });
+                    };
+                    task.Failed += (s, m) =>
+                    {
+                        Dispatcher.Invoke(() =>
+                        {
+                            BusyIndicator.IsBusy = false;
+                            UnlockActions();
+                            MessageBox.Show(this, $"Delete folder {folder} failed:\n\n{m}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+                        });
+                    };
+                }
+                catch (Exception ex)
+                {
+                    BusyIndicator.IsBusy = false;
+                    UnlockActions();
+                    MessageBox.Show(this, $"Delete folder {folder} failed:\n\n{ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
+                }
+            }
         }
 
-        /// <summary>
-        /// 解锁所有操作
-        /// </summary>
-        private void UnlockActions()
+        private void OnPackageConsoleMouseDown(object sender, MouseButtonEventArgs e)
         {
-            SourceFolder.IsEnabled = true;
-            ComboBoxChannel.IsEnabled = true;
-            ButtonPackage.IsEnabled = true;
-            ButtonMaintenance.IsEnabled = true;
-            ButtonPublish.IsEnabled = true;
-            ButtonChooseSourceFolder.IsEnabled = true;
+            Process.Start("explorer.exe", PackageFolder.Text);
         }
     }
 }

+ 0 - 41
fisp/MaintenanceWindow.xaml

@@ -1,41 +0,0 @@
-<Window x:Class="fisp.MaintenanceWindow"
-        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:local="clr-namespace:fisp" 
-        xmlns:busyIndicator="https://github.com/moh3ngolshani/BusyIndicator"
-        mc:Ignorable="d"
-        Title="Maintenance" Height="600" Width="400"
-         ResizeMode="NoResize" WindowStartupLocation="CenterScreen"
-        Loaded="OnLoaded" Unloaded="OnUnloaded">
-    <busyIndicator:BusyMask x:Name="BusyIndicator" 
-                        IsBusy="False" 
-                        IndicatorType="ThreeDots" 
-                        BusyContent="Please wait..." 
-                        BusyContentMargin="0,20,0,0" 
-                        IsBusyAtStartup="False" >
-        <Grid>
-            <Grid.RowDefinitions>
-                <RowDefinition Height="Auto"/>
-                <RowDefinition Height="*"/>
-            </Grid.RowDefinitions>
-            <TextBlock Margin="8" Text="Online Folders:" FontSize="14" FontWeight="Bold"/>
-            <ListBox Grid.Row="1" x:Name="OnlineFolderList" Margin="8,0,8,8" HorizontalContentAlignment="Stretch">
-                <ListBox.ItemTemplate>
-                    <DataTemplate>
-                        <Grid HorizontalAlignment="Stretch">
-                            <Grid.ColumnDefinitions>
-                                <ColumnDefinition Width="*"/>
-                                <ColumnDefinition Width="48"/>
-                            </Grid.ColumnDefinitions>
-                            <TextBlock Grid.Column="0" Text="{Binding}" FontSize="14" VerticalAlignment="Center" HorizontalAlignment="Left"/>
-                            <TextBlock Text="Delete" HorizontalAlignment="Center" FontSize="12" TextDecorations="Underline" Cursor="Hand"  Foreground="Red" VerticalAlignment="Center" Grid.Column="1" MouseDown="OnDeleteClick"/>
-                        </Grid>
-                    </DataTemplate>
-                </ListBox.ItemTemplate>
-            </ListBox>
-            <Border Width="0.5" Grid.Row="0" Background="Gray" Grid.RowSpan="2" HorizontalAlignment="Left"/>
-        </Grid>
-    </busyIndicator:BusyMask>
-</Window>

+ 0 - 106
fisp/MaintenanceWindow.xaml.cs

@@ -1,106 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
-
-namespace fisp
-{
-    /// <summary>
-    /// MaintenanceWindow.xaml 的交互逻辑
-    /// </summary>
-    public partial class MaintenanceWindow : Window
-    {
-        private bool _maintenanceOn;
-
-        public MaintenanceWindow()
-        {
-            InitializeComponent();
-        }
-
-        private void OnLoaded(object sender, RoutedEventArgs e)
-        {
-            BusyIndicator.IsBusy = true;
-            Task.Run(() =>
-            {
-                libfisp.fisp publisher = new libfisp.fisp();
-                try
-                {
-                    var folders = publisher.ListFolders(string.Empty);
-                    Dispatcher.Invoke(() =>
-                    {
-                        foreach (var folder in folders)
-                        {
-                            OnlineFolderList.Items.Add(folder.Replace("/", ""));
-                        }
-                        BusyIndicator.IsBusy = false;
-                    });
-                }
-                catch (Exception ex)
-                {
-                    Dispatcher.Invoke(() =>
-                    {
-                        BusyIndicator.IsBusy = false;
-                        MessageBox.Show(this, $"Load online folders failed:\n\n{ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
-                    });
-                }
-            });
-        }
-
-        private void OnUnloaded(object sender, RoutedEventArgs e)
-        {
-            OnlineFolderList.Items.Clear();
-        }
-
-        private void OnDeleteClick(object sender, MouseButtonEventArgs e)
-        {
-            var obj = (TextBlock)sender;
-            var folder = (string)obj.DataContext;
-            if (MessageBox.Show(this, "Are you sure you want to delete this folder?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
-            {
-                BusyIndicator.IsBusy = true;
-                libfisp.fisp publisher = new libfisp.fisp();
-                try
-                {
-                    var task = publisher.DeleteFolder(folder + "/");
-                    task.Progress += (s, e) =>
-                    {
-                        Dispatcher.Invoke(() =>
-                        {
-                            BusyIndicator.BusyContent = $"Deleting folder {folder} ... {(int)e}%";
-                        });
-                    };
-                    task.Successed += (s, e) =>
-                    {
-                        Dispatcher.Invoke(() =>
-                        {
-                            OnlineFolderList.Items.Remove(folder);
-                            BusyIndicator.IsBusy = false;
-                        });
-                    };
-                    task.Failed += (s, m) =>
-                    {
-                        Dispatcher.Invoke(() =>
-                        {
-                            BusyIndicator.IsBusy = false;
-                            MessageBox.Show(this, $"Delete folder {folder} failed:\n\n{m}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
-                        });
-                    };
-                }
-                catch (Exception ex)
-                {
-                    BusyIndicator.IsBusy = false;
-                    MessageBox.Show(this, $"Delete folder {folder} failed:\n\n{ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
-                }
-            }
-        }
-    }
-}

+ 3 - 8
fisp/PackageHandler.cs

@@ -1,13 +1,9 @@
 using fisp.Models;
 using System;
-using System.Collections.Generic;
 using System.IO;
 using System.IO.Compression;
-using System.Linq;
-using System.Reflection.PortableExecutable;
 using System.Text;
 using System.Text.Json;
-using System.Threading;
 using System.Threading.Tasks;
 using System.Windows;
 
@@ -15,7 +11,7 @@ namespace fisp
 {
     internal class PackageHandler
     {
-        public const string WORKSPACE = "C:/WebPublishWorkspace";
+        public static readonly string WORKSPACE = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FisPublish");
         private const string CDN_ROOT = "https://app.fis.plus/";
         private const string GOOGLE_FONTS_CDN = "https://static.fis.plus/flyinsono/GoogleFonts/";
         private static string GOOGLE_FONT_PATH = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources/GoogleFonts.zip");
@@ -57,10 +53,9 @@ namespace fisp
                     {
                         LoadVersion();
                     }
-                    catch (Exception ex)
+                    catch
                     {
-                        MessageBox.Show($"Please choose correct flutter web folder!", "Choose folder", MessageBoxButton.OK, MessageBoxImage.Error);
-                        return "Error!!!";
+                        return "Error!";
                     }
                 }
                 return $"{_versionModel!.Version}.{_versionModel.BuildNumber}";

+ 0 - 16
fisp/fisp.csproj.user

@@ -1,20 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup />
-  <ItemGroup>
-    <Compile Update="Controls\LoadingControl.xaml.cs">
-      <SubType>Code</SubType>
-    </Compile>
-    <Compile Update="MaintenanceWindow.xaml.cs">
-      <SubType>Code</SubType>
-    </Compile>
-  </ItemGroup>
-  <ItemGroup>
-    <Page Update="Controls\LoadingControl.xaml">
-      <SubType>Designer</SubType>
-    </Page>
-    <Page Update="MaintenanceWindow.xaml">
-      <SubType>Designer</SubType>
-    </Page>
-  </ItemGroup>
 </Project>

+ 28 - 10
libfisp/fisp.cs

@@ -76,7 +76,7 @@ namespace libfisp
         public DeleteTask DeleteFolder(string folderName)
         {
             var deleteTask = new DeleteTask();
-            Task.Run(() =>
+            Task.Run(async() =>
             {
                 try
                 {
@@ -89,18 +89,36 @@ namespace libfisp
                         var files = getResult.listBucket.contentsList.Select(x => x.key).ToArray();
                         for (var i = 0; i < files.Length; i++)
                         {
-                            var file = files[i];
-                            var deleteRequest = new DeleteObjectRequest(_bucket, file);
-                            var deleteResult = _cosXml.DeleteObject(deleteRequest);
-                            if (deleteResult.IsSuccessful())
+                            if (!isSuccess)
                             {
-                                deleteTask.UpdateProgress((i + 1) * 100 / files.Length);
+                                break;
                             }
-                            else
+                            var file = files[i];
+                            //腾讯云的SDK重试机制有问题,没有考虑熔断的问题,需要手动撰写重试delay。
+                            var retryTimes = 3;
+                            while (retryTimes > 0)
                             {
-                                deleteTask.UpdateFailed(deleteResult.GetResultInfo());
-                                isSuccess = false;
-                                break;
+                                var deleteRequest = new DeleteObjectRequest(_bucket, file);
+                                var deleteResult = _cosXml.DeleteObject(deleteRequest);
+                                if (deleteResult.IsSuccessful())
+                                {
+                                    deleteTask.UpdateProgress((i + 1) * 100 / files.Length);
+                                    break;
+                                }
+                                else
+                                {
+                                    retryTimes--;
+                                    if (retryTimes > 0)
+                                    {
+                                        //3秒后重试
+                                        await Task.Delay(3000);
+                                    }
+                                    else
+                                    {
+                                        deleteTask.UpdateFailed(deleteResult.GetResultInfo());
+                                        isSuccess = false;
+                                    }
+                                }
                             }
                         }
                         if (isSuccess)