@@ -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 ]
0 commit comments