Skip to content

Commit 46ffc99

Browse files
committed
Automated dotnet-format update
1 parent 3783db1 commit 46ffc99

File tree

9 files changed

+47
-70
lines changed

9 files changed

+47
-70
lines changed

cat2/Models/Items.cs

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ bool isStarted
1717
[ObservableProperty] private bool _isStartedEnabled = true;
1818
[ObservableProperty] private string _name = tunnelInfo.name;
1919

20-
[ObservableProperty]
21-
private string _toolTip =
20+
[ObservableProperty] private string _toolTip =
2221
$"[内网端口:{tunnelInfo.nport}]-[外网端口/连接域名:{tunnelInfo.dorp}]-[节点状态:{tunnelInfo.nodestate}]";
2322

2423
[RelayCommand]
@@ -27,9 +26,21 @@ public void TunnelClick()
2726
IsStartedEnabled = false;
2827
if (IsStarted)
2928
StartTunnelFromId(
30-
tunnelInfo.id,
29+
tunnelInfo.id,
3130
() =>
31+
{
32+
Application.Current.Dispatcher.Invoke(() =>
3233
{
34+
ShowSnackbar(
35+
"隧道已在运行",
36+
$"隧道 {tunnelInfo.name} 已在运行中。",
37+
ControlAppearance.Danger,
38+
SymbolRegular.Warning24);
39+
IsStartedEnabled = true;
40+
});
41+
}, isStart =>
42+
{
43+
if (isStart)
3344
Application.Current.Dispatcher.Invoke(() =>
3445
{
3546
ShowSnackbar("隧道启动成功",
@@ -39,9 +50,7 @@ public void TunnelClick()
3950
IsStartedEnabled = true;
4051
Clipboard.SetDataObject($"{tunnelInfo.ip}:{tunnelInfo.dorp}");
4152
});
42-
},
43-
() =>
44-
{
53+
else
4554
Application.Current.Dispatcher.Invoke(() =>
4655
{
4756
ShowSnackbar("隧道启动失败",
@@ -51,25 +60,11 @@ public void TunnelClick()
5160
IsStarted = false;
5261
IsStartedEnabled = true;
5362
});
54-
},
55-
() =>
56-
{
57-
Application.Current.Dispatcher.Invoke(() =>
58-
{
59-
ShowSnackbar(
60-
"隧道已在运行",
61-
$"隧道 {tunnelInfo.name} 已在运行中。",
62-
ControlAppearance.Danger,
63-
SymbolRegular.Warning24);
64-
IsStartedEnabled = true;
65-
});
66-
}
67-
);
63+
});
6864
else
6965
StopTunnelFromId(
7066
tunnelInfo.id,
71-
() => { Application.Current.Dispatcher.Invoke(() => { IsStartedEnabled = true; }); },
72-
() => { Application.Current.Dispatcher.Invoke(() => { IsStartedEnabled = true; }); });
67+
_ => { Application.Current.Dispatcher.Invoke(() => { IsStartedEnabled = true; }); });
7368
}
7469

7570
[RelayCommand]
@@ -148,8 +143,7 @@ NodeInfoClass nodeInfo
148143
[ObservableProperty] private string _id = $"#{nodeInfo.id}";
149144
[ObservableProperty] private float _load15 = nodeInfo.load15 * 100;
150145

151-
[ObservableProperty]
152-
private string _name =
146+
[ObservableProperty] private string _name =
153147
$"{nodeInfo.name}({(nodeInfo.nodegroup == "vip" ? "VIP" : "普通")},{(nodeInfo.state == "online" ? "在线" : "离线")})";
154148

155149
[ObservableProperty]

cat2/ViewModels/Pages/NodePageViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public async void Loaded(object sender, RoutedEventArgs e)
2020
private async Task Loaded()
2121
{
2222
IsLoadedEnabled = false;
23-
23+
2424
var nodesData = await NodeActions.GetNodesDataListAsync();
2525
ListDataContext.Clear();
2626
await Task.WhenAll(nodesData.Select(async nodeData =>

cat2/ViewModels/Pages/TunnelPageViewModel.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private async Task Loaded()
5757

5858
var runningTunnels = await IsTunnelRunningAsync(tunnelsData);
5959
var settings = JsonNode.Parse(await File.ReadAllTextAsync(SettingsFilePath))?["StartedItems"];
60-
60+
6161
var existingItems = ListDataContext.ToDictionary(item => item.Id);
6262

6363
await Task.WhenAll(tunnelsData.Select(tunnel =>
@@ -78,27 +78,27 @@ await Task.WhenAll(tunnelsData.Select(tunnel =>
7878
else
7979
{
8080
var newItem = new TunnelItem(this, tunnel, isRunning);
81-
if (!isRunning &&
81+
if (!isRunning &&
8282
settings?[$"{tunnel.name}({tunnel.type.ToUpperInvariant()})"] is JsonValue value &&
83-
value.TryGetValue<bool>(out var isStarted) &&
83+
value.TryGetValue<bool>(out var isStarted) &&
8484
isStarted)
8585
{
8686
newItem.IsStarted = true;
8787
newItem.TunnelClick();
8888
}
89-
89+
9090
ListDataContext.Add(newItem);
9191
}
9292

9393
return Task.CompletedTask;
9494
}));
95-
95+
9696
var validIds = new HashSet<string>(tunnelsData.Select(t => $"[隧道ID:{t.id}]"));
9797
foreach (var item in ListDataContext
9898
.Where(item => !validIds.Contains(item.Id))
9999
.ToList())
100100
ListDataContext.Remove(item);
101-
101+
102102
IsLoadedEnabled = true;
103103
}
104104
}

cat2/ViewModels/Pages/UserPageViewModel.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,23 @@ namespace CAT2.ViewModels;
55

66
public partial class UserPageViewModel : ObservableObject
77
{
8+
[ObservableProperty] private string _bandwidth;
89
[ObservableProperty] private BitmapImage _currentImage;
910
[ObservableProperty] private string _email;
11+
12+
private bool _first = true;
13+
[ObservableProperty] private string _integral;
14+
[ObservableProperty] private bool _isLoadedEnabled;
1015
[ObservableProperty] private string _name;
11-
[ObservableProperty] private string _usergroup;
1216
[ObservableProperty] private string _qq;
13-
[ObservableProperty] private string _integral;
14-
[ObservableProperty] private string _bandwidth;
1517
[ObservableProperty] private string _tunnelCount;
16-
[ObservableProperty] private bool _isLoadedEnabled;
18+
[ObservableProperty] private string _usergroup;
1719

1820
public async void Loaded(object sender, RoutedEventArgs e)
1921
{
2022
await Loaded();
2123
}
2224

23-
private bool _first = true;
2425
[RelayCommand]
2526
private async Task Loaded()
2627
{
@@ -45,7 +46,7 @@ private async Task Loaded()
4546
Bandwidth = $"带宽限制:国内{UserInfo.bandwidth}m | 国外{UserInfo.bandwidth * 4}m";
4647
IsLoadedEnabled = true;
4748
}
48-
49+
4950
[RelayCommand]
5051
private static async Task OnSignOut()
5152
{

cat2/Views/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
NavigationCacheMode="Required"
7373
Icon="{ui:SymbolIcon AppsListDetail24}"
7474
TargetPageType="{x:Type pages:NodePage}" />
75-
75+
7676
<ui:NavigationViewItem
7777
Content="用户信息"
7878
Name="UserItem"

cat2/Views/Pages/NodePage.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
<RowDefinition
1616
Height="*" />
1717
</Grid.RowDefinitions>
18-
18+
1919
<ui:CardControl
2020
Margin="5">
2121
<ui:CardControl.Header>
2222
<ui:TextBlock
2323
FontTypography="Title"
24-
Text="节点列表"/>
24+
Text="节点列表" />
2525
</ui:CardControl.Header>
2626
<StackPanel
2727
Orientation="Horizontal"

cat2/Views/Pages/SettingPage.xaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
VerticalAlignment="Center"
104104
Text="{Binding Name}"
105105
HorizontalAlignment="Left" />
106-
107106
<CheckBox
108107
HorizontalAlignment="Right"
109108
IsChecked="{Binding IsStarted}" />
@@ -125,7 +124,6 @@
125124
<StackPanel
126125
Orientation="Horizontal"
127126
VerticalAlignment="Center">
128-
129127
<ui:ImageIcon
130128
Height="30"
131129
Margin="10,0,10,0"
@@ -140,7 +138,6 @@
140138
Text="{Binding Copyright}"
141139
FontSize="14" />
142140
</ui:TextBlock>
143-
144141
</StackPanel>
145142

146143
<Label
@@ -152,15 +149,14 @@
152149
</Grid>
153150
</ui:CardExpander.Header>
154151

155-
<StackPanel
156-
Orientation="Vertical">
152+
<StackPanel>
157153
<TextBlock
154+
Margin="0,0,0,8"
158155
TextWrapping="WrapWithOverflow"
159156
Text="我是Qusay,目前是一名初中生,正在编写此应用程序。QQ:2976779544" />
160157

161158
<StackPanel
162159
Orientation="Horizontal">
163-
164160
<ui:HyperlinkButton
165161
Icon="{ui:SymbolIcon Link48}"
166162
Content="查看作者BiliBili首页"

cat2/Views/Pages/TunnelPage.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
VerticalAlignment="Top">
1515
<Grid.RowDefinitions>
1616
<RowDefinition />
17-
<RowDefinition />
17+
<RowDefinition />
1818
</Grid.RowDefinitions>
1919

2020
<ui:CardControl
2121
Margin="5">
2222
<ui:CardControl.Header>
2323
<ui:TextBlock
2424
FontTypography="Title"
25-
Text="隧道列表"/>
25+
Text="隧道列表" />
2626
</ui:CardControl.Header>
2727
<StackPanel
2828
Orientation="Horizontal"

cat2/Views/Pages/UserPage.xaml

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,8 @@
1414
VerticalAlignment="Center"
1515
HorizontalAlignment="Stretch">
1616
<ui:CardControl.Header>
17-
<StackPanel
18-
HorizontalAlignment="Left"
19-
VerticalAlignment="Center"
20-
Margin="45,0,0,0"
21-
Orientation="Vertical">
17+
<StackPanel>
2218
<ui:Image
23-
VerticalContentAlignment="Center"
2419
Width="200" Height="200"
2520
Source="{Binding CurrentImage}"
2621
CornerRadius="100"
@@ -29,49 +24,40 @@
2924
<DropShadowEffect BlurRadius="10" Opacity="0.1" ShadowDepth="2" />
3025
</ui:Image.Effect>
3126
</ui:Image>
32-
3327
<ui:TextBlock
3428
Text="{Binding Name}"
3529
FontTypography="Title"
3630
HorizontalAlignment="Center"
3731
Margin="0,25,0,0" />
3832
</StackPanel>
39-
4033
</ui:CardControl.Header>
4134

42-
<StackPanel
43-
Margin="20,10,20,30"
44-
VerticalAlignment="Top">
35+
<StackPanel>
36+
<ui:CardControl
37+
Padding="8,8,10,8"
38+
Header="{Binding Bandwidth}"
39+
Icon="{ui:SymbolIcon TextGrammarArrowLeft24}" />
4540
<ui:CardControl
4641
Padding="8,8,10,8"
4742
Header="{Binding Email}"
4843
Icon="{ui:SymbolIcon Mail48}" />
49-
5044
<ui:CardControl
5145
Padding="8,8,10,8"
5246
Header="{Binding Qq}"
5347
Icon="{ui:SymbolIcon QrCode28}" />
54-
5548
<ui:CardControl
5649
Padding="8,8,10,8"
5750
Header="{Binding Usergroup}"
5851
Icon="{ui:SymbolIcon ContactCard48}" />
59-
6052
<ui:CardControl
6153
Padding="8,8,10,8"
6254
Header="{Binding TunnelCount}"
6355
Icon="{ui:SymbolIcon TextGrammarArrowRight24}" />
64-
6556
<ui:CardControl
6657
Padding="8,8,10,8"
6758
Header="{Binding Integral}"
6859
Icon="{ui:SymbolIcon BoxMultiple24}" />
6960

70-
<ui:CardControl
71-
Padding="8,8,10,8"
72-
Header="{Binding Bandwidth}"
73-
Icon="{ui:SymbolIcon TextGrammarArrowLeft24}" />
74-
7561
<StackPanel
7662
Margin="0,20,0,0"
7763
Orientation="Horizontal">
@@ -82,14 +68,14 @@
8268
Padding="20,8"
8369
Margin="0,0,8,0"
8470
IsEnabled="{Binding IsLoadedEnabled}"
85-
Command="{Binding LoadedCommand}"/>
71+
Command="{Binding LoadedCommand}" />
8672
<ui:Button
8773
Appearance="Primary"
8874
Icon="{ui:SymbolIcon ArrowCircleUpLeft24}"
8975
Content="退出登录"
9076
HorizontalAlignment="Center"
9177
Padding="20,8"
92-
Command="{Binding SignOutCommand}"/>
78+
Command="{Binding SignOutCommand}" />
9379
</StackPanel>
9480
</StackPanel>
9581
</ui:CardControl>

0 commit comments

Comments
 (0)