Skip to content

feat: add hyperlinks to the menu, support right-click to open the page #2342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions examples/sites/src/views/layout/layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@collapse-change="collapseChange"
>
<template #default="{ data }">
<div class="node-name-container">
<a @click="clickMenuLink" :href="getMenuLink(data)" class="node-name-container">
<tiny-tag v-if="data?.mode?.includes('mobile-first')" size="mini" effect="plain" class="absolute-tag"
>多端</tiny-tag
>
Expand All @@ -35,7 +35,7 @@
:is-from-menu="true"
>
</version-tip>
</div>
</a>
</template>
</tiny-tree-menu>
</div>
Expand Down Expand Up @@ -124,6 +124,16 @@ export default defineComponent({
}
}

const getMenuLink = (menu) => {
if (menu.type === 'overview') {
return `${import.meta.env.VITE_CONTEXT}${allPath}${lang}/${theme}/overview`
} else if (menu.type === 'docs') {
return getTo('docs/', menu.key)
} else if (menu.type === 'components') {
return getTo('components/', menu.key)
}
}

const collapseChange = (isCollapsed) => {
state.isCollapsed = isCollapsed
}
Expand Down Expand Up @@ -168,6 +178,10 @@ export default defineComponent({
routerCbDestroy()
})

const clickMenuLink = (e) => {
e.preventDefault()
}

return {
...toRefs(state),
appData,
Expand All @@ -179,6 +193,8 @@ export default defineComponent({
apiModeState,
apiModeFn,
templateModeState,
getMenuLink,
clickMenuLink,
getWord,
i18nByKey,
isThemeSaas
Expand Down Expand Up @@ -299,6 +315,7 @@ export default defineComponent({
line-height: 1.5;

.node-name-container {
color: #191919;
display: flex;
align-items: center;
flex-wrap: nowrap;
Expand Down
Loading