1
0

text_modal.html 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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="themeSwitcher.darkCardClass"
  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)"
  8. :download="txtModal.fileName">
  9. {{ i18n "download" }} [[ txtModal.fileName ]]
  10. </a-button>
  11. <a-input type="textarea" v-model="txtModal.content"
  12. :autosize="{ minRows: 10, maxRows: 20}"></a-input>
  13. </a-modal>
  14. <script>
  15. const txtModal = {
  16. title: '',
  17. content: '',
  18. fileName: '',
  19. qrcode: null,
  20. clipboard: null,
  21. visible: false,
  22. show: function (title = '', content = '', fileName = '') {
  23. this.title = title;
  24. this.content = content;
  25. this.fileName = fileName;
  26. this.visible = true;
  27. textModalApp.$nextTick(() => {
  28. if (this.clipboard === null) {
  29. this.clipboard = new ClipboardJS('#txt-modal-ok-btn', {
  30. text: () => this.content,
  31. });
  32. this.clipboard.on('success', () => app.$message.success('{{ i18n "copied" }}'));
  33. }
  34. });
  35. },
  36. close: function () {
  37. this.visible = false;
  38. },
  39. };
  40. const textModalApp = new Vue({
  41. delimiters: ['[[', ']]'],
  42. el: '#text-modal',
  43. data: {
  44. txtModal: txtModal,
  45. },
  46. });
  47. </script>
  48. {{end}}