feat(S3): content export - Markdown download and PDF print
- Backend: GET /api/export/:type/:id returns .md file download - Backend: POST /api/export/text for direct text-to-md export - Frontend: downloadMarkdown() utility for client-side .md download - Frontend: printAsPdf() utility via browser print dialog - GenerateView: export dropdown button (MD / PDF) on result card Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,8 @@ import { useRouter } from 'vue-router'
|
||||
import { fetchGenerateMeta, fetchTemplatesByCategory, generatePrompt, continuePrompt } from '@/api/modules/prompt'
|
||||
import { quickAddFavorite } from '@/api/modules/favorite'
|
||||
import type { PromptTemplateItem } from '@/api/types/template'
|
||||
import { ArrowDownBold } from '@element-plus/icons-vue'
|
||||
import { downloadMarkdown, printAsPdf } from '@/utils/export'
|
||||
|
||||
const metaLoading = ref(true)
|
||||
const templatesLoading = ref(false)
|
||||
@@ -279,6 +281,19 @@ function resetConversation() {
|
||||
ElMessage.info('已开始新对话')
|
||||
}
|
||||
|
||||
function exportMarkdown() {
|
||||
if (!result.value) return
|
||||
const tpl = selectedTemplate.value
|
||||
downloadMarkdown(result.value.generated_text, tpl?.name || '提示词生成结果')
|
||||
ElMessage.success('Markdown 已下载')
|
||||
}
|
||||
|
||||
function exportPdf() {
|
||||
if (!result.value) return
|
||||
const tpl = selectedTemplate.value
|
||||
printAsPdf(result.value.generated_text, tpl?.name || '提示词生成结果')
|
||||
}
|
||||
|
||||
async function addToFavorites() {
|
||||
if (!result.value || selectedTemplateId.value == null) return
|
||||
const tpl = selectedTemplate.value
|
||||
@@ -439,6 +454,17 @@ onMounted(async () => {
|
||||
加入收藏
|
||||
</el-button>
|
||||
<el-button type="success" plain size="small" @click="copyResult">复制</el-button>
|
||||
<el-dropdown trigger="click" @command="(cmd: string) => cmd === 'md' ? exportMarkdown() : exportPdf()">
|
||||
<el-button type="info" plain size="small">
|
||||
导出 <el-icon class="el-icon--right"><ArrowDownBold /></el-icon>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="md">Markdown (.md)</el-dropdown-item>
|
||||
<el-dropdown-item command="pdf">PDF (打印)</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</el-space>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user