mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-06 00:18:51 +08:00
* feat: 菜单支持a标签右键的所有浏览器行为(在新标签页中、新窗口中打开链接,拖拽到新标签页打开等) * feat: 修复添加a标签样式问题 * feat: 修复windows下双滚动条问题 * feat: 修复添加a标签样式问题
37 lines
649 B
Vue
37 lines
649 B
Vue
<script setup lang="ts">
|
|
import { computed } from "vue";
|
|
import { isUrl } from "@pureadmin/utils";
|
|
import { menuType } from "@/layout/types";
|
|
|
|
defineOptions({
|
|
name: "LinkItem"
|
|
});
|
|
|
|
const props = defineProps<{
|
|
to: menuType;
|
|
}>();
|
|
|
|
const isExternalLink = computed(() => isUrl(props.to.name));
|
|
const getLinkProps = (item: menuType) => {
|
|
if (isExternalLink.value) {
|
|
return {
|
|
href: item.name,
|
|
target: "_blank",
|
|
rel: "noopener"
|
|
};
|
|
}
|
|
return {
|
|
to: item
|
|
};
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<component
|
|
:is="isExternalLink ? 'a' : 'router-link'"
|
|
v-bind="getLinkProps(to)"
|
|
>
|
|
<slot />
|
|
</component>
|
|
</template>
|