From b10787d23ca645932e89383ebb39402d1eb84700 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 29 Jan 2018 10:47:26 +0300 Subject: [PATCH] first ver --- src/components/attachment/attachment.js | 4 ++ src/components/attachment/attachment.vue | 2 +- src/components/still-image/still-image.js | 29 ++++++++++++ src/components/still-image/still-image.vue | 51 ++++++++++++++++++++++ 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 src/components/still-image/still-image.js create mode 100644 src/components/still-image/still-image.vue diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index 8a2a3826..cd72e571 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -1,3 +1,4 @@ +import StillImage from '../still-image/still-image.vue' import nsfwImage from '../../assets/nsfw.png' import fileTypeService from '../../services/file_type/file_type.service.js' @@ -16,6 +17,9 @@ const Attachment = { img: document.createElement('img') } }, + components: { + StillImage + }, computed: { type () { return fileTypeService.fileType(this.attachment.mimetype) diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index d6a51ffd..2810e205 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -8,7 +8,7 @@ - + diff --git a/src/components/still-image/still-image.js b/src/components/still-image/still-image.js new file mode 100644 index 00000000..fa027bc4 --- /dev/null +++ b/src/components/still-image/still-image.js @@ -0,0 +1,29 @@ +import fileTypeService from '../../services/file_type/file_type.service.js' + +const StillImage = { + props: [ + 'src', + 'referrerpolicy', + 'mimetype' + ], + data () { + return { + hideNsfwLocal: this.$store.state.config.hideNsfw, + } + }, + computed: { + animated () { + return this.mimetype === 'image/gif' + } + }, + methods: { + drawCanvas() { + const canvas = this.$refs.canvas + if (!canvas) return + const ctx = canvas.getContext('2d') + ctx.drawImage(this.$refs.src, 1, 1, canvas.width, canvas.height) + } + } +} + +export default StillImage diff --git a/src/components/still-image/still-image.vue b/src/components/still-image/still-image.vue new file mode 100644 index 00000000..fa086e51 --- /dev/null +++ b/src/components/still-image/still-image.vue @@ -0,0 +1,51 @@ + + + + +