mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-28 19:10:40 +00:00
vuex refactoring
This commit is contained in:
Vendored
+47
-2
@@ -1,19 +1,64 @@
|
||||
const defaultState = {
|
||||
fileInfoPanelVisible: localStorage.getItem('file_info_visibility') == 'true' || false,
|
||||
FilePreviewType: localStorage.getItem('FilePreviewType') || 'list',
|
||||
appSize: undefined,
|
||||
config: undefined,
|
||||
}
|
||||
const actions = {
|
||||
changePreviewType: ({commit, dispatch, state, getters}) => {
|
||||
// Get preview type
|
||||
let previewType = state.FilePreviewType == 'grid' ? 'list' : 'grid'
|
||||
|
||||
// Store preview type to localStorage
|
||||
localStorage.setItem('preview_type', previewType)
|
||||
|
||||
// Change preview
|
||||
commit('CHANGE_PREVIEW', previewType)
|
||||
|
||||
if (getters.currentFolder.location === 'trash-root') {
|
||||
dispatch('getTrash')
|
||||
|
||||
} else {
|
||||
|
||||
if ( this.$isThisLocation('public') ) {
|
||||
dispatch('browseShared', [this.currentFolder(), false, true])
|
||||
} else {
|
||||
dispatch('getFolder', [getters.currentFolder, false, true])
|
||||
}
|
||||
}
|
||||
},
|
||||
fileInfoToggle: (context, visibility = undefined) => {
|
||||
if (!visibility) {
|
||||
if (context.state.fileInfoPanelVisible) {
|
||||
context.commit('FILE_INFO_TOGGLE', false)
|
||||
} else {
|
||||
context.commit('FILE_INFO_TOGGLE', true)
|
||||
}
|
||||
} else {
|
||||
context.commit('FILE_INFO_TOGGLE', visibility)
|
||||
}
|
||||
},
|
||||
}
|
||||
const mutations = {
|
||||
SET_CONFIG(state, config) {
|
||||
state.config = config
|
||||
FILE_INFO_TOGGLE(state, isVisible) {
|
||||
state.fileInfoPanelVisible = isVisible
|
||||
|
||||
localStorage.setItem('file_info_visibility', isVisible)
|
||||
},
|
||||
SET_APP_WIDTH(state, scale) {
|
||||
state.appSize = scale
|
||||
},
|
||||
CHANGE_PREVIEW(state, type) {
|
||||
state.FilePreviewType = type
|
||||
},
|
||||
SET_CONFIG(state, config) {
|
||||
state.config = config
|
||||
},
|
||||
|
||||
}
|
||||
const getters = {
|
||||
fileInfoVisible: state => state.fileInfoPanelVisible,
|
||||
FilePreviewType: state => state.FilePreviewType,
|
||||
appSize: state => state.appSize,
|
||||
api: state => state.config.api,
|
||||
config: state => state.config,
|
||||
|
||||
Reference in New Issue
Block a user