Skip to content

Commit

Permalink
feat: 添加针对墙主的公告显示功能
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Oct 22, 2024
1 parent 34d7f72 commit f918f01
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions frontend/src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default {
this.$store.commit('initMetadata', 'popup_announcement')
this.$store.commit('initMetadata', 'post_rules')
this.$store.commit('initMetadata', 'beianhao')
this.$store.commit('fetchPublicObject')
console.log(this.$store.state.metadata)
console.log(this.$store.state.account)
},
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/pages/post.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
<h2 id="mt" style="padding: 8px 16px; font-family: Lilita One; display: inline-block">Campux</h2>
<span>{{ $store.state.metadata.brand }}</span>
</div>
<v-banner v-if="($store.state.account.userGroup === 'admin') && $store.state.publicObject != {} && $store.state.publicObject.announcement.admin.length > 0 && ($store.state.publicObject.announcement.admin[0].versions.includes($store.state.version))"
:style="{ background: $store.state.publicObject.announcement.admin[0].color.background, color: $store.state.publicObject.announcement.admin[0].color.text, fontSize: '14px', textAlign: 'center' }"
lines="one">
<h3 style="margin-right: 8px;">{{ $store.state.publicObject.announcement.admin[0].title }}</h3>
<div style="margin-right: 3px;">{{ $store.state.publicObject.announcement.admin[0].content }}</div>
<a v-if="$store.state.publicObject.announcement.admin[0].link.url !== ''" :href="$store.state.publicObject.announcement.admin[0].link.url"
style="color: blue; font-weight: bold;"
target="_blank">{{ $store.state.publicObject.announcement.admin[0].link.text }}</a>
</v-banner>
<v-banner v-if="$store.state.metadata.banner !== ''"
style="background: #f8b94c; color: #fff; font-size: 14px; text-align: center;" color="warning" lines="one"
:text="$store.state.metadata.banner" :stacked="false">
Expand Down Expand Up @@ -242,7 +251,7 @@ export default {
// 将images中的baseurl去掉
this.post.images = this.post.images.map(image => {
return image.replace(this.$store.state.base_url + "/v1/post/download-image/", '')
.replace("?preview=1", "")
.replace("?preview=1", "")
})
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ export default createStore({
}
},
authMode: "login",
publicObject: {
"announcement": {
"admin": []
}
}
},
mutations: {
initMetadata(state, key) {
Expand All @@ -60,6 +65,17 @@ export default createStore({
})
}
},
fetchPublicObject(state) {
axios.get(
"https://campux.idoknow.top/object.json",
{withCredentials: false}
).then(res => {
if (res.status == 200) {
state.publicObject = res.data
console.log(state.publicObject)
}
})
},
getVersion(state) {
axios.get(this.state.base_url + '/v1/misc/get-version')
.then(res => {
Expand Down

0 comments on commit f918f01

Please sign in to comment.