text_modal.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. {{define "textModal"}}
  2. <a-modal id="text-modal" v-model="txtModal.visible" :title="txtModal.title"
  3. :closable="true" ok-text='{{ i18n "copy" }}' cancel-text='{{ i18n "close" }}'
  4. :class="siderDrawer.isDarkTheme ? darkClass : ''"
  5. :ok-button-props="{attrs:{id:'txt-modal-ok-btn'}}">
  6. <a-button v-if="!ObjectUtil.isEmpty(txtModal.fileName)" type="primary" style="margin-bottom: 10px;"
  7. :href="'data:application/text;charset=utf-8,' + encodeURIComponent(txtModal.content)" :download="txtModal.fileName">
  8. {{ i18n "download" }} [[ txtModal.fileName ]]
  9. </a-button>
  10. <a-input type="textarea" v-model="txtModal.content"
  11. :autosize="{ minRows: 10, maxRows: 20}"></a-input>
  12. </a-modal>
  13. <script>
  14. const txtModal = {
  15. title: '',
  16. content: '',
  17. fileName: '',
  18. qrcode: null,
  19. clipboard: null,
  20. visible: false,
  21. show: function (title='', content='', fileName='') {
  22. this.title = title;
  23. this.content = content;
  24. this.fileName = fileName;
  25. this.visible = true;
  26. textModalApp.$nextTick(() => {
  27. if (this.clipboard === null) {
  28. this.clipboard = new ClipboardJS('#txt-modal-ok-btn', {
  29. text: () => this.content,
  30. });
  31. this.clipboard.on('success', () => app.$message.success('{{ i18n "copied" }}'));
  32. }
  33. });
  34. },
  35. close: function () {
  36. this.visible = false;
  37. },
  38. };
  39. const textModalApp = new Vue({
  40. delimiters: ['[[', ']]'],
  41. el: '#text-modal',
  42. data: {
  43. txtModal: txtModal,
  44. },
  45. });
  46. </script>
  47. {{end}}