mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-15 14:03:36 +08:00
chore:更换到主分支
This commit is contained in:
6
src/store/getters.ts
Normal file
6
src/store/getters.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
const getters = {
|
||||
sidebar: (state: any) => state.app.sidebar,
|
||||
device: (state: any) => state.app.device,
|
||||
}
|
||||
|
||||
export default getters
|
||||
12
src/store/index.ts
Normal file
12
src/store/index.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { createStore } from 'vuex'
|
||||
import getters from './getters'
|
||||
import app from './modules/app'
|
||||
import settings from './modules/settings'
|
||||
|
||||
export default createStore({
|
||||
getters,
|
||||
modules: {
|
||||
app,
|
||||
settings
|
||||
}
|
||||
})
|
||||
58
src/store/modules/app.ts
Normal file
58
src/store/modules/app.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { storageLocal } from "../../utils/storage"
|
||||
interface stateInter {
|
||||
sidebar: {
|
||||
opened: Boolean,
|
||||
withoutAnimation: Boolean
|
||||
},
|
||||
device: String
|
||||
}
|
||||
|
||||
const state = {
|
||||
sidebar: {
|
||||
opened: storageLocal.getItem('sidebarStatus') ? !!+storageLocal.getItem('sidebarStatus') : true,
|
||||
withoutAnimation: false
|
||||
},
|
||||
device: 'desktop'
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
TOGGLE_SIDEBAR: (state: stateInter): void => {
|
||||
state.sidebar.opened = !state.sidebar.opened
|
||||
state.sidebar.withoutAnimation = false
|
||||
if (state.sidebar.opened) {
|
||||
storageLocal.setItem('sidebarStatus', 1)
|
||||
} else {
|
||||
storageLocal.setItem('sidebarStatus', 0)
|
||||
}
|
||||
},
|
||||
CLOSE_SIDEBAR: (state: stateInter, withoutAnimation: Boolean) => {
|
||||
storageLocal.setItem('sidebarStatus', 0)
|
||||
state.sidebar.opened = false
|
||||
state.sidebar.withoutAnimation = withoutAnimation
|
||||
},
|
||||
TOGGLE_DEVICE: (state: stateInter, device: String) => {
|
||||
state.device = device
|
||||
}
|
||||
}
|
||||
|
||||
const actions = {
|
||||
// @ts-ignore
|
||||
toggleSideBar({ commit }) {
|
||||
commit('TOGGLE_SIDEBAR')
|
||||
},
|
||||
// @ts-ignore
|
||||
closeSideBar({ commit }, { withoutAnimation }) {
|
||||
commit('CLOSE_SIDEBAR', withoutAnimation)
|
||||
},
|
||||
// @ts-ignore
|
||||
toggleDevice({ commit }, device) {
|
||||
commit('TOGGLE_DEVICE', device)
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions
|
||||
}
|
||||
29
src/store/modules/settings.ts
Normal file
29
src/store/modules/settings.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import defaultSettings from '../../settings'
|
||||
|
||||
const state = {
|
||||
title: defaultSettings.title,
|
||||
fixedHeader: defaultSettings.fixedHeader,
|
||||
sidebarLogo: defaultSettings.sidebarLogo
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
CHANGE_SETTING: (state: any, { key, value }) => {
|
||||
if (state.hasOwnProperty(key)) {
|
||||
state[key] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const actions = {
|
||||
changeSetting({ commit }, data) {
|
||||
commit('CHANGE_SETTING', data)
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user