33 <Favicon :favicon =" item.favicon" />
44 <div class =" ml-10 flex-grow-2" >
55 <div class =" first-block" >
6- <p class =" url" @click =" openUrl(item.url)" >{{ item.url }}</p >
6+ <div class =" w-85" >
7+ <p class =" url" @click =" openUrl(item.url)" >{{ url }}</p >
8+ <div class =" d-inline-block" v-html =" getBadgeIcon()" ></div >
9+ </div >
710 <p class =" text-right time" >{{ summaryTimeForTab }}</p >
811 </div >
12+ <p v-if =" showWarningMessage" class =" warning-message" >
13+ You cannot open a local file due to security rules
14+ </p >
915 <div class =" second-block" >
1016 <div class =" progress-bar" >
1117 <div :style =" styleForProgressBar" ></div >
1420 </div >
1521 <p class =" sessions" >{{ sessions }}</p >
1622 </div >
17- <div ></div >
1823 </div >
1924</template >
2025
@@ -25,7 +30,7 @@ export default {
2530 </script >
2631
2732<script lang="ts" setup>
28- import { computed } from ' vue' ;
33+ import { computed , ref } from ' vue' ;
2934import Favicon from ' ./Favicon.vue' ;
3035import { convertSummaryTimeToString } from ' ../utils/converter' ;
3136import { getPercentage } from ' ../utils/common' ;
@@ -35,6 +40,21 @@ const props = defineProps<{
3540 item: CurrentTabItem ;
3641}>();
3742
43+ enum TypeOfUrl {
44+ WebSite ,
45+ Document ,
46+ }
47+
48+ const typeOfUrl = computed (() =>
49+ props .item .url .startsWith (' file:' ) ? TypeOfUrl .Document : TypeOfUrl .WebSite ,
50+ );
51+
52+ const url = computed (() =>
53+ typeOfUrl .value == TypeOfUrl .Document
54+ ? encodeURI (props .item .url .split (' ///' )[1 ])
55+ : props .item .url ,
56+ );
57+
3858const sessions = computed (() => {
3959 if (props .item .sessions == 0 ) return ' 0 session' ;
4060 if (props .item .sessions > 1 ) return ` ${props .item .sessions } sessions ` ;
@@ -51,8 +71,16 @@ const percent = computed(() =>
5171const styleForProgressBar = computed (() => ` width: ${percent .value }% ` );
5272
5373function openUrl(url : string ) {
54- if (! url .startsWith (' http' )) url = ` https://${url } ` ;
55- window .open (url , ' _blank' );
74+ if (typeOfUrl .value != TypeOfUrl .Document && ! url .startsWith (' http' )) {
75+ url = ` https://${url } ` ;
76+ window .open (url , ' _blank' );
77+ } else showWarningMessage .value = true ;
78+ }
79+
80+ const showWarningMessage = ref <boolean >();
81+
82+ function getBadgeIcon() {
83+ if (typeOfUrl .value == TypeOfUrl .Document ) return ` <span class="badge-document">Document</span> ` ;
5684}
5785 </script >
5886
@@ -73,6 +101,9 @@ function openUrl(url: string) {
73101 font-size : 15px ;
74102 font-weight : 600 ;
75103 cursor : pointer ;
104+ overflow-wrap : anywhere;
105+ max-width : 80% ;
106+ display : inline-block ;
76107}
77108.tab-item .url :hover {
78109 color : #1a0dab ;
@@ -113,4 +144,15 @@ function openUrl(url: string) {
113144.tab-item .sessions {
114145 margin : 0 0 0 5px ;
115146}
147+ .tab-item ::v-deep span .badge-document {
148+ border-radius : 6px ;
149+ background-color : #0043ff9e ;
150+ padding : 3px 7px ;
151+ font-size : 11px ;
152+ color : white ;
153+ font-weight : 600 ;
154+ }
155+ .tab-item .warning-message {
156+ color : grey ;
157+ }
116158 </style >
0 commit comments