Skip to content

Commit

Permalink
feat: 元数据
Browse files Browse the repository at this point in the history
  • Loading branch information
Soulter committed Apr 18, 2024
1 parent 17616fe commit a722f7b
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 11 deletions.
4 changes: 2 additions & 2 deletions frontend/src/components/PostCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default {
dialog: false,
reason: "",
filterStatus: ['通过', '拒绝'],
filterStatus: ['通过', '拒绝', '无理由拒绝'],
backgrouldColor: "",
avatarBaseUrl: "http://q1.qlogo.cn/g?b=qq&nk="
}
Expand All @@ -99,7 +99,7 @@ export default {
methods: {
randomColor() {
let colors = ["#FFC107", "#42A5F5", "#9CCC65", "#F06292", "#76FF03", "#9E9E9E", "#8D6E63"]
return colors[Math.floor(Math.random() * colors.length)]
return colors[Math.floor(Math.random() * 100) % colors.length]
},
recall() {
this.$emit('recall', this.post.id)
Expand Down
61 changes: 57 additions & 4 deletions frontend/src/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>

<v-banner style="background: #f8b94c; color: #fff; font-size: 14px; text-align: center;" color="warning" lines="one"
text="📢 投稿前请阅读投稿规则" :stacked="false">
<v-banner v-if="metadata.banner !== ''" style="background: #f8b94c; color: #fff; font-size: 14px; text-align: center;" color="warning" lines="one"
:text="metadata.banner" :stacked="false">
</v-banner>

<!-- input area -->
Expand Down Expand Up @@ -73,12 +73,14 @@
<v-card title="😉 投稿礼仪">

<v-card-text>
<p>0. 有诉求请使用正确的语言合理表达,我们讨厌无实际意义的情绪宣泄。</p>
<!-- <p>0. 有诉求请使用正确的语言合理表达,我们讨厌无实际意义的情绪宣泄。</p>
<p>1. 发表针对特定人的负面信息或发表任何人的照片,不允许匿名,同时要求 QQ 等级高于一个太阳</p>
<p>2. 请勿选择不完全符合内容的标签,否则可能导致封禁</p>
<p>3. 以下情形拒绝:涉及政论、主义、国、党等一切敏感内容</p>
<p>4. 涉及时事敏感话题或有带节奏嫌疑将经过长时间讨论</p>
<p>5. 对于以上所有规则,运营团队保留所有解释权</p>
<p>5. 对于以上所有规则,运营团队保留所有解释权</p> -->

<p v-for="(rule, index) in metadata.post_rules" :key="index">{{ index }}. {{ rule }}</p>
</v-card-text>

<v-card-actions>
Expand Down Expand Up @@ -126,6 +128,24 @@
</v-card>
</v-dialog>

<v-dialog
v-model="showPopupAN"
width="auto"
>
<v-card
:text="metadata.popup_announcement"
title="提示"
>
<template v-slot:actions>
<v-btn
class="ms-auto"
text="1 天内不再提醒"
@click="showPopupAN = false;"
></v-btn>
</template>
</v-card>
</v-dialog>


</div>
<v-snackbar v-model="snackbar.show" :color="snackbar.color" :timeout="snackbar.timeout">
Expand All @@ -147,6 +167,13 @@ export default {
},
data() {
return {
showPopupAN: false,
metadata: {
"banner": "",
"popup_announcement": "",
"post_rules": ""
},
snackbar: {
show: false,
text: '',
Expand Down Expand Up @@ -183,9 +210,35 @@ export default {
mounted() {
this.tokenLogin()
this.getMetadata_("banner")
this.getMetadata_("popup_announcement")
this.getMetadata_("post_rules")
},
methods: {
getMetadata_(key) {
this.$axios.get('/v1/misc/get-metadata?key='+key)
.then(res => {
if (res.data.code === 0) {
if (key == "post_rules") {
this.metadata[key] = JSON.parse(res.data.data.value)
} else {
this.metadata[key] = res.data.data.value
}
let last_an_ts = localStorage.getItem("popup_announcement_ts")
if (key == "popup_announcement" && (last_an_ts == null || new Date().getTime() - last_an_ts > 86400000)) {
this.showPopupAN = true
localStorage.setItem("popup_announcement_ts", new Date().getTime())
}
}
})
.catch(err => {
this.toast('获取失败:' + err)
console.error(err)
})
},
removeImage(index) {
if (index === -1) {
return
Expand Down
60 changes: 56 additions & 4 deletions frontend/src/pages/service.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
</v-dialog>

<h2 style="margin-top: 16px">🤩 推荐网站</h2>
<div class="rect1" style="background-color: #2196F3;">
<div class="rect1" v-for="(service, index) in services" :style="service.color">
<div>
<p style="font-weight: bold; font-size: 16px">🗺️ 桂林中学毕业生去向分布图</p>
<small style="color: #fff; font-size: 13px">https://stumap.idoknow.top</small>
<p style="font-weight: bold; font-size: 16px">{{service.emoji}} {{ service.name }}</p>
<small style="color: #fff; font-size: 13px">{{service.link}}</small>
</div>
<a style="font-size: 16px; cursor:pointer; font-weight: bold;" @click="go('https://stumap.idoknow.top/')">点击查看</a>
<a style="font-size: 16px; cursor:pointer; font-weight: bold;" @click="selectedService=index; showServiceHint=true">点击查看</a>
</div>

<p style="text-align: center; margin-top: 16px; color: #c3c3c3">更多服务正在开发...</p>
Expand All @@ -49,6 +49,29 @@
<v-snackbar v-model="snackbar.show" :color="snackbar.color" :timeout="snackbar.timeout">
{{ snackbar.text }}
</v-snackbar>

<v-dialog
v-model="showServiceHint"
width="auto"
>
<v-card
:text="services[selectedService].toast"
title="提示"
>
<template v-slot:actions>
<v-btn
text="取消"
@click="showServiceHint = false;"
></v-btn>
<v-btn
class="ms-auto"
text="确定"
@click="showServiceHint = false; go(services[selectedService].link)"
></v-btn>
</template>
</v-card>
</v-dialog>

</template>

<script>
Expand All @@ -59,6 +82,9 @@ export default {
},
data() {
return {
showServiceHint: false,
selectedService: -1,
services: [],
password: "",
snackbar: {
show: false,
Expand All @@ -71,9 +97,35 @@ export default {
},
mounted() {
this.getMetadata_('services')
},
methods: {
randomColor() {
let colors = ["#FFC107", "#42A5F5", "#9CCC65", "#F06292", "#76FF03", "#9E9E9E", "#8D6E63"]
return colors[Math.floor(Math.random() * 100) % colors.length]
},
getMetadata_(key) {
this.$axios.get('/v1/misc/get-metadata?key='+key)
.then(res => {
if (res.data.code === 0) {
this.services = JSON.parse(res.data.data.value)
console.log(this.services)
for (let i = 0; i < this.services.length; i++) {
if (!this.services[i].toast) {
this.services[i].toast = '点击确定跳转到 ' + this.services[i].link
}
this.services[i].color = "background-color: " + this.randomColor() + ";"
}
} else {
this.toast('获取服务失败:' + res.data.msg)
}
})
.catch(err => {
this.toast('获取失败:' + err)
console.error(err)
})
},
toast(text, color = 'error') {
this.snackbar.text = text
this.snackbar.color = color
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/pages/world.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default {
avatarUrl: "",
userGroup: "user",
judgePosts: [],
pullLoading: false
pullLoading: false,
}
},
Expand All @@ -110,6 +110,9 @@ export default {
if (p.reason === "") {
p.reason = "无理由"
}
} else if (p.status === "无理由拒绝") {
p.status = 'reject'
p.reason = "无理由"
}
let form = {
Expand Down

0 comments on commit a722f7b

Please sign in to comment.