11import { t } from "@cs/locale"
22import { useRequest } from "@hooks/useRequest"
33import Flex from "@pages/components/Flex"
4- import { meetLimit , meetTimeLimit , period2Str } from "@util/limit"
4+ import { matchCond , meetLimit , meetTimeLimit , period2Str } from "@util/limit"
55import { formatPeriodCommon , MILL_PER_SECOND } from "@util/time"
66import { ElDescriptions , ElDescriptionsItem , ElTag } from "element-plus"
77import { computed , defineComponent } from "vue"
8- import { useReason , useRule } from "../context"
8+ import { useGlobalParam , useReason , useRule } from "../context"
9+
10+ const renderBaseItems = ( rule : timer . limit . Rule | null , url : string ) => < >
11+ < ElDescriptionsItem label = { t ( msg => msg . limit . item . name ) } labelAlign = "right" >
12+ { rule ?. name ?? '-' }
13+ </ ElDescriptionsItem >
14+ < ElDescriptionsItem label = { t ( msg => msg . limit . item . condition ) } labelAlign = 'right' >
15+ { matchCond ( rule ?. cond ?? [ ] , url ) ?. join ( ', ' ) }
16+ </ ElDescriptionsItem >
17+ </ >
918
1019const TimeDescriptions = defineComponent ( {
1120 props : {
@@ -21,15 +30,14 @@ const TimeDescriptions = defineComponent({
2130 setup ( props ) {
2231 const rule = useRule ( )
2332 const reason = useReason ( )
33+ const { url } = useGlobalParam ( )
2434
2535 const timeLimited = computed ( ( ) => meetTimeLimit ( props . time ?? 0 , props . waste ?? 0 , ! ! reason . value ?. allowDelay , reason . value ?. delayCount ?? 0 ) )
2636 const visitLimited = computed ( ( ) => meetLimit ( props . count ?? 0 , props . visit ?? 0 ) )
2737
2838 return ( ) => (
2939 < ElDescriptions border column = { 1 } labelWidth = { 130 } >
30- < ElDescriptionsItem label = { t ( msg => msg . limit . item . name ) } labelAlign = "right" >
31- { rule . value ?. name ?? '-' }
32- </ ElDescriptionsItem >
40+ { renderBaseItems ( rule . value , url ) }
3341 < ElDescriptionsItem label = { props . ruleLabel } labelAlign = "right" >
3442 < Flex gap = { 5 } width = { 200 } >
3543 < ElTag v-show = { ! ! props . time } > { formatPeriodCommon ( ( props . time ?? 0 ) * MILL_PER_SECOND ) } </ ElTag >
@@ -67,6 +75,7 @@ const TimeDescriptions = defineComponent({
6775const _default = defineComponent ( ( ) => {
6876 const reason = useReason ( )
6977 const rule = useRule ( )
78+ const { url } = useGlobalParam ( )
7079 const type = computed ( ( ) => reason . value ?. type )
7180
7281 const { data : browsingTime , refresh : refreshBrowsingTime } = useRequest ( ( ) => {
@@ -98,9 +107,7 @@ const _default = defineComponent(() => {
98107 dataLabel = { t ( msg => msg . calendar . range . thisWeek ) }
99108 />
100109 < ElDescriptions border column = { 1 } v-show = { type . value === 'VISIT' } >
101- < ElDescriptionsItem label = { t ( msg => msg . limit . item . name ) } labelAlign = "right" >
102- { rule . value ?. name || '-' }
103- </ ElDescriptionsItem >
110+ { renderBaseItems ( rule . value , url ) }
104111 < ElDescriptionsItem label = { t ( msg => msg . limit . item . visitTime ) } labelAlign = "right" >
105112 { formatPeriodCommon ( ( rule . value ?. visitTime ?? 0 ) * MILL_PER_SECOND ) || '-' }
106113 </ ElDescriptionsItem >
@@ -114,9 +121,7 @@ const _default = defineComponent(() => {
114121 </ ElDescriptionsItem >
115122 </ ElDescriptions >
116123 < ElDescriptions border column = { 1 } v-show = { type . value === 'PERIOD' } >
117- < ElDescriptionsItem label = { t ( msg => msg . limit . item . name ) } labelAlign = "right" >
118- { rule . value ?. name || '-' }
119- </ ElDescriptionsItem >
124+ { renderBaseItems ( rule . value , url ) }
120125 < ElDescriptionsItem label = { t ( msg => msg . limit . item . period ) } labelAlign = "right" >
121126 {
122127 rule . value ?. periods ?. length
0 commit comments