feat: 离线图标功能
This commit is contained in:
@@ -99,7 +99,7 @@ onBeforeUnmount(() => {
|
||||
>
|
||||
<template #trigger>
|
||||
<div :class="[nsMenu.be('tooltip', 'trigger')]">
|
||||
<VbenIcon :class="nsMenu.e('icon')" :icon="menuIcon" offline />
|
||||
<VbenIcon :class="nsMenu.e('icon')" :icon="menuIcon" />
|
||||
<slot></slot>
|
||||
<span v-if="collapseShowTitle" :class="nsMenu.e('name')">
|
||||
<slot name="title"></slot>
|
||||
@@ -114,7 +114,7 @@ onBeforeUnmount(() => {
|
||||
class="right-2"
|
||||
v-bind="props"
|
||||
/>
|
||||
<VbenIcon :class="nsMenu.e('icon')" :icon="menuIcon" offline />
|
||||
<VbenIcon :class="nsMenu.e('icon')" :icon="menuIcon" />
|
||||
<slot></slot>
|
||||
<slot name="title"></slot>
|
||||
</div>
|
||||
|
@@ -87,7 +87,6 @@ const iconArrowStyle = computed(() => {
|
||||
:class="nsMenu.e('icon')"
|
||||
:icon="icon"
|
||||
fallback
|
||||
offline
|
||||
/>
|
||||
|
||||
<div v-if="!hiddenTitle" :class="[e('title')]">
|
||||
|
@@ -13,7 +13,6 @@ const props = defineProps<{
|
||||
// 没有是否显示默认图标
|
||||
fallback?: boolean;
|
||||
icon?: Component | Function | string;
|
||||
offline?: boolean;
|
||||
}>();
|
||||
|
||||
const isRemoteIcon = computed(() => {
|
||||
@@ -24,20 +23,37 @@ const isComponent = computed(() => {
|
||||
const { icon } = props;
|
||||
return !isString(icon) && (isObject(icon) || isFunction(icon));
|
||||
});
|
||||
|
||||
/**
|
||||
* 判断图标是否为离线图标
|
||||
* 主要是判断后缀是否为 |offline
|
||||
*/
|
||||
const offlineIcon = computed(() => {
|
||||
if (
|
||||
isString(props.icon) &&
|
||||
!isHttpUrl(props.icon) &&
|
||||
props.icon.endsWith('|offline')
|
||||
) {
|
||||
return {
|
||||
confirm: true,
|
||||
icon: props.icon.replace('|offline', ''),
|
||||
};
|
||||
}
|
||||
return {
|
||||
confirm: false,
|
||||
icon: '',
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<component :is="icon as Component" v-if="isComponent" v-bind="$attrs" />
|
||||
<img v-else-if="isRemoteIcon" :src="icon as string" v-bind="$attrs" />
|
||||
<IconifyOfflineIcon
|
||||
v-else-if="icon && offline"
|
||||
v-else-if="offlineIcon.confirm"
|
||||
v-bind="$attrs"
|
||||
:icon="icon as string"
|
||||
/>
|
||||
<IconifyIcon
|
||||
v-else-if="icon && !offline"
|
||||
v-bind="$attrs"
|
||||
:icon="icon as string"
|
||||
:icon="offlineIcon.icon"
|
||||
/>
|
||||
<IconifyIcon v-else-if="icon" v-bind="$attrs" :icon="icon as string" />
|
||||
<IconDefault v-else-if="fallback" v-bind="$attrs" />
|
||||
</template>
|
||||
|
@@ -144,7 +144,6 @@ const tabsView = computed(() => {
|
||||
:icon="tab.icon"
|
||||
class="mr-1 flex size-4 items-center overflow-hidden"
|
||||
/>
|
||||
|
||||
<span class="flex-1 overflow-hidden whitespace-nowrap text-sm">
|
||||
{{ tab.title }}
|
||||
</span>
|
||||
|
Reference in New Issue
Block a user