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