Files
iot-device-management-frontend/packages/effects/common-ui/src/components/doc-alert/doc-alert.vue

56 lines
1.4 KiB
Vue
Raw Normal View History

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"
class="border-primary bg-primary/10 relative my-2 flex h-8 w-full 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">
<span class="inline-block w-40">{{ title }}</span>
<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>