@@ -1787,6 +1787,9 @@ <h2 data-i18n="summary">切换摘要</h2>
17871787 incomeLayerOn : "开启,起始 {start},最高 {ratio}" ,
17881788 optionOverlayOff : "关闭" ,
17891789 optionOverlayOn : "开启(策略默认)" ,
1790+ optionOverlayDefaultSimple : "策略默认:开启" ,
1791+ optionOverlayDefault : "策略默认:开启,{detail}" ,
1792+ cashOnlyExecutionDefault : "平台默认:允许融资" ,
17901793 } ,
17911794 en : {
17921795 appTitle : "Strategy Switch" ,
@@ -1950,6 +1953,9 @@ <h2 data-i18n="summary">切换摘要</h2>
19501953 incomeLayerOn : "Enabled, starts at {start}, max {ratio}" ,
19511954 optionOverlayOff : "Disabled" ,
19521955 optionOverlayOn : "Enabled (strategy default)" ,
1956+ optionOverlayDefaultSimple : "Strategy default: enabled" ,
1957+ optionOverlayDefault : "Strategy default: enabled, {detail}" ,
1958+ cashOnlyExecutionDefault : "Platform default: margin allowed" ,
19531959 } ,
19541960 } ;
19551961
@@ -2468,22 +2474,68 @@ <h2 data-i18n="summary">切换摘要</h2>
24682474 return enabled ? t ( "cashOnlyExecutionValueNo" ) : t ( "cashOnlyExecutionValueYes" ) ;
24692475 }
24702476
2477+ function platformCashOnlyExecutionDefault ( ) {
2478+ return false ;
2479+ }
2480+
2481+ function effectiveCashOnlyExecutionForAccount ( platform , account ) {
2482+ const configured = currentCashOnlyExecutionForAccount ( platform , account ) ;
2483+ if ( configured !== null ) return configured ;
2484+ if ( ! platformSupportsMarginPolicy ( platform ) ) return null ;
2485+ return platformCashOnlyExecutionDefault ( ) ;
2486+ }
2487+
24712488 function currentCashOnlyExecutionForAccount ( platform , account ) {
24722489 return cleanOptionalBoolean ( currentEntryForAccount ( platform , account ) ?. cash_only_execution ) ;
24732490 }
24742491
24752492 function currentCashOnlyExecutionText ( platform = state . selected , account = selectedAccount ( platform ) ) {
2476- return cashOnlyExecutionText ( currentCashOnlyExecutionForAccount ( platform , account ) ) ;
2493+ if ( ! platformSupportsMarginPolicy ( platform ) ) return t ( "notRead" ) ;
2494+ const entry = currentEntryForAccount ( platform , account ) ;
2495+ if ( ! entry ) return t ( "notRead" ) ;
2496+ const configured = cleanOptionalBoolean ( entry . cash_only_execution ) ;
2497+ if ( configured === null ) return t ( "cashOnlyExecutionDefault" ) ;
2498+ return cashOnlyExecutionText ( configured ) ;
24772499 }
24782500
24792501 function currentOptionOverlayForAccount ( platform , account ) {
24802502 return cleanOptionalBoolean ( currentEntryForAccount ( platform , account ) ?. option_overlay_enabled ) ;
24812503 }
24822504
2505+ function effectiveOptionOverlayForAccount ( platform , account , profile = state . forms [ platform ] ?. strategy ) {
2506+ const configured = currentOptionOverlayForAccount ( platform , account ) ;
2507+ if ( configured !== null ) return configured ;
2508+ if ( ! optionOverlaySupported ( profile ) ) return null ;
2509+ return true ;
2510+ }
2511+
2512+ function optionOverlayDefaultSummaryDetail ( defaults ) {
2513+ if ( ! defaults ?. families ?. length ) return "" ;
2514+ return defaults . families . map ( ( item ) => {
2515+ const family = item . family === "income" ? t ( "optionOverlayFamilyIncome" ) : t ( "optionOverlayFamilyGrowth" ) ;
2516+ const ratioText = item . ratioKind === "risk"
2517+ ? t ( "optionOverlayRiskRatio" ) . replace ( "{ratio}" , formatRatioPercent ( item . ratio ) )
2518+ : t ( "optionOverlayBudgetRatio" ) . replace ( "{ratio}" , formatRatioPercent ( item . ratio ) ) ;
2519+ return `${ family } ${ ratioText } ` ;
2520+ } ) . join ( " / " ) ;
2521+ }
2522+
2523+ function optionOverlayDefaultText ( profile ) {
2524+ const defaults = optionOverlayDefaultForStrategy ( profile ) ;
2525+ if ( ! defaults ) return t ( "optionOverlayNotSupported" ) ;
2526+ const detail = optionOverlayDefaultSummaryDetail ( defaults ) ;
2527+ return detail ? t ( "optionOverlayDefault" ) . replace ( "{detail}" , detail ) : t ( "optionOverlayDefaultSimple" ) ;
2528+ }
2529+
24832530 function currentOptionOverlayText ( platform = state . selected , account = selectedAccount ( platform ) , profile = state . forms [ platform ] ?. strategy ) {
2484- const enabled = currentOptionOverlayForAccount ( platform , account ) ;
2485- if ( ! optionOverlaySupported ( profile ) && enabled === null ) return t ( "optionOverlayNotSupported" ) ;
2486- return enabled === null ? t ( "notRead" ) : optionOverlayText ( enabled ) ;
2531+ const entry = currentEntryForAccount ( platform , account ) ;
2532+ if ( ! entry ) return t ( "notRead" ) ;
2533+ const configured = cleanOptionalBoolean ( entry . option_overlay_enabled ) ;
2534+ if ( ! optionOverlaySupported ( profile ) ) {
2535+ return configured === null ? t ( "optionOverlayNotSupported" ) : optionOverlayText ( configured ) ;
2536+ }
2537+ if ( configured === null ) return optionOverlayDefaultText ( profile ) ;
2538+ return optionOverlayText ( configured ) ;
24872539 }
24882540
24892541 function currentIncomeLayerForAccount ( platform , account ) {
@@ -3234,12 +3286,12 @@ <h2 data-i18n="summary">切换摘要</h2>
32343286 const profile = cleanStrategyProfile ( inputs . strategy_profile || state . forms [ platform ] ?. strategy ) ;
32353287 const supported = optionOverlaySupported ( profile ) ;
32363288 const mode = normalizeOptionOverlayMode ( inputs . option_overlay_mode ) ;
3237- const current = currentOptionOverlayForAccount ( platform , account ) ;
3289+ const current = effectiveOptionOverlayForAccount ( platform , account , profile ) ;
32383290 if ( mode === "current" ) {
32393291 return {
32403292 supported,
32413293 changed : false ,
3242- inputs : { option_overlay_enabled : current } ,
3294+ inputs : { option_overlay_enabled : currentOptionOverlayForAccount ( platform , account ) } ,
32433295 } ;
32443296 }
32453297 if ( mode === "enabled" ) {
@@ -3258,11 +3310,11 @@ <h2 data-i18n="summary">切换摘要</h2>
32583310
32593311 function pendingCashOnlyExecution ( inputs , platform = state . selected , account = selectedAccount ( platform ) ) {
32603312 const mode = normalizeCashOnlyExecutionMode ( inputs . cash_only_execution_mode ) ;
3261- const current = currentCashOnlyExecutionForAccount ( platform , account ) ;
3313+ const current = effectiveCashOnlyExecutionForAccount ( platform , account ) ;
32623314 if ( mode === "current" ) {
32633315 return {
32643316 changed : false ,
3265- inputs : { cash_only_execution : current } ,
3317+ inputs : { cash_only_execution : currentCashOnlyExecutionForAccount ( platform , account ) } ,
32663318 } ;
32673319 }
32683320 const nextEnabled = mode === "enabled" ;
@@ -3413,8 +3465,10 @@ <h2 data-i18n="summary">切换摘要</h2>
34133465 ] ,
34143466 [ t ( "currentPluginMode" ) , pluginModeLabel ( changes . currentPluginMode ) ] ,
34153467 [ t ( "reservedCashPolicy" ) , currentReservedCashPolicyText ( state . selected , account ) ] ,
3416- [ t ( "currentCashOnlyExecution" ) , currentCashOnlyExecutionText ( state . selected , account ) ] ,
34173468 ] ;
3469+ if ( platformSupportsMarginPolicy ( state . selected ) ) {
3470+ rows . push ( [ t ( "currentCashOnlyExecution" ) , currentCashOnlyExecutionText ( state . selected , account ) ] ) ;
3471+ }
34183472 if ( incomeLayerSupported ( inputs . strategy_profile ) ) {
34193473 rows . push ( [ t ( "currentIncomeLayer" ) , currentIncomeLayerText ( state . selected , account , inputs . strategy_profile ) ] ) ;
34203474 }
0 commit comments