1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- const app = {
- state: {
- loading: true,
- page: ['home'],
- device: 'desktop',
- locale: 'zh-cn',
- adIsShow: true
- },
- mutations: {
- SET_PAGE: (state, value) => {
- state.page.push(value)
- },
- DELETE_PAGE: (state) => {
- if (state.page.length > 0) {
- state.page.splice(state.page.length-1,1)
- }
- },
- HIDE_AD: (state) => {
- state.adIsShow = false
- },
- GET_AD_STATUS: (state) => {
- return state.adIsShow
- },
- SET_LOCALE: (state, locale) => {
- state.locale = locale
- },
- HIDE_LOADING: (state) => {
- state.loading = false
- },
- GET_DATA: (state, name) => {
- const item = JSON.parse(JSON.stringify(name))
- if (state[item]) {
- return JSON.parse(JSON.stringify(state[item]))
- }
- },
- SET_DATA: (state, res) => {
- const item = JSON.parse(JSON.stringify(res))
- if (item.name && !state[item.name]) {
- state[item.name] = ''
- }
- state[item.name] = JSON.parse(JSON.stringify(item.value))
- },
- DELETE_DATA: (state, res) => {
- if (res.name && state[res.name]) {
- delete state[res.name]
- }
- }
- },
- actions: {
- showLoading: ({commit}) => {
- commit('SHOW_LOADING')
- },
- hideLoading: ({commit}) => {
- commit('HIDE_LOADING')
- },
- getData: ({commit}, data) => {
- commit('GET_DATA', data)
- },
- setData: ({commit}, data) => {
- commit('SET_DATA', data)
- },
- deleteData: ({commit}, data) => {
- commit('DELETE_DATA', data)
- },
- getAdStatus: ({commit}) => {
- commit('GET_AD_STATUS')
- },
- hideAd: ({commit}) => {
- commit('HIDE_AD')
- }
- }
- }
- export default app
|