Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Jan 2, 2019
1 parent 5f3da02 commit 421d9e1
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
71 changes: 71 additions & 0 deletions console/pages/admin/settings/ad/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<template>
<div>
<div class="card fn-clear card__body">

<v-form>
<v-text-field
multi-line
label="Google AdSense ins"
:rules="linkRules"
:counter="255"
v-model="googleAdSenseArticleEmbed"
></v-text-field>
<div class="alert alert--danger" v-show="error">
<v-icon>danger</v-icon>
<span>{{ errorMsg }}</span>
</div>
</v-form>
<v-btn class="fn-right btn--margin-t30 btn--info btn--space" @click="update">
{{ $t('confirm', $store.state.locale) }}
</v-btn>
</div>
</div>
</template>

<script>
import {maxSize} from '~/plugins/validate'
export default {
data () {
return {
googleAdSenseArticleEmbed: '',
linkRules: [
(v) => maxSize.call(this, v, 255)
],
error: false,
errorMsg: ''
}
},
head () {
return {
title: `${this.$t('3rdStatistic', this.$store.state.locale)} - ${this.$store.state.blogTitle}`
}
},
methods: {
async update () {
const responseData = await this.axios.put('/console/settings/ad', {
googleAdSenseArticleEmbed: this.googleAdSenseArticleEmbed
})
if (responseData.code === 0) {
this.$set(this, 'error', false)
this.$set(this, 'errorMsg', '')
this.$store.commit('setSnackBar', {
snackBar: true,
snackMsg: this.$t('setupSuccess', this.$store.state.locale),
snackModify: 'success'
})
} else {
this.$set(this, 'error', true)
this.$set(this, 'errorMsg', responseData.msg)
}
}
},
async mounted () {
const responseData = await this.axios.get('/console/settings/ad')
if (responseData) {
this.$set(this, 'googleAdSenseArticleEmbed', responseData.googleAdSenseArticleEmbed)
}
}
}
</script>
5 changes: 5 additions & 0 deletions console/plugins/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ export const genMenuData = (app, locale) => [
title: app.$t('3rdStatistic', locale),
link: '/admin/settings/3rd-statistic',
role: 2
},
{
title: app.$t('ad', locale),
link: '/admin/settings/ad',
role: 2
}
]
},
Expand Down
1 change: 1 addition & 0 deletions i18n/en_US.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"ad": "advertisement",
"userName": "User Name",
"popularBlog": "Popular Blog",
"createdTime": "Created Time",
Expand Down
1 change: 1 addition & 0 deletions i18n/zh_CN.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"ad": "广告",
"month": "",
"useGitHub": "推荐通过 GitHub 进行",
"userName": "用户名",
Expand Down

0 comments on commit 421d9e1

Please sign in to comment.