feat: add image thumbnails support (#980)

* set max image preview size to 1080x1080px
This commit is contained in:
monkeyWie
2020-06-25 15:37:13 +08:00
committed by GitHub
parent 4c20772e11
commit 6b0d49b1fc
8 changed files with 137 additions and 9 deletions

View File

@@ -13,7 +13,8 @@
:aria-label="name"
:aria-selected="isSelected">
<div>
<i class="material-icons">{{ icon }}</i>
<img v-if="type==='image'" :src="thumbnailUrl">
<i v-else class="material-icons">{{ icon }}</i>
</div>
<div>
@@ -30,6 +31,7 @@
</template>
<script>
import { baseURL } from '@/utils/constants'
import { mapMutations, mapGetters, mapState } from 'vuex'
import filesize from 'filesize'
import moment from 'moment'
@@ -44,7 +46,7 @@ export default {
},
props: ['name', 'isDir', 'url', 'type', 'size', 'modified', 'index'],
computed: {
...mapState(['selected', 'req', 'user']),
...mapState(['selected', 'req', 'user', 'jwt']),
...mapGetters(['selectedCount']),
isSelected () {
return (this.selected.indexOf(this.index) !== -1)
@@ -69,6 +71,10 @@ export default {
}
return true
},
thumbnailUrl () {
const path = this.url.replace(/^\/files\//, '')
return `${baseURL}/api/preview/thumb/${path}?auth=${this.jwt}&inline=true`
}
},
methods: {