11/**
2- * Generate operation butons
2+ * Generate operation buttons
33 */
44import { h , ref , Ref } from 'vue'
55import { ElButton , ElMessage , ElPopconfirm , ElTableColumn } from "element-plus"
@@ -12,6 +12,8 @@ import { formatTime } from '../../../../util/time'
1212import { dateFormatter } from '../formatter'
1313import { ReportMessage } from '../../../locale/components/report'
1414import { QueryData } from '../../common/constants'
15+ import { LocationQueryRaw , Router } from 'vue-router'
16+ import { TRENDER_ROUTE } from '../../../router/constants'
1517
1618const timerDatabase = new TimerDatabase ( chrome . storage . local )
1719
@@ -23,7 +25,9 @@ type Props = {
2325 queryData : QueryData
2426 whitelistRef : Ref < string [ ] >
2527 mergeDateRef : Ref < boolean >
28+ mergeDomainRef : Ref < boolean >
2629 dateRangeRef : Ref < Array < Date > >
30+ router : Router
2731}
2832
2933export type OperationButtonColumnProps = Props
@@ -116,7 +120,6 @@ const add2WhitelistButton = (props: Props, { host }: SiteInfo) => operationButto
116120} )
117121
118122// Remove from whitelist
119-
120123const removeFromWhitelistButton = ( props : Props , { host } : SiteInfo ) => operationButton ( {
121124 confirmTitle : t ( msg => msg . setting . whitelist . removeConfirmMsg , { url : host } ) ,
122125 buttonType : 'primary' ,
@@ -125,24 +128,44 @@ const removeFromWhitelistButton = (props: Props, { host }: SiteInfo) => operatio
125128 onConfirm : ( ) => operateTheWhitelist ( whitelistService . remove ( host ) , props , 'removeFromWhitelist' )
126129} )
127130
131+ function handleClickJump ( props : Props , { host } : SiteInfo ) {
132+ const query : LocationQueryRaw = {
133+ host,
134+ merge : props . mergeDomainRef . value ? '1' : '0' ,
135+ }
136+ props . router . push ( { path : TRENDER_ROUTE , query } )
137+ }
138+
139+ // Jump to the trender
140+ const jumpTowardTheTrender = ( props : Props , row : SiteInfo ) => h ( ElButton , {
141+ icon : 'el-icon-stopwatch' ,
142+ size : 'mini' ,
143+ type : 'primary' ,
144+ onClick : ( ) => handleClickJump ( props , row )
145+ } , ( ) => t ( msg => msg . item . operation . jumpToTrender ) )
146+
128147const operationContainer = ( props : Props , row : SiteInfo ) => {
129148 const operationButtons = [ ]
130- const { host, date } = row
131- // Delete button
132- operationButtons . push ( deleteButton ( props , row ) )
133-
134- const existsInWhitelist = props . whitelistRef . value . includes ( host )
135- const whitelistButton = existsInWhitelist ? removeFromWhitelistButton ( props , row ) : add2WhitelistButton ( props , row )
136- operationButtons . push ( whitelistButton )
149+ const { host } = row
150+ operationButtons . push ( jumpTowardTheTrender ( props , row ) )
151+ if ( ! props . mergeDomainRef . value ) {
152+ // Delete button
153+ operationButtons . push ( deleteButton ( props , row ) )
154+
155+ const existsInWhitelist = props . whitelistRef . value . includes ( host )
156+ const whitelistButton = existsInWhitelist ? removeFromWhitelistButton ( props , row ) : add2WhitelistButton ( props , row )
157+ operationButtons . push ( whitelistButton )
158+ }
137159 return operationButtons
138160}
139161
140162const tableColumnProps = {
141163 label : t ( msg => msg . item . operation . label ) ,
142- minWidth : 240 ,
143- align : 'center '
164+ align : 'center' ,
165+ fixed : 'right '
144166}
145- const _default = ( props : Props ) => h ( ElTableColumn , tableColumnProps ,
167+ const _default = ( props : Props ) => h ( ElTableColumn ,
168+ { minWidth : props . mergeDomainRef . value ? 100 : 280 , ...tableColumnProps } ,
146169 {
147170 default : ( data : { row : SiteInfo } ) => operationContainer ( props , data . row )
148171 }
0 commit comments