3x-ui/web/html/modals/text_modal.html

62 lines
1.9 KiB
HTML
Raw Normal View History

{{define "modals/textModal"}}
<a-modal id="text-modal" v-model="txtModal.visible" :title="txtModal.title" :closable="true"
:class="themeSwitcher.currentTheme">
<a-input :style="{ overflowY: 'auto' }" type="textarea" v-model="txtModal.content"
:autosize="{ minRows: 10, maxRows: 20}"></a-input>
<template slot="footer">
<a-button v-if="!ObjectUtil.isEmpty(txtModal.fileName)" icon="download"
@click="txtModal.download(txtModal.content, txtModal.fileName)">
<span>[[ txtModal.fileName ]]</span>
</a-button>
<a-button type="primary" icon="copy" @click="txtModal.copy(txtModal.content)">
<span>{{ i18n "copy" }}</span>
</a-button>
</template>
2023-02-09 19:18:06 +00:00
</a-modal>
<script>
const txtModal = {
title: '',
content: '',
fileName: '',
qrcode: null,
visible: false,
2023-05-08 14:44:22 +00:00
show: function (title = '', content = '', fileName = '') {
2023-02-09 19:18:06 +00:00
this.title = title;
this.content = content;
this.fileName = fileName;
this.visible = true;
},
copy: function (content = '') {
ClipboardManager
.copyText(content)
.then(() => {
app.$message.success('{{ i18n "copied" }}')
this.close();
})
2023-02-09 19:18:06 +00:00
},
download: function (content = '', fileName = '') {
let link = document.createElement('a');
link.download = fileName;
link.href = URL.createObjectURL(new Blob([content], { type: 'text/plain' }));
link.click();
URL.revokeObjectURL(link.href);
link.remove();
},
2023-02-09 19:18:06 +00:00
close: function () {
this.visible = false;
},
};
const textModalApp = new Vue({
2023-03-17 16:07:49 +00:00
delimiters: ['[[', ']]'],
2023-02-09 19:18:06 +00:00
el: '#text-modal',
data: {
txtModal: txtModal,
},
});
</script>
{{end}}