5050</template >
5151
5252<script setup>
53- import { computed , ref , watch } from " vue"
53+ import { computed , ref , watch , onBeforeUnmount } from " vue"
5454import " @uppy/core/dist/style.css"
5555import " @uppy/dashboard/dist/style.css"
5656import " @uppy/image-editor/dist/style.css"
@@ -77,7 +77,7 @@ const store = useStore()
7777const route = useRoute ()
7878const router = useRouter ()
7979const { gid , sid , cid } = useCidReq ()
80- const { onCreated , onError } = useUpload ()
80+ const { onCreated } = useUpload ()
8181const { t } = useI18n ()
8282const allowedFiletypes = [" file" , " video" , " certificate" ]
8383const filetypeQuery = route .query .filetype
@@ -100,8 +100,8 @@ const resourceLinkList = ref(
100100 ]),
101101)
102102
103- let uppy = ref ( )
104- uppy . value = new Uppy ( )
103+ const uppy = new Uppy ({ autoProceed : false } )
104+ . use (Webcam )
105105 .use (ImageEditor, {
106106 cropperOptions: {
107107 viewMode: 1 ,
@@ -126,11 +126,10 @@ uppy.value = new Uppy()
126126 formData: true ,
127127 fieldName: " uploadFile" ,
128128 })
129- .on (" upload-success" , (item , response ) => {
129+ .on (" upload-success" , (_item , response ) => {
130130 onCreated (response .body )
131131 })
132132 .on (" complete" , () => {
133- console .log (" Upload complete, sending message..." )
134133 const parentNodeId = parentResourceNodeId .value
135134 localStorage .setItem (" isUploaded" , " true" )
136135 localStorage .setItem (" uploadParentNodeId" , parentNodeId)
@@ -147,7 +146,7 @@ uppy.value = new Uppy()
147146 }, 2000 )
148147 })
149148
150- uppy .value . setMeta ({
149+ uppy .setMeta ({
151150 filetype,
152151 parentResourceNodeId: parentResourceNodeId .value ,
153152 resourceLinkList: resourceLinkList .value ,
@@ -156,31 +155,27 @@ uppy.value.setMeta({
156155})
157156
158157if (filetype === " certificate" ) {
159- uppy .value . opts . restrictions . allowedFileTypes = [" .html" ]
158+ uppy .setOptions ({ restrictions: { allowedFileTypes : [" .html" ] } })
160159} else if (filetype === " video" ) {
161- uppy .value . opts . restrictions . allowedFileTypes = [" video/*" ]
162- } else if (filetype === " file " ) {
163- uppy .value . opts . restrictions . allowedFileTypes = null
160+ uppy .setOptions ({ restrictions: { allowedFileTypes : [" video/*" ] } })
161+ } else {
162+ uppy .setOptions ({ restrictions: { allowedFileTypes : null } })
164163}
165164
166165watch (isUncompressZipEnabled, () => {
167- uppy .value .setOptions ({
168- meta: {
169- isUncompressZipEnabled: isUncompressZipEnabled .value ,
170- },
166+ uppy .setOptions ({
167+ meta: { isUncompressZipEnabled: isUncompressZipEnabled .value },
171168 })
172169})
173170
174171watch (fileExistsOption, () => {
175- uppy .value .setOptions ({
176- meta: {
177- fileExistsOption: fileExistsOption .value ,
178- },
172+ uppy .setOptions ({
173+ meta: { fileExistsOption: fileExistsOption .value },
179174 })
180175})
181176
182177function back () {
183- let queryParams = { cid, sid, gid, filetype, tab: route .query .tab }
178+ const queryParams = { cid, sid, gid, filetype, tab: route .query .tab }
184179 if (route .query .tab ) {
185180 router .push ({
186181 name: " FileManagerList" ,
@@ -191,4 +186,8 @@ function back() {
191186 router .back ()
192187 }
193188}
189+
190+ onBeforeUnmount (() => {
191+ try { uppy .close () } catch {}
192+ })
194193 </script >
0 commit comments