【新增】DocAlert 组件,提供文档输出

pull/42/head
YunaiV 2024-05-04 14:57:37 +08:00
parent 43cef5a186
commit a59032a695
3 changed files with 66 additions and 0 deletions

3
.env
View File

@ -13,5 +13,8 @@ VITE_GLOB_APP_TENANT_ENABLE = true
# 验证码的开关
VITE_GLOB_APP_CAPTCHA_ENABLE = true
# 文档地址的开关
VITE_APP_DOCALERT_ENABLE=true
# 百度统计
VITE_APP_BAIDU_CODE = eb21166668bf766b9d059a6fd1c10777

View File

@ -0,0 +1,4 @@
import docAlert from './src/DocAlert.vue'
import { withInstall } from '@/utils'
export const DocAlert = withInstall(docAlert)

View File

@ -0,0 +1,59 @@
<script lang="tsx">
import type { PropType } from 'vue'
import { defineComponent } from 'vue';
import { Alert, Button } from 'ant-design-vue';
export default defineComponent({
name: 'DocAlert',
components: {
Alert,
Button
},
props: {
title: {
type: String as PropType<string>,
required: true,
},
url: {
type: String as PropType<string>,
required: true,
},
},
setup(props) {
/** 跳转 URL 链接 */
const goToUrl = () => {
window.open(props.url);
};
/** 是否开启 */
const getEnable = () => {
return import.meta.env.VITE_APP_DOCALERT_ENABLE !== 'false';
};
return {
goToUrl,
getEnable,
props
};
}
});
</script>
<style scoped>
.ant-alert-success {
margin-top: 5px;
margin-left: 15px;
margin-right: 15px;
cursor: pointer;
border: 1px solid green;
}
</style>
<template>
<Alert v-if="getEnable()" type="success" show-icon>
<template #message>
<Button type="link" @click="goToUrl">
{{ title }}文档地址{{ url }}
</Button>
</template>
</Alert>
</template>