Browse Source

example: fix Vue3 example (#3774)

Antoine du Hamel 2 years ago
parent
commit
0d88c8eafc

+ 9 - 0
examples/vue3/README.md

@@ -0,0 +1,9 @@
+# Vue 3 example
+
+To run the example, from the root directory of this repo, run the following commands:
+
+```sh
+cp .env.example .env
+corepack yarn install
+corepack yarn workspace @uppy-example/vue3 dev
+```

+ 10 - 10
examples/vue3/index.html

@@ -1,13 +1,13 @@
 <!DOCTYPE html>
 <html lang="en">
-<head>
-  <meta charset="UTF-8">
-  <link rel="icon" href="/favicon.ico" />
-  <meta name="viewport" content="width=device-width, initial-scale=1.0">
-  <title>Vite App</title>
-</head>
-<body>
-  <div id="app"></div>
-  <script type="module" src="/src/main.js"></script>
-</body>
+  <head>
+    <meta charset="UTF-8" />
+    <link rel="icon" href="/favicon.ico" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>Vite App</title>
+  </head>
+  <body>
+    <div id="app"></div>
+    <script type="module" src="/src/main.js"></script>
+  </body>
 </html>

+ 9 - 6
examples/vue3/package.json

@@ -4,17 +4,20 @@
   "private": true,
   "scripts": {
     "dev": "vite",
-    "build": "vite build"
+    "build": "vite build",
+    "preview": "vite preview --port 5050"
   },
   "dependencies": {
     "@uppy/core": "workspace:*",
+    "@uppy/dashboard": "workspace:*",
+    "@uppy/drag-drop": "workspace:*",
+    "@uppy/progress-bar": "workspace:*",
+    "@uppy/tus": "workspace:*",
     "@uppy/vue": "workspace:*",
-    "core-js": "^3.6.5",
-    "shallow-equal": "^1.2.1",
-    "vue": "^3.0.4"
+    "vue": "^3.2.33"
   },
   "devDependencies": {
-    "@vue/compiler-sfc": "^3.0.4",
-    "vite": "^1.0.0-rc.13"
+    "@vitejs/plugin-vue": "^2.3.1",
+    "vite": "^2.7.1"
   }
 }

+ 20 - 20
examples/vue3/src/App.vue

@@ -1,3 +1,7 @@
+<script setup>
+import { Dashboard, DashboardModal, DragDrop, ProgressBar } from '@uppy/vue'
+</script>
+
 <template>
   <div id="app">
     <!-- <HelloWorld msg="Welcome to Uppy Vue Demo"/> -->
@@ -13,7 +17,7 @@
       />
       Show Dashboard
     </label>
-    <dashboard
+    <Dashboard
       v-if="showInlineDashboard"
       :uppy="uppy"
       :props="{
@@ -23,7 +27,7 @@
     <h2>Modal Dashboard</h2>
     <div>
       <button @click="open = true">Show Dashboard</button>
-    <dashboard-modal
+    <DashboardModal
       :uppy="uppy2" 
       :open="open" 
       :props="{
@@ -33,7 +37,7 @@
     </div>
 
     <h2>Drag Drop Area</h2>
-    <drag-drop 
+    <DragDrop 
       :uppy="uppy"
       :props="{
         locale: {
@@ -46,7 +50,7 @@
     />
 
     <h2>Progress Bar</h2>
-    <progress-bar 
+    <ProgressBar 
       :uppy="uppy"
       :props="{
         hideAfterFinish: false
@@ -57,22 +61,19 @@
 
 <script>
 import Uppy from '@uppy/core'
-// import Tus from '@uppy/tus'
-import { Dashboard, DashboardModal, DragDrop, ProgressBar } from '@uppy/vue'
+import Tus from '@uppy/tus'
+import { defineComponent } from 'vue'
 
-export default {
-  name: 'App',
-  components: {
-    Dashboard,
-    DashboardModal,
-    DragDrop,
-    ProgressBar
-  },
+const {
+  VITE_TUS_ENDPOINT: TUS_ENDPOINT,
+} = import.meta.env
+
+export default defineComponent({
   computed: {
-    uppy: () => new Uppy({ id: 'uppy1', autoProceed: true, debug: true }),
-      // .use(Tus, { endpoint: 'https://tusd.tusdemo.net/files/' }),
+    uppy: () => new Uppy({ id: 'uppy1', autoProceed: true, debug: true })
+      .use(Tus, { endpoint: TUS_ENDPOINT }),
     uppy2: () => new Uppy({ id: 'uppy2', autoProceed: false, debug: true })
-      // .use(Tus, { endpoint: 'https://tusd.tusdemo.net/files/' }),
+      .use(Tus, { endpoint: TUS_ENDPOINT }),
   },
   data () {
     return {
@@ -83,15 +84,14 @@ export default {
   methods: {
     handleClose() { this.open = false }
   },
-  
-}
+})
 </script>
+
 <style src='@uppy/core/dist/style.css'></style> 
 <style src='@uppy/dashboard/dist/style.css'></style> 
 <style src='@uppy/drag-drop/dist/style.css'></style> 
 <style src='@uppy/progress-bar/dist/style.css'></style> 
 
-
 <style>
 #app {
   font-family: Avenir, Helvetica, Arial, sans-serif;

+ 0 - 8
examples/vue3/src/index.css

@@ -1,8 +0,0 @@
-#app {
-  font-family: Avenir, Helvetica, Arial, sans-serif;
-  -webkit-font-smoothing: antialiased;
-  -moz-osx-font-smoothing: grayscale;
-  text-align: center;
-  color: #2c3e50;
-  margin-top: 60px;
-}

+ 0 - 1
examples/vue3/src/main.js

@@ -1,5 +1,4 @@
 import { createApp } from 'vue'
 import App from './App.vue'
-import './index.css'
 
 createApp(App).mount('#app')

+ 7 - 0
examples/vue3/vite.config.js

@@ -0,0 +1,7 @@
+import { defineConfig } from 'vite'
+import vue from '@vitejs/plugin-vue'
+
+// https://vitejs.dev/config/
+export default defineConfig({
+  plugins: [vue()],
+})

File diff suppressed because it is too large
+ 185 - 415
yarn.lock


Some files were not shown because too many files changed in this diff