Skip to content

Commit e64fa1f

Browse files
committed
Refactor the packaging functionality
1 parent 900dfbe commit e64fa1f

5 files changed

Lines changed: 73 additions & 217 deletions

File tree

src/App.axaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
x:Class="GeneralUpdate.Tool.Avalonia.App"
44
xmlns:local="using:GeneralUpdate.Tool.Avalonia"
55
xmlns:semi="https://irihi.tech/semi"
6+
xmlns:u-semi="https://irihi.tech/ursa/themes/semi"
67
RequestedThemeVariant="Default">
78
<Application.Resources>
89
<ResourceDictionary>
@@ -12,7 +13,7 @@
1213
</ResourceDictionary>
1314
</Application.Resources>
1415
<Application.Styles>
15-
<FluentTheme />
16-
<semi:SemiTheme />
16+
<semi:SemiTheme Locale="en" />
17+
<u-semi:SemiTheme Locale="en"/>
1718
</Application.Styles>
1819
</Application>

src/GeneralUpdate.Tool.Avalonia.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.2.0.1" />
2424
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
2525
<PackageReference Include="GeneralUpdate.Core" Version="10.2.1" />
26+
<PackageReference Include="Irihi.Ursa.Themes.Semi" Version="1.13.0" />
2627
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
2728
<PackageReference Include="Nlnet.Avalonia.MessageBox" Version="1.0.2" />
28-
<PackageReference Include="Semi.Avalonia" Version="11.2.1.4" />
29+
<PackageReference Include="Semi.Avalonia" Version="11.2.1.10" />
2930
</ItemGroup>
3031
</Project>

src/Models/PacketConfigModel.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,25 @@ namespace GeneralUpdate.Tool.Avalonia.Models;
44

55
public class PacketConfigModel : ObservableObject
66
{
7+
private string _serverAddress;
78
private string _appDirectory, _releaseDirectory, _patchDirectory, _name, _path, _driverDirectory;
89
private string _reportUrl, _updateUrl, _appName, _mainAppName, _clientVersion;
910
private PlatformModel _platform;
1011
private FormatModel _format;
1112
private EncodingModel _encoding;
13+
14+
public string ServerAddress
15+
{
16+
get => _serverAddress;
17+
set
18+
{
19+
_serverAddress = value;
20+
OnPropertyChanged(nameof(ServerAddress));
21+
22+
ReportUrl = $"{_serverAddress}/report";
23+
UpdateUrl = $"{_serverAddress}/update";
24+
}
25+
}
1226

1327
/// <summary>
1428
/// 压缩包格式

src/ViewModels/PacketViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ private void LoadedAction()
9393

9494
private void ResetAction()
9595
{
96-
ConfigModel.Name = GenerateFileName("1.0.0.0");
96+
ConfigModel.Name = GenerateFileName();
9797
ConfigModel.ReleaseDirectory = GetPlatformSpecificPath();
9898
ConfigModel.AppDirectory = GetPlatformSpecificPath();
9999
ConfigModel.PatchDirectory = GetPlatformSpecificPath();
@@ -232,10 +232,10 @@ private string GetPlatformSpecificPath()
232232
throw new PlatformNotSupportedException("Unsupported OS");
233233
}
234234

235-
private string GenerateFileName(string version)
235+
private string GenerateFileName()
236236
{
237-
string timestamp = DateTime.Now.ToString("yyyyMMddHHmmssfff");
238-
return $"packet_{timestamp}_{version}";
237+
var timestamp = DateTime.Now.ToString("yyyyMMddHHmmssfff");
238+
return $"packet_{timestamp}";
239239
}
240240

241241
private void DeleteDirectoryRecursively(string targetDir)

src/Views/PacketView.axaml

Lines changed: 50 additions & 210 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
77
xmlns:ia="clr-namespace:Avalonia.Xaml.Interactions.Core;assembly=Avalonia.Xaml.Interactions"
88
xmlns:vm="clr-namespace:GeneralUpdate.Tool.Avalonia.ViewModels"
9+
xmlns:u="https://irihi.tech/ursa"
910
x:Class="GeneralUpdate.Tool.Avalonia.Views.PacketView" x:DataType="vm:PacketViewModel">
1011
<i:Interaction.Behaviors>
1112
<ia:EventTriggerBehavior EventName="Loaded">
@@ -16,216 +17,55 @@
1617
<ScrollViewer>
1718
<StackPanel Margin="10">
1819
<!-- Required Fields Section -->
19-
<TextBlock
20-
Text="Required Fields"
21-
FontWeight="Bold"
22-
FontSize="14"
23-
Margin="0,5,0,5" />
24-
<Separator Margin="0,0,0,10" />
25-
26-
<Grid ColumnDefinitions="1*,4*,1*" RowDefinitions="Auto,Auto,Auto,Auto,Auto">
27-
<!-- UpdateUrl (Required) -->
28-
<TextBlock
29-
HorizontalAlignment="Right"
30-
VerticalAlignment="Center"
31-
Text="UpdateUrl*" />
32-
<TextBox
33-
Grid.Column="1"
34-
Margin="5"
35-
Text="{Binding ConfigModel.UpdateUrl}" />
36-
37-
<!-- ReportUrl (Required) -->
38-
<TextBlock
39-
Grid.Row="1"
40-
HorizontalAlignment="Right"
41-
VerticalAlignment="Center"
42-
Text="ReportUrl*" />
43-
<TextBox
44-
Grid.Row="1"
45-
Grid.Column="1"
46-
Margin="5"
47-
Text="{Binding ConfigModel.ReportUrl}" />
48-
49-
<!-- AppDirectory (Required) -->
50-
<TextBlock
51-
Grid.Row="2"
52-
HorizontalAlignment="Right"
53-
VerticalAlignment="Center"
54-
Text="AppDirectory*" />
55-
<TextBox
56-
Grid.Row="2"
57-
Grid.Column="1"
58-
Margin="5"
59-
Text="{Binding ConfigModel.AppDirectory}" />
60-
<Button
61-
Grid.Row="2"
62-
Grid.Column="2"
63-
Margin="5"
64-
Classes="Primary"
65-
Command="{Binding SelectFolderCommand}"
66-
CommandParameter="App" Content="Pick"
67-
Theme="{DynamicResource SolidButton}" >
68-
</Button>
69-
70-
<!-- ReleaseDirectory (Required) -->
71-
<TextBlock
72-
Grid.Row="3"
73-
HorizontalAlignment="Right"
74-
VerticalAlignment="Center"
75-
Text="ReleaseDirectory*" />
76-
<TextBox
77-
Grid.Row="3"
78-
Grid.Column="1"
79-
Margin="5"
80-
Text="{Binding ConfigModel.ReleaseDirectory}" />
81-
<Button
82-
Grid.Row="3"
83-
Grid.Column="2"
84-
Margin="5"
85-
Classes="Primary"
86-
Command="{Binding SelectFolderCommand}"
87-
CommandParameter="Release" Content="Pick"
88-
Theme="{DynamicResource SolidButton}">
89-
</Button>
90-
91-
<!-- PatchDirectory (Required) -->
92-
<TextBlock
93-
Grid.Row="4"
94-
HorizontalAlignment="Right"
95-
VerticalAlignment="Center"
96-
Text="PatchDirectory*" />
97-
<TextBox
98-
Grid.Row="4"
99-
Grid.Column="1"
100-
Margin="5"
101-
Text="{Binding ConfigModel.PatchDirectory}" />
102-
<Button
103-
Grid.Row="4"
104-
Grid.Column="2"
105-
Margin="5"
106-
Classes="Primary"
107-
Command="{Binding SelectFolderCommand}"
108-
CommandParameter="Patch" Content="Pick"
109-
Theme="{DynamicResource SolidButton}">
110-
</Button>
111-
</Grid>
112-
113-
<!-- Optional Fields Section -->
114-
<TextBlock
115-
Text="Optional Fields"
116-
FontWeight="Bold"
117-
FontSize="14"
118-
Margin="0,15,0,5" />
119-
<Separator Margin="0,0,0,10" />
120-
121-
<Grid ColumnDefinitions="1*,4*,1*" RowDefinitions="Auto">
122-
<!-- DriverDirectory (Optional) -->
123-
<TextBlock
124-
HorizontalAlignment="Right"
125-
VerticalAlignment="Center"
126-
Text="DriverDirectory" />
127-
<TextBox
128-
Grid.Column="1"
129-
Margin="5"
130-
Text="{Binding ConfigModel.DriverDirectory, Mode=TwoWay}" />
131-
<Button
132-
Grid.Column="2"
133-
Margin="5"
134-
Classes="Primary"
135-
Command="{Binding SelectFolderCommand}"
136-
CommandParameter="Driver" Content="Pick"
137-
Theme="{DynamicResource SolidButton}">
138-
</Button>
139-
</Grid>
20+
<u:Divider Content="Required Fields"/>
21+
<u:Form LabelPosition="Left" LabelWidth="*" Margin="10">
22+
<StackPanel Orientation="Horizontal" u:FormItem.IsRequired="True" u:FormItem.Label="ServerAddress">
23+
<TextBox Width="400" Text="{Binding ConfigModel.ServerAddress}" />
24+
</StackPanel>
25+
<StackPanel Orientation="Horizontal" u:FormItem.IsRequired="True" u:FormItem.Label="AppDirectory" >
26+
<TextBox Width="400" Text="{Binding ConfigModel.AppDirectory}"/>
27+
<Button Margin="5,0,0,0"
28+
Classes="Primary"
29+
Command="{Binding SelectFolderCommand}"
30+
CommandParameter="App"
31+
Content="Pick"
32+
Theme="{DynamicResource SolidButton}" >
33+
</Button>
34+
</StackPanel>
35+
<StackPanel Orientation="Horizontal" u:FormItem.IsRequired="True" u:FormItem.Label="ReleaseDirectory" >
36+
<TextBox Width="400" Text="{Binding ConfigModel.ReleaseDirectory}" />
37+
<Button Margin="5,0,0,0"
38+
Classes="Primary"
39+
Command="{Binding SelectFolderCommand}"
40+
CommandParameter="Release"
41+
Content="Pick"
42+
Theme="{DynamicResource SolidButton}">
43+
</Button>
44+
</StackPanel>
45+
</u:Form>
14046

14147
<!-- Auto-generated Fields Section -->
142-
<TextBlock
143-
Text="Auto-generated Fields"
144-
FontWeight="Bold"
145-
FontSize="14"
146-
Margin="0,15,0,5" />
147-
<Separator Margin="0,0,0,10" />
148-
149-
<Grid ColumnDefinitions="1*,4*,1*" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto">
150-
<!-- AppName (Auto-generated) -->
151-
<TextBlock
152-
HorizontalAlignment="Right"
153-
VerticalAlignment="Center"
154-
Text="AppName" />
155-
<TextBox
156-
Grid.Column="1"
157-
Margin="5"
158-
IsReadOnly="True"
159-
Text="{Binding ConfigModel.AppName, Mode=OneWay}" />
160-
161-
<!-- MainAppName (Auto-generated) -->
162-
<TextBlock
163-
Grid.Row="1"
164-
HorizontalAlignment="Right"
165-
VerticalAlignment="Center"
166-
Text="MainAppName" />
167-
<TextBox
168-
Grid.Row="1"
169-
Grid.Column="1"
170-
Margin="5"
171-
IsReadOnly="True"
172-
Text="{Binding ConfigModel.MainAppName, Mode=OneWay}" />
173-
174-
<!-- ClientVersion (Auto-generated) -->
175-
<TextBlock
176-
Grid.Row="2"
177-
HorizontalAlignment="Right"
178-
VerticalAlignment="Center"
179-
Text="ClientVersion" />
180-
<TextBox
181-
Grid.Row="2"
182-
Grid.Column="1"
183-
Margin="5"
184-
IsReadOnly="True"
185-
Text="{Binding ConfigModel.ClientVersion, Mode=OneWay}" />
186-
187-
<!-- PacketName (Auto-generated) -->
188-
<TextBlock
189-
Grid.Row="3"
190-
HorizontalAlignment="Right"
191-
VerticalAlignment="Center"
192-
Text="PacketName" />
193-
<TextBox
194-
Grid.Row="3"
195-
Grid.Column="1"
196-
Margin="5"
197-
IsReadOnly="True"
198-
Text="{Binding ConfigModel.Name, Mode=OneWay}" />
199-
200-
<!-- Format (Auto-generated) -->
201-
<TextBlock
202-
Grid.Row="4"
203-
HorizontalAlignment="Right"
204-
VerticalAlignment="Center"
205-
Text="Format" />
206-
<ComboBox
207-
Grid.Row="4"
208-
Grid.Column="1"
209-
MinWidth="150"
210-
Margin="5"
211-
ItemsSource="{Binding Formats}"
212-
SelectedItem="{Binding ConfigModel.Format}" />
213-
214-
<!-- Encoding (Auto-generated) -->
215-
<TextBlock
216-
Grid.Row="5"
217-
HorizontalAlignment="Right"
218-
VerticalAlignment="Center"
219-
Text="Encoding" />
220-
<ComboBox
221-
Grid.Row="5"
222-
Grid.Column="1"
223-
MinWidth="150"
224-
Margin="5"
225-
ItemsSource="{Binding Encodings}"
226-
SelectedIndex="0"
227-
SelectedItem="{Binding ConfigModel.Encoding}" />
228-
</Grid>
48+
<u:Divider Content="Auto-generated Fields"/>
49+
<u:Form LabelPosition="Left" LabelWidth="*" Margin="10">
50+
<TextBox Width="400" u:FormItem.Label="UpdateUrl" Text="{Binding ConfigModel.UpdateUrl}" />
51+
<TextBox Width="400" u:FormItem.Label="ReportUrl" Text="{Binding ConfigModel.ReportUrl}"/>
52+
<TextBox Width="400" u:FormItem.Label="AppName" Text="{Binding ConfigModel.AppName, Mode=OneWay}" />
53+
<TextBox Width="400" u:FormItem.Label="MainAppName" Text="{Binding ConfigModel.MainAppName, Mode=OneWay}" />
54+
<TextBox Width="400" u:FormItem.Label="ClientVersion" Text="{Binding ConfigModel.ClientVersion, Mode=OneWay}" />
55+
<TextBox Width="400" u:FormItem.Label="PacketName" Text="{Binding ConfigModel.Name, Mode=OneWay}" />
56+
<ComboBox u:FormItem.Label="Format" Width="400" ItemsSource="{Binding Formats}" SelectedItem="{Binding ConfigModel.Format}" />
57+
<ComboBox u:FormItem.Label="Encoding" Width="400" ItemsSource="{Binding Encodings}" SelectedIndex="0" SelectedItem="{Binding ConfigModel.Encoding}" />
58+
<StackPanel Orientation="Horizontal" u:FormItem.Label="PatchDirectory">
59+
<TextBox Width="400" Text="{Binding ConfigModel.PatchDirectory}" />
60+
<Button Margin="5,0,0,0"
61+
Classes="Primary"
62+
Command="{Binding SelectFolderCommand}"
63+
CommandParameter="Patch"
64+
Content="Pick"
65+
Theme="{DynamicResource SolidButton}">
66+
</Button>
67+
</StackPanel>
68+
</u:Form>
22969
</StackPanel>
23070
</ScrollViewer>
23171
<StackPanel
@@ -235,11 +75,11 @@
23575
VerticalAlignment="Center"
23676
Orientation="Horizontal"
23777
Spacing="10">
238-
<Button
78+
<u:IconButton
23979
Classes="Primary"
24080
Command="{Binding BuildCommand}"
24181
Theme="{DynamicResource SolidButton}" Content="Build">
242-
</Button>
82+
</u:IconButton>
24383
<Button
24484
Classes="Primary"
24585
Command="{Binding ClearCommand}"

0 commit comments

Comments
 (0)