Skip to content

Commit

Permalink
前端发帖页面根据按钮配置进行控制是否可用
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbbbbbbbbbbba committed Nov 10, 2022
1 parent 2e13a54 commit e76df10
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
17 changes: 9 additions & 8 deletions site/layouts/error.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
<img src="~/assets/images/logo.png" style="max-width: 100px" />
</div>
<div class="description">
<span v-if="error.statusCode === 404">{{
error.message ? error.message : '页面没找到'
}}</span>
<span v-if="error.statusCode === 403">{{
error.message ? error.message : 'forbidden'
}}</span>
<span v-else>{{ error.statusCode }} 页面异常</span>
<div v-if="error.message">
{{ error.message }}
</div>
<template v-else>
<div v-if="error.statusCode === 404">页面没找到</div>
<div v-if="error.statusCode === 403">forbidden</div>
<div v-else>{{ error.statusCode }} 异常</div>
</template>
</div>
<div class="report">
<nuxt-link to="/topic/create" target="_blank"
Expand Down Expand Up @@ -44,7 +45,7 @@ export default {
.description {
margin-top: 30px;
span {
div {
font-size: 18px;
font-weight: bold;
line-height: 22px;
Expand Down
11 changes: 11 additions & 0 deletions site/pages/article/create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@
<script>
export default {
middleware: 'authenticated',
asyncData({ store, error }) {
if (!store.getters['config/isEnabledArticle']) {
// 发帖子
error({
statusCode: 404,
message: '已关闭文章功能',
})
return
}
return {}
},
data() {
return {
publishing: false, // 当前是否正处于发布中...
Expand Down
18 changes: 17 additions & 1 deletion site/pages/topic/create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<script>
export default {
middleware: 'authenticated',
async asyncData({ $axios, query, store }) {
async asyncData({ $axios, query, store, error }) {
// 节点
const nodes = await $axios.get('/api/topic/nodes')
Expand All @@ -139,6 +139,22 @@ export default {
const type = parseInt(query.type || 0) || 0
if (type === 0 && !store.getters['config/isEnabledTopic']) {
// 发帖子
error({
statusCode: 404,
message: '已关闭帖子功能',
})
return
} else if (type === 1 && !store.getters['config/isEnabledTweet']) {
// 发动态
error({
statusCode: 404,
message: '已关闭动态功能',
})
return
}
return {
nodes,
postForm: {
Expand Down

0 comments on commit e76df10

Please sign in to comment.