Skip to content

Commit 80bd308

Browse files
committed
File manager fixed with refresh page.
1 parent e989bf2 commit 80bd308

File tree

10 files changed

+71
-7
lines changed

10 files changed

+71
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "laravel-frontend-file-manager",
3-
"version": "3.0.68",
3+
"version": "3.0.79",
44
"description": "File manager for Laravel",
55
"keywords": [
66
"laravel",

src/FileManager.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ export default {
130130
HTTP.defaults.headers = this.$store.getters['fm/settings/headers'];*/
131131
132132
/** Customized by Mohammad Ashrafuddin Ferdousi */
133-
let settings = localstore.getStorage(localstore.axiosSettingType);
133+
// Uncomment when needed.
134+
/*let settings = localstore.getStorage(localstore.axiosSettingType);
134135
135136
if(settings) {
136137
HTTP.interceptors.request.use(config => {
@@ -144,7 +145,17 @@ export default {
144145
);
145146
} else {
146147
throw `settings.baseURL: ${settings.baseURL}, settings.withCredentials: ${settings.withCredentials}, settings.headers: ${settings.headers} is set!`;
147-
}
148+
}*/
149+
// End of uncomment when needed.
150+
HTTP.interceptors.request.use(config => {
151+
config.baseURL = this.$store.getters['fm/settings/baseUrl'];
152+
config.withCredentials = this.$store.getters['fm/settings/withCredentials'];
153+
config.headers = this.$store.getters['fm/settings/headers'];
154+
config.headers.common.Authorization = `Bearer ${window.localStorage.getItem('_token')}`;
155+
156+
return config;
157+
}, error => Promise.reject(error)
158+
);
148159
},
149160
150161
/**

src/http/axios.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import axios from 'axios';
2-
import localstore from '../mixins/localstore';
2+
// Uncomment when needed.
3+
/*import localstore from '../mixins/localstore';
34
45
let settings = localstore.getStorage(localstore.axiosSettingType);
56
@@ -10,4 +11,7 @@ if(settings) {
1011
}
1112
1213
// set new axios instance
13-
export default axios.create(settings);
14+
export default axios.create(settings);*/
15+
// End of uncomment when needed.
16+
17+
export default axios.create();

src/store/actions.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export default {
1515
// Mohammad Ashrafuddin Ferdousi : 2
1616
initializeApp({ state, commit, getters, dispatch }) {
1717
// Mohammad Ashrafuddin Ferdousi : 1
18-
GET.initialize().then((response) => {
18+
let init = GET.initialize();
19+
init.then((response) => {
1920
if (response.data.result.status === 'success') {
2021
commit('settings/initSettings', response.data.config);
2122
commit('setDisks', response.data.config.disks);
@@ -89,11 +90,28 @@ export default {
8990
}
9091
});
9192
}
92-
} else {
93+
}
94+
else {
9395
window.location.reload();
96+
// Uncomment when needed.
97+
/*if(getters.callInitTill) {
98+
setTimeout(() => {
99+
dispatch('initializeApp');
100+
commit('increaseInitCallCount');
101+
}, 1000);
102+
}*/
103+
// End of uncomment when needed.
94104
}
95105
}).catch(err => {
96106
window.location.reload();
107+
// Uncomment when needed.
108+
/*if(getters.callInitTill) {
109+
setTimeout(() => {
110+
dispatch('initializeApp');
111+
commit('increaseInitCallCount');
112+
}, 1000);
113+
}*/
114+
// End of uncomment when needed.
97115
});
98116
},
99117

src/store/getters.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,13 @@ export default {
4444
inactiveManager(state) {
4545
return state.activeManager === 'left' ? 'right' : 'left';
4646
},
47+
48+
/**
49+
*
50+
* @param state
51+
* @returns {boolean}
52+
*/
53+
callInitTill(state) {
54+
return state.initCallCount < 3;
55+
}
4756
};

src/store/mutations.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,8 @@ export default {
9292
state.fileCallback = null;
9393
state.fullScreen = false;
9494
},
95+
96+
increaseInitCallCount(state) {
97+
state.initCallCount++;
98+
}
9599
};

src/store/settings/getters.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,8 @@ export default {
2525
authHeader(state) {
2626
return Object.prototype.hasOwnProperty.call(state.headers, 'Authorization');
2727
},
28+
29+
withCredentials(state) {
30+
return state.withCredentials;
31+
}
2832
};

src/store/settings/mutations.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ export default {
7676
}
7777
}
7878
}
79+
80+
if (state.withCredentials === false) {
81+
if((import.meta.env.VITE_APP_LFM_WITH_CREDENTIALS !== undefined)) {
82+
state.withCredentials = import.meta.env.VITE_APP_LFM_WITH_CREDENTIALS;
83+
} else if((import.meta.env.VITE_LFM_CSRF_WITH_CREDENTIALS !== undefined)) {
84+
state.withCredentials = import.meta.env.VITE_LFM_CSRF_WITH_CREDENTIALS;
85+
}
86+
}
7987
},
8088

8189
/**

src/store/settings/store.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ export default {
3737
// axios default URL
3838
baseUrl: null,
3939

40+
// axios default withCredentials
41+
withCredentials: true,
42+
4043
/**
4144
* File manager windows configuration
4245
* 1 - only one file manager window

src/store/state.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@ export default {
2525

2626
// full screen mode
2727
fullScreen: false,
28+
29+
//initializeApp call count
30+
initCallCount: 0,
2831
};

0 commit comments

Comments
 (0)