Cache options by vuex.

pull/40/head
ruibaby 2019-09-03 16:58:30 +08:00
parent 77c826ebe8
commit ec1a661177
19 changed files with 122 additions and 137 deletions

View File

@ -63,7 +63,6 @@
import HeaderComment from './HeaderComment' import HeaderComment from './HeaderComment'
import SettingDrawer from '@/components/SettingDrawer/SettingDrawer' import SettingDrawer from '@/components/SettingDrawer/SettingDrawer'
import { mapActions, mapGetters } from 'vuex' import { mapActions, mapGetters } from 'vuex'
import optionApi from '@/api/option'
export default { export default {
name: 'UserMenu', name: 'UserMenu',
@ -73,19 +72,14 @@ export default {
}, },
data() { data() {
return { return {
optionVisible: true, optionVisible: true
options: [],
keys: ['blog_url']
} }
}, },
mounted() { mounted() {
this.optionVisible = this.$refs.drawer.visible this.optionVisible = this.$refs.drawer.visible
}, },
created() {
this.loadOptions()
},
computed: { computed: {
...mapGetters(['user']) ...mapGetters(['user', 'options'])
}, },
methods: { methods: {
...mapActions(['logout']), ...mapActions(['logout']),
@ -114,11 +108,6 @@ export default {
showOptionModal() { showOptionModal() {
this.optionVisible = this.$refs.drawer.visible this.optionVisible = this.$refs.drawer.visible
this.$refs.drawer.toggle() this.$refs.drawer.toggle()
},
loadOptions() {
optionApi.listAll(this.keys).then(response => {
this.options = response.data.data
})
} }
} }
} }

View File

@ -11,7 +11,8 @@ import {
DEFAULT_FIXED_SIDEMENU, DEFAULT_FIXED_SIDEMENU,
DEFAULT_CONTENT_WIDTH_TYPE, DEFAULT_CONTENT_WIDTH_TYPE,
USER, USER,
API_URL API_URL,
OPTIONS
} from '@/store/mutation-types' } from '@/store/mutation-types'
import config from '@/config/defaultSettings' import config from '@/config/defaultSettings'
@ -27,6 +28,6 @@ export default function Initializer() {
store.commit('SET_TOKEN', Vue.ls.get(ACCESS_TOKEN)) store.commit('SET_TOKEN', Vue.ls.get(ACCESS_TOKEN))
store.commit('SET_USER', Vue.ls.get(USER)) store.commit('SET_USER', Vue.ls.get(USER))
store.commit('SET_API_URL', Vue.ls.get(API_URL)) store.commit('SET_API_URL', Vue.ls.get(API_URL))
store.commit('SET_OPTIONS', Vue.ls.get(OPTIONS))
// last step // last step
} }

View File

@ -12,7 +12,8 @@ const getters = {
return state.app.apiUrl return state.app.apiUrl
} }
return `${window.location.protocol}//${window.location.host}` return `${window.location.protocol}//${window.location.host}`
} },
options: state => state.option.options
} }
export default getters export default getters

View File

@ -4,6 +4,7 @@ import Vuex from 'vuex'
import app from './modules/app' import app from './modules/app'
import user from './modules/user' import user from './modules/user'
import permission from './modules/permission' import permission from './modules/permission'
import option from './modules/option'
import getters from './getters' import getters from './getters'
Vue.use(Vuex) Vue.use(Vuex)
@ -12,7 +13,8 @@ export default new Vuex.Store({
modules: { modules: {
app, app,
user, user,
permission permission,
option
}, },
state: { state: {

View File

@ -0,0 +1,36 @@
import Vue from 'vue'
import {
OPTIONS
} from '@/store/mutation-types'
import optionApi from '@/api/option'
const keys = ['blog_url']
const option = {
state: {
options: []
},
mutations: {
SET_OPTIONS: (state, options) => {
Vue.ls.set(OPTIONS, options)
state.options = options
}
},
actions: {
loadOptions({
commit
}) {
return new Promise((resolve, reject) => {
optionApi
.listAll(keys)
.then(response => {
commit('SET_OPTIONS', response.data.data)
resolve(response)
})
.catch(error => {
reject(error)
})
})
}
}
}
export default option

View File

@ -1,5 +1,8 @@
import Vue from 'vue' import Vue from 'vue'
import { ACCESS_TOKEN, USER } from '@/store/mutation-types' import {
ACCESS_TOKEN,
USER
} from '@/store/mutation-types'
import adminApi from '@/api/admin' import adminApi from '@/api/admin'
import userApi from '@/api/user' import userApi from '@/api/user'
@ -16,7 +19,9 @@ const user = {
Vue.ls.set(ACCESS_TOKEN, token) Vue.ls.set(ACCESS_TOKEN, token)
state.token = token state.token = token
}, },
SET_NAME: (state, { name }) => { SET_NAME: (state, {
name
}) => {
state.name = name state.name = name
}, },
SET_AVATAR: (state, avatar) => { SET_AVATAR: (state, avatar) => {
@ -35,7 +40,9 @@ const user = {
} }
}, },
actions: { actions: {
loadUser({ commit }) { loadUser({
commit
}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
userApi userApi
.getProfile() .getProfile()
@ -48,7 +55,12 @@ const user = {
}) })
}) })
}, },
login({ commit }, { username, password }) { login({
commit
}, {
username,
password
}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
adminApi adminApi
.login(username, password) .login(username, password)
@ -64,7 +76,9 @@ const user = {
}) })
}) })
}, },
logout({ commit }) { logout({
commit
}) {
return new Promise(resolve => { return new Promise(resolve => {
commit('CLEAR_TOKEN') commit('CLEAR_TOKEN')
adminApi adminApi
@ -77,7 +91,9 @@ const user = {
}) })
}) })
}, },
refreshToken({ commit }, refreshToken) { refreshToken({
commit
}, refreshToken) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
adminApi adminApi
.refreshToken(refreshToken) .refreshToken(refreshToken)

View File

@ -9,6 +9,7 @@ export const DEFAULT_FIXED_HEADER_HIDDEN = 'DEFAULT_FIXED_HEADER_HIDDEN'
export const DEFAULT_CONTENT_WIDTH_TYPE = 'DEFAULT_CONTENT_WIDTH_TYPE' export const DEFAULT_CONTENT_WIDTH_TYPE = 'DEFAULT_CONTENT_WIDTH_TYPE'
export const USER = 'USER' export const USER = 'USER'
export const API_URL = 'API_URL' export const API_URL = 'API_URL'
export const OPTIONS = 'OPTIONS'
export const CONTENT_WIDTH_TYPE = { export const CONTENT_WIDTH_TYPE = {
Fluid: 'Fluid', Fluid: 'Fluid',

View File

@ -126,8 +126,8 @@
</template> </template>
<script> <script>
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import { mapGetters } from 'vuex'
import commentApi from '@/api/comment' import commentApi from '@/api/comment'
import optionApi from '@/api/option'
export default { export default {
name: 'CommentDetail', name: 'CommentDetail',
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
@ -166,7 +166,9 @@ export default {
}, },
created() { created() {
this.loadSkeleton() this.loadSkeleton()
this.loadOptions() },
computed: {
...mapGetters(['options'])
}, },
watch: { watch: {
visible: function(newValue, oldValue) { visible: function(newValue, oldValue) {
@ -184,11 +186,6 @@ export default {
this.detailLoading = false this.detailLoading = false
}, 500) }, 500)
}, },
loadOptions() {
optionApi.listAll(this.keys).then(response => {
this.options = response.data.data
})
},
handleEditComment() { handleEditComment() {
this.editable = true this.editable = true
}, },

View File

@ -262,8 +262,8 @@
</div> </div>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'
import commentApi from '@/api/comment' import commentApi from '@/api/comment'
import optionApi from '@/api/option'
import marked from 'marked' import marked from 'marked'
import CommentDetail from './CommentDetail' import CommentDetail from './CommentDetail'
const postColumns = [ const postColumns = [
@ -376,14 +376,11 @@ export default {
replyComment: {}, replyComment: {},
loading: false, loading: false,
commentStatus: commentApi.commentStatus, commentStatus: commentApi.commentStatus,
options: [],
keys: ['blog_url'],
commentDetailVisible: false commentDetailVisible: false
} }
}, },
created() { created() {
this.loadComments() this.loadComments()
this.loadOptions()
}, },
computed: { computed: {
formattedComments() { formattedComments() {
@ -392,7 +389,8 @@ export default {
comment.content = marked(comment.content, { sanitize: true }) comment.content = marked(comment.content, { sanitize: true })
return comment return comment
}) })
} },
...mapGetters(['options'])
}, },
methods: { methods: {
loadComments() { loadComments() {
@ -410,11 +408,6 @@ export default {
this.queryParam.page = 0 this.queryParam.page = 0
this.loadComments() this.loadComments()
}, },
loadOptions() {
optionApi.listAll(this.keys).then(response => {
this.options = response.data.data
})
},
handleEditStatusClick(commentId, status) { handleEditStatusClick(commentId, status) {
commentApi.updateStatus(this.type, commentId, status).then(response => { commentApi.updateStatus(this.type, commentId, status).then(response => {
this.$message.success('操作成功!') this.$message.success('操作成功!')

View File

@ -331,15 +331,15 @@
import { PageView } from '@/layouts' import { PageView } from '@/layouts'
import AnalysisCard from './components/AnalysisCard' import AnalysisCard from './components/AnalysisCard'
import RecentCommentTab from './components/RecentCommentTab' import RecentCommentTab from './components/RecentCommentTab'
import countTo from 'vue-count-to'
import UploadPhoto from '../../components/Upload/UploadPhoto.vue'
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import optionApi from '@/api/option' import { mapGetters } from 'vuex'
import postApi from '@/api/post' import postApi from '@/api/post'
import logApi from '@/api/log' import logApi from '@/api/log'
import adminApi from '@/api/admin' import adminApi from '@/api/admin'
import journalApi from '@/api/journal' import journalApi from '@/api/journal'
import countTo from 'vue-count-to'
import UploadPhoto from '../../components/Upload/UploadPhoto.vue'
export default { export default {
name: 'Dashboard', name: 'Dashboard',
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
@ -371,8 +371,6 @@ export default {
}, },
journalPhotos: [], // journalPhotos: [], //
logs: [], logs: [],
options: [],
keys: ['blog_url'],
logPagination: { logPagination: {
page: 1, page: 1,
size: 50, size: 50,
@ -385,11 +383,6 @@ export default {
this.getCounts() this.getCounts()
this.listLatestPosts() this.listLatestPosts()
this.listLatestLogs() this.listLatestLogs()
this.loadOptions()
// this.interval = setInterval(() => {
// this.getCounts()
// }, 5000)
}, },
computed: { computed: {
formattedPostData() { formattedPostData() {
@ -410,7 +403,8 @@ export default {
log.type = this.logType[log.type].text log.type = this.logType[log.type].text
return log return log
}) })
} },
...mapGetters(['options'])
}, },
beforeRouteEnter(to, from, next) { beforeRouteEnter(to, from, next) {
next(vm => { next(vm => {
@ -440,11 +434,6 @@ export default {
} }
this.journalPhotos.push(photo) this.journalPhotos.push(photo)
}, },
loadOptions() {
optionApi.listAll(this.keys).then(response => {
this.options = response.data.data
})
},
listLatestPosts() { listLatestPosts() {
postApi.listLatest(5).then(response => { postApi.listLatest(5).then(response => {
this.postData = response.data.data this.postData = response.data.data

View File

@ -54,8 +54,8 @@
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'
import commentApi from '@/api/comment' import commentApi from '@/api/comment'
import optionApi from '@/api/option'
import marked from 'marked' import marked from 'marked'
export default { export default {
@ -73,9 +73,7 @@ export default {
data() { data() {
return { return {
comments: [], comments: [],
loading: false, loading: false
options: [],
keys: ['blog_url']
} }
}, },
computed: { computed: {
@ -84,18 +82,13 @@ export default {
comment.content = marked(comment.content, { sanitize: true }) comment.content = marked(comment.content, { sanitize: true })
return comment return comment
}) })
} },
...mapGetters(['options'])
}, },
created() { created() {
this.loadComments() this.loadComments()
this.loadOptions()
}, },
methods: { methods: {
loadOptions() {
optionApi.listAll(this.keys).then(response => {
this.options = response.data.data
})
},
loadComments() { loadComments() {
this.loading = true this.loading = true
commentApi.latestComment(this.type, 5, 'PUBLISHED').then(response => { commentApi.latestComment(this.type, 5, 'PUBLISHED').then(response => {

View File

@ -221,10 +221,10 @@
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import AttachmentSelectDrawer from '../../attachment/components/AttachmentSelectDrawer' import AttachmentSelectDrawer from '../../attachment/components/AttachmentSelectDrawer'
import FooterToolBar from '@/components/FooterToolbar' import FooterToolBar from '@/components/FooterToolbar'
import { mapGetters } from 'vuex'
import Verte from 'verte' import Verte from 'verte'
import 'verte/dist/verte.css' import 'verte/dist/verte.css'
import themeApi from '@/api/theme' import themeApi from '@/api/theme'
import optionApi from '@/api/option'
export default { export default {
name: 'ThemeSetting', name: 'ThemeSetting',
mixins: [mixin, mixinDevice], mixins: [mixin, mixinDevice],
@ -249,8 +249,6 @@ export default {
}, },
viewMode: false, viewMode: false,
formColValue: 12, formColValue: 12,
options: [],
keys: ['blog_url'],
clientHeight: document.documentElement.clientHeight clientHeight: document.documentElement.clientHeight
} }
}, },
@ -272,7 +270,6 @@ export default {
created() { created() {
this.loadSkeleton() this.loadSkeleton()
this.initData() this.initData()
this.loadOptions()
}, },
watch: { watch: {
visible: function(newValue, oldValue) { visible: function(newValue, oldValue) {
@ -281,6 +278,9 @@ export default {
} }
} }
}, },
computed: {
...mapGetters(['options'])
},
methods: { methods: {
loadSkeleton() { loadSkeleton() {
this.settingLoading = true this.settingLoading = true
@ -288,11 +288,6 @@ export default {
this.settingLoading = false this.settingLoading = false
}, 500) }, 500)
}, },
loadOptions() {
optionApi.listAll(this.keys).then(response => {
this.options = response.data.data
})
},
initData() { initData() {
this.settingLoading = true this.settingLoading = true

View File

@ -1,6 +1,9 @@
<template> <template>
<div class="page-header-index-wide"> <div class="page-header-index-wide">
<a-card :bordered="false" :bodyStyle="{ padding: '16px' }"> <a-card
:bordered="false"
:bodyStyle="{ padding: '16px' }"
>
<div class="table-page-search-wrapper"> <div class="table-page-search-wrapper">
<a-form layout="inline"> <a-form layout="inline">
<a-row :gutter="48"> <a-row :gutter="48">
@ -303,9 +306,9 @@ import PostSetting from './components/PostSetting'
import AttachmentSelectDrawer from '../attachment/components/AttachmentSelectDrawer' import AttachmentSelectDrawer from '../attachment/components/AttachmentSelectDrawer'
import TagSelect from './components/TagSelect' import TagSelect from './components/TagSelect'
import CategoryTree from './components/CategoryTree' import CategoryTree from './components/CategoryTree'
import { mapGetters } from 'vuex'
import categoryApi from '@/api/category' import categoryApi from '@/api/category'
import postApi from '@/api/post' import postApi from '@/api/post'
import optionApi from '@/api/option'
const columns = [ const columns = [
{ {
title: '标题', title: '标题',
@ -389,9 +392,7 @@ export default {
postSettingVisible: false, postSettingVisible: false,
selectedPost: {}, selectedPost: {},
selectedTagIds: [], selectedTagIds: [],
selectedCategoryIds: [], selectedCategoryIds: []
options: [],
keys: ['blog_url']
} }
}, },
computed: { computed: {
@ -400,11 +401,11 @@ export default {
post.statusProperty = this.postStatus[post.status] post.statusProperty = this.postStatus[post.status]
return post return post
}) })
} },
...mapGetters(['options'])
}, },
created() { created() {
this.loadPosts() this.loadPosts()
this.loadOptions()
this.loadCategories() this.loadCategories()
}, },
methods: { methods: {
@ -425,11 +426,6 @@ export default {
this.categories = response.data.data this.categories = response.data.data
}) })
}, },
loadOptions() {
optionApi.listAll(this.keys).then(response => {
this.options = response.data.data
})
},
handleEditClick(post) { handleEditClick(post) {
this.$router.push({ name: 'PostEdit', query: { postId: post.id } }) this.$router.push({ name: 'PostEdit', query: { postId: post.id } })
}, },

View File

@ -195,7 +195,7 @@ import CategoryTree from './CategoryTree'
import CategorySelectTree from './CategorySelectTree' import CategorySelectTree from './CategorySelectTree'
import TagSelect from './TagSelect' import TagSelect from './TagSelect'
import AttachmentSelectDrawer from '../../attachment/components/AttachmentSelectDrawer' import AttachmentSelectDrawer from '../../attachment/components/AttachmentSelectDrawer'
import optionApi from '@/api/option' import { mapGetters } from 'vuex'
import categoryApi from '@/api/category' import categoryApi from '@/api/category'
import postApi from '@/api/post' import postApi from '@/api/post'
export default { export default {
@ -212,8 +212,6 @@ export default {
thumbDrawerVisible: false, thumbDrawerVisible: false,
categoryFormVisible: false, categoryFormVisible: false,
settingLoading: true, settingLoading: true,
options: [],
keys: ['blog_url'],
selectedPost: this.post, selectedPost: this.post,
selectedTagIds: this.tagIds, selectedTagIds: this.tagIds,
selectedCategoryIds: this.categoryIds, selectedCategoryIds: this.categoryIds,
@ -262,7 +260,6 @@ export default {
}, },
created() { created() {
this.loadSkeleton() this.loadSkeleton()
this.loadOptions()
this.loadCategories() this.loadCategories()
}, },
watch: { watch: {
@ -297,7 +294,8 @@ export default {
return moment(date, 'YYYY-MM-DD HH:mm:ss') return moment(date, 'YYYY-MM-DD HH:mm:ss')
} }
return moment(new Date(), 'YYYY-MM-DD HH:mm:ss') return moment(new Date(), 'YYYY-MM-DD HH:mm:ss')
} },
...mapGetters(['options'])
}, },
methods: { methods: {
loadSkeleton() { loadSkeleton() {
@ -306,11 +304,6 @@ export default {
this.settingLoading = false this.settingLoading = false
}, 500) }, 500)
}, },
loadOptions() {
optionApi.listAll(this.keys).then(response => {
this.options = response.data.data
})
},
loadCategories() { loadCategories() {
categoryApi.listAll().then(response => { categoryApi.listAll().then(response => {
this.categories = response.data.data this.categories = response.data.data

View File

@ -246,8 +246,8 @@
<script> <script>
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import SheetSetting from './components/SheetSetting' import SheetSetting from './components/SheetSetting'
import { mapGetters } from 'vuex'
import sheetApi from '@/api/sheet' import sheetApi from '@/api/sheet'
import optionApi from '@/api/option'
import menuApi from '@/api/menu' import menuApi from '@/api/menu'
const internalColumns = [ const internalColumns = [
@ -319,9 +319,7 @@ export default {
sheetSettingVisible: false, sheetSettingVisible: false,
internalSheets: [], internalSheets: [],
sheets: [], sheets: [],
options: [], menu: {}
menu: {},
keys: ['blog_url']
} }
}, },
computed: { computed: {
@ -330,12 +328,12 @@ export default {
sheet.statusProperty = this.sheetStatus[sheet.status] sheet.statusProperty = this.sheetStatus[sheet.status]
return sheet return sheet
}) })
} },
...mapGetters(['options'])
}, },
created() { created() {
this.loadSheets() this.loadSheets()
this.loadInternalSheets() this.loadInternalSheets()
this.loadOptions()
}, },
methods: { methods: {
loadSheets() { loadSheets() {
@ -350,11 +348,6 @@ export default {
this.internalSheets = response.data.data this.internalSheets = response.data.data
}) })
}, },
loadOptions() {
optionApi.listAll(this.keys).then(response => {
this.options = response.data.data
})
},
handleEditClick(sheet) { handleEditClick(sheet) {
this.$router.push({ name: 'SheetEdit', query: { sheetId: sheet.id } }) this.$router.push({ name: 'SheetEdit', query: { sheetId: sheet.id } })
}, },

View File

@ -108,7 +108,7 @@
import { mixin, mixinDevice } from '@/utils/mixin.js' import { mixin, mixinDevice } from '@/utils/mixin.js'
import moment from 'moment' import moment from 'moment'
import AttachmentSelectDrawer from '../../attachment/components/AttachmentSelectDrawer' import AttachmentSelectDrawer from '../../attachment/components/AttachmentSelectDrawer'
import optionApi from '@/api/option' import { mapGetters } from 'vuex'
import themeApi from '@/api/theme' import themeApi from '@/api/theme'
import sheetApi from '@/api/sheet' import sheetApi from '@/api/sheet'
export default { export default {
@ -121,8 +121,6 @@ export default {
return { return {
thumbDrawerVisible: false, thumbDrawerVisible: false,
settingLoading: true, settingLoading: true,
options: [],
keys: ['blog_url'],
selectedSheet: this.sheet, selectedSheet: this.sheet,
customTpls: [] customTpls: []
} }
@ -149,7 +147,6 @@ export default {
}, },
created() { created() {
this.loadSkeleton() this.loadSkeleton()
this.loadOptions()
this.loadCustomTpls() this.loadCustomTpls()
}, },
watch: { watch: {
@ -172,7 +169,8 @@ export default {
return moment(date, 'YYYY-MM-DD HH:mm:ss') return moment(date, 'YYYY-MM-DD HH:mm:ss')
} }
return moment(new Date(), 'YYYY-MM-DD HH:mm:ss') return moment(new Date(), 'YYYY-MM-DD HH:mm:ss')
} },
...mapGetters(['options'])
}, },
methods: { methods: {
loadSkeleton() { loadSkeleton() {
@ -181,11 +179,6 @@ export default {
this.settingLoading = false this.settingLoading = false
}, 500) }, 500)
}, },
loadOptions() {
optionApi.listAll(this.keys).then(response => {
this.options = response.data.data
})
},
loadCustomTpls() { loadCustomTpls() {
themeApi.customTpls().then(response => { themeApi.customTpls().then(response => {
this.customTpls = response.data.data this.customTpls = response.data.data

View File

@ -716,10 +716,10 @@
</template> </template>
<script> <script>
import AttachmentSelectDrawer from '../attachment/components/AttachmentSelectDrawer' import AttachmentSelectDrawer from '../attachment/components/AttachmentSelectDrawer'
import { mapActions } from 'vuex'
import optionApi from '@/api/option' import optionApi from '@/api/option'
import mailApi from '@/api/mail' import mailApi from '@/api/mail'
import attachmentApi from '@/api/attachment' import attachmentApi from '@/api/attachment'
import { mapActions } from 'vuex'
export default { export default {
components: { components: {
@ -747,11 +747,11 @@ export default {
} }
}, },
mounted() { mounted() {
this.loadOptions() this.loadFormOptions()
}, },
methods: { methods: {
...mapActions(['loadUser']), ...mapActions(['loadUser', 'loadOptions']),
loadOptions() { loadFormOptions() {
optionApi.listAll().then(response => { optionApi.listAll().then(response => {
this.options = response.data.data this.options = response.data.data
this.handleAttachChange(this.options['attachment_type']) this.handleAttachChange(this.options['attachment_type'])
@ -1013,6 +1013,7 @@ export default {
} }
optionApi.save(this.options).then(response => { optionApi.save(this.options).then(response => {
this.loadFormOptions()
this.loadOptions() this.loadOptions()
this.loadUser() this.loadUser()
this.$message.success('保存成功!') this.$message.success('保存成功!')

View File

@ -99,7 +99,7 @@ export default {
...mapGetters({ defaultApiUrl: 'apiUrl' }) ...mapGetters({ defaultApiUrl: 'apiUrl' })
}, },
methods: { methods: {
...mapActions(['login', 'loadUser']), ...mapActions(['login', 'loadUser', 'loadOptions']),
...mapMutations({ ...mapMutations({
setApiUrl: 'SET_API_URL', setApiUrl: 'SET_API_URL',
restoreApiUrl: 'RESTORE_API_URL' restoreApiUrl: 'RESTORE_API_URL'
@ -123,6 +123,7 @@ export default {
loginSuccess() { loginSuccess() {
// Cache the user info // Cache the user info
this.loadUser() this.loadUser()
this.loadOptions()
if (this.$route.query.redirect) { if (this.$route.query.redirect) {
this.$router.replace(this.$route.query.redirect) this.$router.replace(this.$route.query.redirect)
} else { } else {

View File

@ -6,7 +6,10 @@
:md="24" :md="24"
:style="{ 'padding-bottom': '12px' }" :style="{ 'padding-bottom': '12px' }"
> >
<a-card :bordered="false" :bodyStyle="{ padding: '16px' }"> <a-card
:bordered="false"
:bodyStyle="{ padding: '16px' }"
>
<div class="profile-center-avatarHolder"> <div class="profile-center-avatarHolder">
<a-tooltip <a-tooltip
placement="right" placement="right"
@ -149,8 +152,7 @@
import AttachmentSelectDrawer from '../attachment/components/AttachmentSelectDrawer' import AttachmentSelectDrawer from '../attachment/components/AttachmentSelectDrawer'
import userApi from '@/api/user' import userApi from '@/api/user'
import adminApi from '@/api/admin' import adminApi from '@/api/admin'
import optionApi from '@/api/option' import { mapMutations, mapGetters } from 'vuex'
import { mapMutations } from 'vuex'
import MD5 from 'md5.js' import MD5 from 'md5.js'
export default { export default {
@ -168,20 +170,18 @@ export default {
newPassword: null, newPassword: null,
confirmPassword: null confirmPassword: null
}, },
attachment: {}, attachment: {}
options: [],
keys: ['blog_url']
} }
}, },
computed: { computed: {
passwordUpdateButtonDisabled() { passwordUpdateButtonDisabled() {
return !(this.passwordParam.oldPassword && this.passwordParam.newPassword) return !(this.passwordParam.oldPassword && this.passwordParam.newPassword)
} },
...mapGetters(['options'])
}, },
created() { created() {
this.loadUser() this.loadUser()
this.getCounts() this.getCounts()
this.loadOptions()
}, },
methods: { methods: {
...mapMutations({ setUser: 'SET_USER' }), ...mapMutations({ setUser: 'SET_USER' }),
@ -191,11 +191,6 @@ export default {
this.profileLoading = false this.profileLoading = false
}) })
}, },
loadOptions() {
optionApi.listAll(this.keys).then(response => {
this.options = response.data.data
})
},
getCounts() { getCounts() {
adminApi.counts().then(response => { adminApi.counts().then(response => {
this.counts = response.data.data this.counts = response.data.data