App.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <script setup>
  2. import { Dashboard, DashboardModal, DragDrop, ProgressBar } from '@uppy/vue'
  3. </script>
  4. <template>
  5. <div id="app">
  6. <!-- <HelloWorld msg="Welcome to Uppy Vue Demo"/> -->
  7. <h1>Welcome to Uppy Vue Demo!</h1>
  8. <h2>Inline Dashboard</h2>
  9. <label>
  10. <input
  11. type="checkbox"
  12. :checked="showInlineDashboard"
  13. @change="(event) => {
  14. showInlineDashboard = event.target.checked
  15. }"
  16. />
  17. Show Dashboard
  18. </label>
  19. <Dashboard
  20. v-if="showInlineDashboard"
  21. :uppy="uppy"
  22. :props="{
  23. metaFields: [{ id: 'name', name: 'Name', placeholder: 'File name' }]
  24. }"
  25. />
  26. <h2>Modal Dashboard</h2>
  27. <div>
  28. <button @click="open = true">Show Dashboard</button>
  29. <DashboardModal
  30. :uppy="uppy2"
  31. :open="open"
  32. :props="{
  33. onRequestCloseModal: handleClose
  34. }"
  35. />
  36. </div>
  37. <h2>Drag Drop Area</h2>
  38. <DragDrop
  39. :uppy="uppy"
  40. :props="{
  41. locale: {
  42. strings: {
  43. chooseFile: 'Boop a file',
  44. orDragDrop: 'or yoink it here'
  45. }
  46. }
  47. }"
  48. />
  49. <h2>Progress Bar</h2>
  50. <ProgressBar
  51. :uppy="uppy"
  52. :props="{
  53. hideAfterFinish: false
  54. }"
  55. />
  56. </div>
  57. </template>
  58. <script>
  59. import Uppy from '@uppy/core'
  60. import Tus from '@uppy/tus'
  61. import { defineComponent } from 'vue'
  62. const {
  63. VITE_TUS_ENDPOINT: TUS_ENDPOINT,
  64. } = import.meta.env
  65. export default defineComponent({
  66. computed: {
  67. uppy: () => new Uppy({ id: 'uppy1', autoProceed: true, debug: true })
  68. .use(Tus, { endpoint: TUS_ENDPOINT }),
  69. uppy2: () => new Uppy({ id: 'uppy2', autoProceed: false, debug: true })
  70. .use(Tus, { endpoint: TUS_ENDPOINT }),
  71. },
  72. data () {
  73. return {
  74. open: false,
  75. showInlineDashboard: false
  76. }
  77. },
  78. methods: {
  79. handleClose() { this.open = false }
  80. },
  81. })
  82. </script>
  83. <style src='@uppy/core/dist/style.css'></style>
  84. <style src='@uppy/dashboard/dist/style.css'></style>
  85. <style src='@uppy/drag-drop/dist/style.css'></style>
  86. <style src='@uppy/progress-bar/dist/style.css'></style>
  87. <style>
  88. #app {
  89. font-family: Avenir, Helvetica, Arial, sans-serif;
  90. -webkit-font-smoothing: antialiased;
  91. -moz-osx-font-smoothing: grayscale;
  92. text-align: center;
  93. color: #2c3e50;
  94. margin-top: 60px;
  95. }
  96. </style>