11<template >
22 <div class =" share" v-if =" loaded" >
3- <a target =" _blank" :href =" link" >
4- <div class =" share__box" >
5- <div class =" share__box__download" v-if =" file.isDir" >{{ $t('download.downloadFolder') }}</div >
6- <div class =" share__box__download" v-else >{{ $t('download.downloadFile') }}</div >
7- <div class =" share__box__info" >
8- <svg v-if =" file.isDir" fill =" #40c4ff" height =" 150" viewBox =" 0 0 24 24" width =" 150" xmlns =" http://www.w3.org/2000/svg" >
9- <path d =" M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z" />
10- <path d =" M0 0h24v24H0z" fill =" none" />
11- </svg >
12- <svg v-else fill =" #40c4ff" height =" 150" viewBox =" 0 0 24 24" width =" 150" xmlns =" http://www.w3.org/2000/svg" >
13- <path d =" M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z" />
14- <path d =" M0 0h24v24H0z" fill =" none" />
15- </svg >
16- <h1 class =" share__box__title" >{{ file.name }}</h1 >
3+ <div class =" share__box share__box__info" >
4+ <div class =" share__box__header" >
5+ {{ file.isDir ? $t('download.downloadFolder') : $t('download.downloadFile') }}
6+ </div >
7+ <div class =" share__box__element share__box__center share__box__icon" >
8+ <i class =" material-icons" >{{ file.isDir ? 'folder' : 'insert_drive_file'}}</i >
9+ </div >
10+ <div class =" share__box__element" >
11+ <strong >{{ $t('prompts.displayName') }}</strong > {{ file.name }}
12+ </div >
13+ <div class =" share__box__element" >
14+ <strong >{{ $t('prompts.lastModified') }}:</strong > {{ humanTime }}
15+ </div >
16+ <div class =" share__box__element" >
17+ <strong >{{ $t('prompts.size') }}:</strong > {{ humanSize }}
18+ </div >
19+ <div class =" share__box__element share__box__center" >
20+ <a target =" _blank" :href =" link" class =" button button--flat" >{{ $t('buttons.download') }}</a >
21+ </div >
22+ <div class =" share__box__element share__box__center" >
1723 <qrcode-vue :value =" fullLink" size =" 200" level =" M" ></qrcode-vue >
1824 </div >
25+ </div >
26+ <div v-if =" file.isDir" class =" share__box share__box__items" >
27+ <div class =" share__box__header" v-if =" file.isDir" >
28+ {{ $t('files.files') }}
29+ </div >
30+ <div id =" listing" class =" list" >
31+ <div class =" item" v-for =" (item) in file.items.slice(0, this.showLimit)" :key =" base64(item.name)" >
32+ <div >
33+ <i class =" material-icons" >{{ item.isDir ? 'folder' : (item.type==='image') ? 'insert_photo' : 'insert_drive_file' }}</i >
34+ </div >
35+ <div >
36+ <p class =" name" >{{ item.name }}</p >
37+ </div >
38+ </div >
39+ <div v-if =" file.items.length > showLimit" class =" item" >
40+ <div >
41+ <p class =" name" > + {{ file.items.length - showLimit }} </p >
42+ </div >
43+ </div >
1944 </div >
20- </a >
45+ </div >
2146 </div >
2247</template >
2348
2449<script >
2550import { share as api } from ' @/api'
2651import { baseURL } from ' @/utils/constants'
52+ import filesize from ' filesize'
53+ import moment from ' moment'
2754import QrcodeVue from ' qrcode.vue'
2855
2956export default {
@@ -34,7 +61,8 @@ export default {
3461 data : () => ({
3562 loaded: false ,
3663 notFound: false ,
37- file: null
64+ file: null ,
65+ showLimit: 500
3866 }),
3967 watch: {
4068 ' $route' : ' fetchData'
@@ -52,8 +80,21 @@ export default {
5280 fullLink : function () {
5381 return window .location .origin + this .link
5482 },
83+ humanSize : function () {
84+ if (this .file .isDir ) {
85+ return this .file .items .length
86+ }
87+
88+ return filesize (this .file .size )
89+ },
90+ humanTime : function () {
91+ return moment (this .file .modified ).fromNow ()
92+ }
5593 },
5694 methods: {
95+ base64 : function (name ) {
96+ return window .btoa (unescape (encodeURIComponent (name)))
97+ },
5798 fetchData : async function () {
5899 try {
59100 this .file = await api .getHash (this .hash )
0 commit comments