Skip to content

Commit

Permalink
perf: 投稿
Browse files Browse the repository at this point in the history
  • Loading branch information
Soulter committed Apr 20, 2024
1 parent 31dc0e6 commit 0939772
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 10 deletions.
3 changes: 2 additions & 1 deletion frontend/src/components/PostCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
</template>

<v-list-item-title v-if="!post.anon">{{ post.uin }}</v-list-item-title>
<v-list-item-title v-else>匿名</v-list-item-title>
<v-list-item-title v-if="post.anon && typ==='self'">匿名</v-list-item-title>
<v-list-item-title v-if="post.anon && typ!=='self'">匿名({{ post.uin }})</v-list-item-title>

<v-list-item-subtitle>{{ post.created_at }}</v-list-item-subtitle>

Expand Down
45 changes: 38 additions & 7 deletions frontend/src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
:text="metadata.banner" :stacked="false">
</v-banner>

<!-- input area -->
<v-alert
style="margin: 16px;"
v-if="isPending"
density="compact"
text="你当前有一条待审核的投稿,请等待审核后再来投稿。"
title="稿件待审核"
type="warning"
></v-alert>

<div style="display: flex; padding: 16px">
<v-dialog max-width="500">
<template v-slot:activator="{ props: activatorProps }">
Expand All @@ -26,13 +34,10 @@
</v-card>
</template>
</v-dialog>
<textarea style="" name="textarea" v-model="post.text" placeholder="有什么新鲜事?!" class="post"></textarea>
<textarea :readonly="isPending" style="" name="textarea" v-model="post.text" placeholder="有什么新鲜事?!" class="post"></textarea>
</div>

<!-- 自动换行 -->
<div style="margin-left: 16px; display: flex; flex-wrap: wrap;">
<!-- 图片上传 -->
<!-- 长按图片可删除 -->
<img v-for="(image, index) in post.images" :src="image" :key="index" width="70" height="70" style="margin-right: 8px; margin-top:4px; border-radius: 10px;" @click="selectedIndex = index; showDeleteImageDialog = true">
<svg style="margin-top: 8px" @click="selectImage" t="1712897639010" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
p-id="1448" width="70" height="70">
Expand Down Expand Up @@ -86,7 +91,7 @@
</v-dialog>

<div style="display: flex; align-items: center;">
<button @click="letsPost" class="postbtn" style="margin: 8px; margin-top: 16px">
<button v-if="!isPending" @click="letsPost" class="postbtn" style="margin: 8px; margin-top: 16px">
<span> 投稿
</span>
</button>
Expand Down Expand Up @@ -193,16 +198,18 @@ export default {
selected: false
}
],
avatarUrl: 'http://q1.qlogo.cn/g?b=qq&nk=905617992&s=100',
avatarUrl: '',
uin: '',
loading: false,
showDeleteImageDialog: false,
selectedIndex: -1,
isPending: false
}
},
mounted() {
this.tokenLogin()
this.getPosts()
this.getMetadata_("banner")
this.getMetadata_("popup_announcement")
this.getMetadata_("post_rules")
Expand Down Expand Up @@ -232,6 +239,29 @@ export default {
})
},
getPosts() {
let filter = {
"status": "pending_approval",
"time_order": 1,
"page": 1,
"page_size": 1
}
this.$axios.post('/v1/post/get-self-posts', filter)
.then((response) => {
if (response.data.code === 0) {
let p = response.data.data.list
if (p !== null) {
this.isPending = true
}
} else {
this.toast(response.data.msg)
}
})
.catch((error) => {
console.log(error)
})
},
removeImage(index) {
if (index === -1) {
return
Expand Down Expand Up @@ -269,6 +299,7 @@ export default {
tag.selected = false
})
this.loading = false
this.getPosts()
} else {
this.toast('投稿失败:' + res.data.msg)
}
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/pages/world.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<v-tab v-if="userGroup === 'admin'" value="3">审核稿件</v-tab>
</v-tabs>

<v-window v-model="tab">
<v-window v-model="tab" disabled>
<v-window-item value="1" style="overflow-y: scroll">
<div style="padding: 16px;">
<v-select v-model="filter.status" label="按条件筛选" :items="filterStatus" variant="solo"
Expand Down Expand Up @@ -96,8 +96,18 @@ export default {
}
},
// watch tab
watch: {
tab: function (val) {
if (val === '1') {
this.getPosts()
} else if (val === '3') {
this.getJudgePosts()
}
}
},
mounted() {
this.getPosts()
this.tokenLogin()
},
Expand Down

0 comments on commit 0939772

Please sign in to comment.