From e9ff54ecf5c5f4d1445b16f3fe5af0d21d93f28b Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Mon, 16 Sep 2024 08:31:28 -0400 Subject: [PATCH] fix: image loading with access-token --- frontend/src/components/PostCard.vue | 43 ++++++++++++++++++++-------- frontend/src/pages/post.vue | 17 ++++++++++- 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/PostCard.vue b/frontend/src/components/PostCard.vue index ffbe60d..eb7cab3 100644 --- a/frontend/src/components/PostCard.vue +++ b/frontend/src/components/PostCard.vue @@ -1,5 +1,6 @@ {{ post.uin }} - 匿名 - 匿名({{ post.uin }}) + 匿名 + 匿名({{ post.uin }}) {{ post.created_at }} @@ -55,7 +56,9 @@ - {{ post.status }} + {{ + post.status + }} @@ -64,8 +67,7 @@ - + @@ -77,10 +79,9 @@ - + -
+

{{ l.comment }}

时间: {{ l.created_at }}

操作者: {{ l.op }}

@@ -102,7 +103,7 @@ export default { return { dialog: false, reason: "", - + postImageBlobs: [], filterStatus: ['通过', '拒绝', '无理由拒绝'], avatarBaseUrl: "http://q1.qlogo.cn/g?b=qq&nk=", logDialog: false, @@ -115,10 +116,12 @@ export default { '队列中': '#9Cbb85', '已发布': '#42A5F5', '失败': '#aa8888', - } + }, + } }, mounted() { + this.fetchImages() }, methods: { recall() { @@ -138,6 +141,22 @@ export default { this.post.reason = this.reason this.$emit('updateJudgePost', this.post) }, + fetchImages() { + for (let i = 0; i < this.post.images.length; i++) { + this.fetchImageBlob(this.post.images[i]) + } + }, + fetchImageBlob(url) { + this.$axios.get(url, { + responseType: 'blob' + }) + .then(res => { + this.postImageBlobs.push(URL.createObjectURL(res.data)) + }) + .catch(err => { + console.error(err) + }) + }, showLogs() { this.$axios.get('/v1/post/post-log/' + this.post.id) .then(res => { diff --git a/frontend/src/pages/post.vue b/frontend/src/pages/post.vue index ec7cc29..b35ff2e 100644 --- a/frontend/src/pages/post.vue +++ b/frontend/src/pages/post.vue @@ -39,7 +39,7 @@
- { tag.selected = false }) @@ -286,6 +289,7 @@ export default { let url = this.$store.state.base_url + '/v1/post/download-image/' + res.data.data.key console.log(url) this.post.images.push(url) + this.fetchLatestImageToImageBlobs(url) this.loading = false } else { this.toast('上传失败:' + res.data.msg) @@ -300,6 +304,17 @@ export default { } input.click() }, + fetchLatestImageToImageBlobs(url) { + this.$axios.get(url, { + responseType: 'blob' + }) + .then(res => { + this.postImageBlobs.push(URL.createObjectURL(res.data)) + }) + .catch(err => { + console.error(err) + }) + }, selectTag(index) { this.toast("标签功能暂时关闭", "warning") this.tags[index].selected = !this.tags[index].selected