Skip to content

Commit

Permalink
add bold style for route path
Browse files Browse the repository at this point in the history
  • Loading branch information
gene9831 committed Feb 14, 2025
1 parent 5a6d059 commit 84e2b2c
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions packages/canvas/route-bar/src/CanvasRouteBar.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<template>
<div id="canvas-route-bar" :style="sizeStyle">
<div class="address-bar">
<template v-for="route in routes" :key="route.id">
<template v-for="(route, index) in routes" :key="route.id">
<span class="slash">/</span>
<span
:class="[
{
route: route.isPage && route.id !== pageId,
current: route.id === pageId && existsPreview,
bold: fontIsBold(route.id, index),
'is-preview': route.isPreview
}
]"
Expand Down Expand Up @@ -118,6 +118,19 @@ watch(
{ immediate: true }
)
const fontIsBold = (id, index) => {
if (existsPreview.value) {
return id === pageId.value
}
// 没有previewId时,routes长度大于1,最后一个route path显示高亮
if (routes.value.length > 1) {
return index === routes.value.length - 1
}
return false
}
/**
* @param route {Route}
*/
Expand Down Expand Up @@ -167,7 +180,7 @@ const handleClearPreview = () => {
.slash {
margin: 0 2px;
}
.current {
.bold {
font-weight: bold;
}
.is-preview {
Expand Down

0 comments on commit 84e2b2c

Please sign in to comment.