text_modal.html 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. :ok-button-props="{attrs:{id:'txt-modal-ok-btn'}}">
  5. <a-button v-if="!ObjectUtil.isEmpty(txtModal.fileName)" type="primary" style="margin-bottom: 10px;"
  6. @click="downloader.download(txtModal.fileName, txtModal.content)">
  7. {{ i18n "download" }} [[ txtModal.fileName ]]
  8. </a-button>
  9. <a-input type="textarea" v-model="txtModal.content"
  10. :autosize="{ minRows: 10, maxRows: 20}"></a-input>
  11. </a-modal>
  12. <script>
  13. const txtModal = {
  14. title: '',
  15. content: '',
  16. fileName: '',
  17. qrcode: null,
  18. clipboard: null,
  19. visible: false,
  20. show: function (title='', content='', fileName='') {
  21. this.title = title;
  22. this.content = content;
  23. this.fileName = fileName;
  24. this.visible = true;
  25. textModalApp.$nextTick(() => {
  26. if (this.clipboard === null) {
  27. this.clipboard = new ClipboardJS('#txt-modal-ok-btn', {
  28. text: () => this.content,
  29. });
  30. this.clipboard.on('success', () => app.$message.success('{{ i18n "copied" }}'));
  31. }
  32. if (this.qrcode === null) {
  33. this.qrcode = new QRious({
  34. element: document.querySelector('#qrCode'),
  35. size: 260,
  36. value: content,
  37. });
  38. } else {
  39. this.qrcode.value = content;
  40. }
  41. });
  42. },
  43. close: function () {
  44. this.visible = false;
  45. },
  46. };
  47. const textModalApp = new Vue({
  48. el: '#text-modal',
  49. data: {
  50. txtModal: txtModal,
  51. },
  52. });
  53. </script>
  54. {{end}}