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 c7901ea commit 2e13a54
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 9 deletions.
47 changes: 38 additions & 9 deletions site/components/CreateTopicBtn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
</slot>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="tweet" icon="iconfont icon-tweet2"
>发动态</el-dropdown-item
>
<el-dropdown-item command="topic" icon="iconfont icon-topic"
>发帖子</el-dropdown-item
>
<el-dropdown-item command="article" icon="iconfont icon-article"
>发文章</el-dropdown-item
<el-dropdown-item
v-for="(item, i) in modules"
:key="i"
:command="item.command"
:icon="item.icon"
>{{ item.name }}</el-dropdown-item
>
</el-dropdown-menu>
</el-dropdown>
Expand All @@ -37,7 +35,38 @@ export default {
data() {
return {}
},
computed: {},
computed: {
config() {
return this.$store.state.config.config
},
modules() {
const modules = []
for (let i = 0; i < this.config.modules.length; i++) {
const item = this.config.modules[i]
if (item.enabled) {
const command = item.module
let icon = ''
let name = ''
if (item.module === 'tweet') {
icon = 'iconfont icon-tweet2'
name = '发动态'
} else if (item.module === 'topic') {
icon = 'iconfont icon-topic'
name = '发帖子'
} else if (item.module === 'article') {
icon = 'iconfont icon-article'
name = '发文章'
}
modules.push({
command,
icon,
name,
})
}
}
return modules
},
},
methods: {
handlePostCommand(cmd) {
if (cmd === 'topic') {
Expand Down
24 changes: 24 additions & 0 deletions site/store/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,28 @@ export const getters = {
siteKeywords(state) {
return state.config.siteKeywords || ''
},
isEnabledTweet(state) {
for (let i = 0; i < state.config.modules.length; i++) {
if (state.config.modules[i].module === 'tweet') {
return state.config.modules[i].enabled
}
}
return true
},
isEnabledTopic(state) {
for (let i = 0; i < state.config.modules.length; i++) {
if (state.config.modules[i].module === 'topic') {
return state.config.modules[i].enabled
}
}
return true
},
isEnabledArticle(state) {
for (let i = 0; i < state.config.modules.length; i++) {
if (state.config.modules[i].module === 'article') {
return state.config.modules[i].enabled
}
}
return true
},
}

0 comments on commit 2e13a54

Please sign in to comment.