diff --git a/web/html/xui/modals/text_modal.html b/web/html/xui/modals/text_modal.html index b5751c65..cd90821d 100644 --- a/web/html/xui/modals/text_modal.html +++ b/web/html/xui/modals/text_modal.html @@ -1,20 +1,20 @@ {{define "modals/textModal"}} -<a-modal id="text-modal" v-model="txtModal.visible" :title="txtModal.title" - :closable="true" - :class="themeSwitcher.currentTheme"> - <template slot="footer"> - <a-button v-if="!ObjectUtil.isEmpty(txtModal.fileName)" icon="download" - :href="'data:application/text;charset=utf-8,' + encodeURIComponent(txtModal.content)" - :download="txtModal.fileName">[[ txtModal.fileName ]] - </a-button> - <a-button type="primary" @click="txtModal.copy(txtModal.content)">{{ i18n "copy" }}</a-button> - </template> +<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> </a-modal> <script> - const txtModal = { title: '', content: '', @@ -35,6 +35,17 @@ this.close(); }) }, + 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(); + }, close: function () { this.visible = false; }, @@ -47,6 +58,5 @@ txtModal: txtModal, }, }); - </script> -{{end}} +{{end}} \ No newline at end of file