File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import type {
1717import { formatPeriodCommon , formatTime } from "@util/time"
1818import { t } from "@popup/locale"
1919import { getPrimaryTextColor , getSecondaryTextColor } from "@util/style"
20+ import { generateSiteLabel } from "@util/site"
2021
2122type EcOption = ComposeOption <
2223 | PieSeriesOption
@@ -47,10 +48,7 @@ const toolTipFormatter = ({ type }: timer.popup.QueryResult, params: any) => {
4748 const { name, value, percent } = format
4849 const data = format . data as timer . stat . Row
4950 const host = data . host
50- let dimensionName = name
51- if ( host && host !== name ) {
52- dimensionName = `${ name } (${ host } )`
53- }
51+ const dimensionName = generateSiteLabel ( host , name )
5452 const valueText = type === 'time' ? value || 0 : formatPeriodCommon ( typeof value === 'number' ? value as number : 0 )
5553 return `${ dimensionName } <br/>${ valueText } (${ percent } %)`
5654}
Original file line number Diff line number Diff line change @@ -34,4 +34,17 @@ export function extractSiteName(title: string, host?: string) {
3434 . filter ( s => ! INVALID_SITE_NAME . test ( s ) )
3535 . sort ( ( a , b ) => a . length - b . length ) [ 0 ]
3636 . trim ( )
37+ }
38+
39+ /**
40+ * Generate the label text with host and name
41+ *
42+ * @since 1.1.8
43+ */
44+ export function generateSiteLabel ( host : string , name ?: string ) : string {
45+ if ( host && host !== name ) {
46+ return `${ name } (${ host } )`
47+ } else {
48+ return host
49+ }
3750}
You can’t perform that action at this time.
0 commit comments