2025-06-10 16:21:40 +08:00
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
|
import type { DocAlertProps } from './types';
|
|
|
|
|
|
|
2025-06-24 16:23:15 +08:00
|
|
|
|
import { ref } from 'vue';
|
|
|
|
|
|
|
2025-06-10 16:21:40 +08:00
|
|
|
|
import { isDocAlertEnable } from '@vben/hooks';
|
|
|
|
|
|
|
|
|
|
|
|
import { VbenIcon } from '@vben-core/shadcn-ui';
|
2025-06-24 16:23:15 +08:00
|
|
|
|
import { openWindow } from '@vben-core/shared/utils';
|
2025-06-10 16:21:40 +08:00
|
|
|
|
|
|
|
|
|
|
defineOptions({
|
|
|
|
|
|
name: 'DocAlert',
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps<DocAlertProps>();
|
|
|
|
|
|
|
2025-06-24 16:23:15 +08:00
|
|
|
|
/** 控制组件显示状态 */
|
|
|
|
|
|
const isVisible = ref(true);
|
|
|
|
|
|
|
2025-06-10 16:21:40 +08:00
|
|
|
|
function goToUrl() {
|
|
|
|
|
|
openWindow(props.url);
|
|
|
|
|
|
}
|
2025-06-24 16:23:15 +08:00
|
|
|
|
|
|
|
|
|
|
function close() {
|
|
|
|
|
|
isVisible.value = false;
|
|
|
|
|
|
}
|
2025-06-10 16:21:40 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<div
|
|
|
|
|
|
role="alert"
|
2025-06-24 16:23:15 +08:00
|
|
|
|
v-if="isDocAlertEnable() && isVisible"
|
2025-07-05 18:30:04 +08:00
|
|
|
|
class="border-primary bg-primary/10 relative m-3 my-2 flex h-8 items-center gap-2 rounded-md border p-2"
|
2025-06-10 16:21:40 +08:00
|
|
|
|
>
|
|
|
|
|
|
<span class="grid shrink-0 place-items-center">
|
|
|
|
|
|
<VbenIcon icon="mdi:information-outline" class="text-primary size-5" />
|
|
|
|
|
|
</span>
|
2025-06-24 16:23:15 +08:00
|
|
|
|
<div class="text-primary min-w-0 flex-1 font-sans text-sm leading-none">
|
2025-06-24 17:06:07 +08:00
|
|
|
|
<span class="inline-block">【{{ title }}】</span>
|
2025-06-24 16:23:15 +08:00
|
|
|
|
<a
|
|
|
|
|
|
class="hover:text-success cursor-pointer break-all"
|
|
|
|
|
|
@click="goToUrl"
|
|
|
|
|
|
:title="url"
|
|
|
|
|
|
>
|
|
|
|
|
|
文档地址:{{ url }}
|
|
|
|
|
|
</a>
|
2025-06-10 16:21:40 +08:00
|
|
|
|
</div>
|
2025-06-24 16:23:15 +08:00
|
|
|
|
<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>
|
2025-06-10 16:21:40 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|