2026-05-09 17:38:48 +02:00
|
|
|
<script setup>
|
|
|
|
|
import { CopyOutlined, DownloadOutlined } from '@ant-design/icons-vue';
|
|
|
|
|
import { message } from 'ant-design-vue';
|
|
|
|
|
|
|
|
|
|
import { ClipboardManager, FileManager } from '@/utils';
|
|
|
|
|
|
|
|
|
|
// Read-only text modal — used to surface multi-line export blobs
|
|
|
|
|
// (subscription URLs, raw inbound JSON, generated share links) the
|
|
|
|
|
// way the legacy txtModal did.
|
|
|
|
|
|
|
|
|
|
defineProps({
|
|
|
|
|
open: { type: Boolean, default: false },
|
|
|
|
|
title: { type: String, default: '' },
|
|
|
|
|
content: { type: String, default: '' },
|
|
|
|
|
// When set, surfaces a download button that writes `content` to a
|
|
|
|
|
// text file with this name.
|
|
|
|
|
fileName: { type: String, default: '' },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['update:open']);
|
|
|
|
|
|
|
|
|
|
function close() {
|
|
|
|
|
emit('update:open', false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function copy(value) {
|
|
|
|
|
const ok = await ClipboardManager.copyText(value || '');
|
|
|
|
|
if (ok) {
|
|
|
|
|
message.success('Copied');
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function download(content, name) {
|
|
|
|
|
if (!name) return;
|
|
|
|
|
FileManager.downloadTextFile(content, name);
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<a-modal :open="open" :title="title" :closable="true" @cancel="close">
|
2026-05-10 17:03:11 +02:00
|
|
|
<a-textarea :value="content" readonly :auto-size="{ minRows: 10, maxRows: 20 }" class="text-modal-content" />
|
2026-05-09 17:38:48 +02:00
|
|
|
<template #footer>
|
|
|
|
|
<a-button v-if="fileName" @click="download(content, fileName)">
|
2026-05-10 17:03:11 +02:00
|
|
|
<template #icon>
|
|
|
|
|
<DownloadOutlined />
|
|
|
|
|
</template>
|
2026-05-09 17:38:48 +02:00
|
|
|
{{ fileName }}
|
|
|
|
|
</a-button>
|
|
|
|
|
<a-button type="primary" @click="copy(content)">
|
2026-05-10 17:03:11 +02:00
|
|
|
<template #icon>
|
|
|
|
|
<CopyOutlined />
|
|
|
|
|
</template>
|
2026-05-09 17:38:48 +02:00
|
|
|
Copy
|
|
|
|
|
</a-button>
|
|
|
|
|
</template>
|
|
|
|
|
</a-modal>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.text-modal-content {
|
|
|
|
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
}
|
|
|
|
|
</style>
|