@@ -18,6 +18,7 @@ interface RoutingRule {
1818 network ?: string ;
1919 outboundTag : string ;
2020 enabled : boolean ;
21+ visible ?: boolean ;
2122}
2223
2324interface DnsServer {
@@ -146,9 +147,9 @@ export class SettingsPageManager {
146147 await SettingsService . setModuleSetting ( "AUTO_START" , target . checked ) ;
147148 toast (
148149 I18nService . t ( "settings.module.toast_autostart" ) +
149- ( target . checked
150- ? I18nService . t ( "common.enabled" )
151- : I18nService . t ( "common.disabled" ) ) ,
150+ ( target . checked
151+ ? I18nService . t ( "common.enabled" )
152+ : I18nService . t ( "common.disabled" ) ) ,
152153 ) ;
153154 } catch ( error : any ) {
154155 toast ( I18nService . t ( "common.set_failed" ) + error . message , true ) ;
@@ -325,6 +326,8 @@ export class SettingsPageManager {
325326 }
326327
327328 this . routingRules . forEach ( ( rule , index ) => {
329+ if ( rule . visible === false ) return ;
330+
328331 const item = document . createElement ( "mdui-list-item" ) ;
329332 item . setAttribute ( "data-index" , String ( index ) ) ;
330333
@@ -369,7 +372,7 @@ export class SettingsPageManager {
369372 item . setAttribute (
370373 "headline" ,
371374 rule . name ||
372- `${ I18nService . t ( "settings.routing.rule_prefix" ) } ${ index + 1 } ` ,
375+ `${ I18nService . t ( "settings.routing.rule_prefix" ) } ${ index + 1 } ` ,
373376 ) ;
374377
375378 // 使用 description slot 显示详情和出站
@@ -462,9 +465,26 @@ export class SettingsPageManager {
462465 }
463466
464467 // 移动规则
465- async moveRule ( fromIndex , toIndex ) {
466- const [ movedRule ] = this . routingRules . splice ( fromIndex , 1 ) ;
467- this . routingRules . splice ( toIndex , 0 , movedRule ) ;
468+ async moveRule ( fromVisibleIndex : number , toVisibleIndex : number ) {
469+ // 找出所有可见规则及其在原数组中的索引
470+ const visibleIndices : number [ ] = [ ] ;
471+ this . routingRules . forEach ( ( rule , index ) => {
472+ if ( rule . visible !== false ) {
473+ visibleIndices . push ( index ) ;
474+ }
475+ } ) ;
476+
477+ if ( fromVisibleIndex >= visibleIndices . length || toVisibleIndex >= visibleIndices . length ) {
478+ return ;
479+ }
480+
481+ const fromRealIndex = visibleIndices [ fromVisibleIndex ] ;
482+ const toRealIndex = visibleIndices [ toVisibleIndex ] ;
483+
484+ // 执行移动操作
485+ const [ movedRule ] = this . routingRules . splice ( fromRealIndex , 1 ) ;
486+ this . routingRules . splice ( toRealIndex , 0 , movedRule ) ;
487+
468488 await this . saveRulesToBackend ( ) ;
469489 this . renderRoutingRules ( ) ;
470490 toast ( I18nService . t ( "routing.toast_reordered" ) ) ;
@@ -541,11 +561,14 @@ export class SettingsPageManager {
541561 network,
542562 outboundTag,
543563 enabled : true ,
564+ visible : true ,
544565 } ;
545566
546567 if ( this . editingRuleIndex >= 0 ) {
547- // 保留原有的 enabled 状态
548- rule . enabled = this . routingRules [ this . editingRuleIndex ] . enabled !== false ;
568+ // 保留原有的 enabled 和 visible 状态
569+ const oldRule = this . routingRules [ this . editingRuleIndex ] ;
570+ rule . enabled = oldRule . enabled !== false ;
571+ rule . visible = oldRule . visible !== false ;
549572 this . routingRules [ this . editingRuleIndex ] = rule ;
550573 } else {
551574 this . routingRules . push ( rule ) ;
@@ -969,15 +992,15 @@ export class SettingsPageManager {
969992
970993 const domains = domainsStr
971994 ? domainsStr
972- . split ( "," )
973- . map ( ( d ) => d . trim ( ) )
974- . filter ( ( d ) => d )
995+ . split ( "," )
996+ . map ( ( d ) => d . trim ( ) )
997+ . filter ( ( d ) => d )
975998 : [ ] ;
976999 const expectIPs = expectIPsStr
9771000 ? expectIPsStr
978- . split ( "," )
979- . map ( ( i ) => i . trim ( ) )
980- . filter ( ( i ) => i )
1001+ . split ( "," )
1002+ . map ( ( i ) => i . trim ( ) )
1003+ . filter ( ( i ) => i )
9811004 : [ ] ;
9821005
9831006 let server : string | DnsServer ;
@@ -1389,10 +1412,10 @@ export class SettingsPageManager {
13891412 const result = / ^ # ? ( [ a - f \d ] { 2 } ) ( [ a - f \d ] { 2 } ) ( [ a - f \d ] { 2 } ) $ / i. exec ( hex ) ;
13901413 return result
13911414 ? {
1392- r : parseInt ( result [ 1 ] , 16 ) ,
1393- g : parseInt ( result [ 2 ] , 16 ) ,
1394- b : parseInt ( result [ 3 ] , 16 ) ,
1395- }
1415+ r : parseInt ( result [ 1 ] , 16 ) ,
1416+ g : parseInt ( result [ 2 ] , 16 ) ,
1417+ b : parseInt ( result [ 3 ] , 16 ) ,
1418+ }
13961419 : { r : 103 , g : 80 , b : 164 } ; // 默认紫色
13971420 } ;
13981421
@@ -1591,9 +1614,9 @@ export class SettingsPageManager {
15911614 this . applyMonetSetting ( enabled ) ;
15921615 toast (
15931616 I18nService . t ( "settings.monet.toast_toggled" ) +
1594- ( enabled
1595- ? I18nService . t ( "common.enabled" )
1596- : I18nService . t ( "common.disabled" ) ) ,
1617+ ( enabled
1618+ ? I18nService . t ( "common.enabled" )
1619+ : I18nService . t ( "common.disabled" ) ) ,
15971620 ) ;
15981621 } ) ;
15991622 }
0 commit comments