2023-02-11 00:44:00 +08:00
|
|
|
<template>
|
2023-04-05 20:13:35 +08:00
|
|
|
<doc-alert title="数据库文档" url="https://doc.iocoder.cn/db-doc/" />
|
|
|
|
|
2023-02-11 00:44:00 +08:00
|
|
|
<ContentWrap title="数据库文档">
|
|
|
|
<!-- 操作工具栏 -->
|
|
|
|
<div class="mb-10px">
|
|
|
|
<XButton
|
|
|
|
type="primary"
|
|
|
|
preIcon="ep:download"
|
|
|
|
:title="t('action.export') + ' HTML'"
|
|
|
|
@click="handleExport('HTML')"
|
|
|
|
/>
|
|
|
|
<XButton
|
|
|
|
type="primary"
|
|
|
|
preIcon="ep:download"
|
|
|
|
:title="t('action.export') + ' Word'"
|
|
|
|
@click="handleExport('Word')"
|
|
|
|
/>
|
|
|
|
<XButton
|
|
|
|
type="primary"
|
|
|
|
preIcon="ep:download"
|
|
|
|
:title="t('action.export') + ' Markdown'"
|
|
|
|
@click="handleExport('Markdown')"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<IFrame v-if="!loding" v-loading="loding" :src="src" />
|
|
|
|
</ContentWrap>
|
|
|
|
</template>
|
|
|
|
<script setup lang="ts" name="DbDoc">
|
|
|
|
import download from '@/utils/download'
|
|
|
|
|
|
|
|
import * as DbDocApi from '@/api/infra/dbDoc'
|
|
|
|
|
|
|
|
const { t } = useI18n() // 国际化
|
|
|
|
const src = ref('')
|
|
|
|
const loding = ref(true)
|
|
|
|
/** 页面加载 */
|
|
|
|
const init = async () => {
|
2023-04-05 20:13:35 +08:00
|
|
|
const res = await DbDocApi.exportHtml()
|
2023-02-11 00:44:00 +08:00
|
|
|
let blob = new Blob([res], { type: 'text/html' })
|
|
|
|
let blobUrl = window.URL.createObjectURL(blob)
|
|
|
|
src.value = blobUrl
|
|
|
|
loding.value = false
|
|
|
|
}
|
|
|
|
/** 处理导出 */
|
|
|
|
const handleExport = async (type: string) => {
|
|
|
|
if (type === 'HTML') {
|
2023-04-05 20:13:35 +08:00
|
|
|
const res = await DbDocApi.exportHtml()
|
2023-02-11 00:44:00 +08:00
|
|
|
download.html(res, '数据库文档.html')
|
|
|
|
}
|
|
|
|
if (type === 'Word') {
|
2023-04-05 20:13:35 +08:00
|
|
|
const res = await DbDocApi.exportWord()
|
2023-02-11 00:44:00 +08:00
|
|
|
download.word(res, '数据库文档.doc')
|
|
|
|
}
|
|
|
|
if (type === 'Markdown') {
|
2023-04-05 20:13:35 +08:00
|
|
|
const res = await DbDocApi.exportMarkdown()
|
2023-02-11 00:44:00 +08:00
|
|
|
download.markdown(res, '数据库文档.md')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onMounted(async () => {
|
|
|
|
await init()
|
|
|
|
})
|
|
|
|
</script>
|