feat: 优化 doc-alert
parent
0b830d634f
commit
fe6fcdaf67
|
@ -1,10 +1,12 @@
|
|||
<script lang="ts" setup>
|
||||
import type { DocAlertProps } from './types';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { isDocAlertEnable } from '@vben/hooks';
|
||||
|
||||
import { VbenIcon } from '@vben-core/shadcn-ui';
|
||||
import { cn, openWindow } from '@vben-core/shared/utils';
|
||||
import { openWindow } from '@vben-core/shared/utils';
|
||||
|
||||
defineOptions({
|
||||
name: 'DocAlert',
|
||||
|
@ -12,28 +14,42 @@ defineOptions({
|
|||
|
||||
const props = defineProps<DocAlertProps>();
|
||||
|
||||
/** 控制组件显示状态 */
|
||||
const isVisible = ref(true);
|
||||
|
||||
function goToUrl() {
|
||||
openWindow(props.url);
|
||||
}
|
||||
|
||||
function close() {
|
||||
isVisible.value = false;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<!-- Alert Component -->
|
||||
<!-- TODO @xingyu:是不是左右边距 + 下,和搜索的对齐,会好看一丢丢的 -->
|
||||
<div
|
||||
role="alert"
|
||||
v-if="isDocAlertEnable()"
|
||||
:class="
|
||||
cn(
|
||||
'border-primary bg-primary/10 relative m-1 flex w-full items-center gap-5 rounded-md border p-1',
|
||||
)
|
||||
"
|
||||
v-if="isDocAlertEnable() && isVisible"
|
||||
class="border-primary bg-primary/10 relative my-2 flex h-8 w-full items-center gap-2 rounded-md border p-2"
|
||||
>
|
||||
<span class="grid shrink-0 place-items-center">
|
||||
<VbenIcon icon="mdi:information-outline" class="text-primary size-5" />
|
||||
</span>
|
||||
<div class="text-primary w-full font-sans text-sm leading-none">
|
||||
【{{ title }}】文档地址:
|
||||
<a class="hover:text-primary" @click="goToUrl">{{ url }}</a>
|
||||
<div class="text-primary min-w-0 flex-1 font-sans text-sm leading-none">
|
||||
<span class="inline-block w-40">【{{ title }}】</span>
|
||||
<a
|
||||
class="hover:text-success cursor-pointer break-all"
|
||||
@click="goToUrl"
|
||||
:title="url"
|
||||
>
|
||||
文档地址:{{ url }}
|
||||
</a>
|
||||
</div>
|
||||
<span class="grid shrink-0 cursor-pointer place-items-center">
|
||||
<VbenIcon
|
||||
icon="mdi:close"
|
||||
class="text-primary size-5 hover:text-red-500"
|
||||
@click="close"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -63,7 +63,7 @@ onMounted(() => {
|
|||
ref="docRef"
|
||||
:class="
|
||||
cn(
|
||||
'bg-card border-border relative flex items-start rounded-md border-b p-1',
|
||||
'bg-card border-border relative mx-4 flex items-start rounded-md border-b',
|
||||
)
|
||||
"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue