Skip to content

Commit 8acb704

Browse files
committed
open project in one action
1 parent 68d6f38 commit 8acb704

File tree

6 files changed

+41
-21
lines changed

6 files changed

+41
-21
lines changed

src/components/OpenProjectComponent.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ export default {
1414
name: 'OpenProjectComponent',
1515
methods: {
1616
...mapActions([
17-
'setComponentMap',
18-
'setRoutes',
19-
'setImagePath'
17+
// 'setComponentMap',
18+
// 'setRoutes',
19+
// 'setImagePath',
20+
'openProject'
2021
]),
2122
parseFileName(file) {
2223
//Obtains json file name from file path
@@ -25,11 +26,13 @@ export default {
2526
openJSONFile (data) {
2627
const jsonFile = JSON.parse(fs.readFileSync(data[0], 'utf8'))
2728
console.log('json file', jsonFile.imagePath)
28-
this.setComponentMap(jsonFile.componentMap)
29-
this.setRoutes(jsonFile.routes)
30-
if (jsonFile.imagePath) {
31-
this.setImagePath(jsonFile.imagePath)
32-
}
29+
// this.setComponentMap(jsonFile.componentMap)
30+
// this.setRoutes(jsonFile.routes)
31+
// if (jsonFile.imagePath) {
32+
// this.setImagePath(jsonFile.imagePath)
33+
// }
34+
// open project action
35+
this.openProject(jsonFile)
3336
},
3437
showOpenJSONDialog () {
3538
remote.dialog.showOpenDialog({

src/components/UploadImage.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@
3434
<div class="file-path">
3535
<q-card>
3636
<!-- <img :src="[imageExists ? `file:///${imagePath[this.activeRoute]}` : ' ']" /> -->
37-
<img class='img' :src="source"/>
38-
37+
<!-- <img class='img' :src="'file:///' + this.imagePath[this.activeRoute]"/> -->
38+
<img class='img' v-if='this.imagePath[this.activeRoute] !== ""' :src="'file:///' + this.imagePath[this.activeRoute]"/>
39+
<!-- <img /> -->
3940
<!-- <q-card-section>
4041
<div class="text-h6 file-header">File Path</div>
4142
<div class="text-subtitle2 file-content">{{ imagePath[0] }}</div>

src/store/actions.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ const actions = {
117117
commit(types.CHANGE_ACTIVE_TAB, payload)
118118
},
119119
// used by OpenProjectComponent.vue
120-
[types.setComponentMap]: ({ commit }, payload) => {
121-
commit(types.SET_COMPONENT_MAP, payload)
122-
},
120+
// [types.setComponentMap]: ({ commit }, payload) => {
121+
// commit(types.SET_COMPONENT_MAP, payload)
122+
// },
123123
[types.addRouteToRouteMap]: ({ state, commit }, payload) => {
124124
commit(types.ADD_ROUTE, payload)
125125
commit(types.SET_ACTIVE_ROUTE, payload)
@@ -137,9 +137,9 @@ const actions = {
137137
[types.setActiveComponent]: ({ commit }, payload) => {
138138
commit(types.SET_ACTIVE_COMPONENT, payload)
139139
},
140-
[types.setRoutes]: ({ commit }, payload) => {
141-
commit(types.SET_ROUTES, payload)
142-
},
140+
// [types.setRoutes]: ({ commit }, payload) => {
141+
// commit(types.SET_ROUTES, payload)
142+
// },
143143
[types.deleteProjectTab]: ({ commit }, payload) => {
144144
commit(types.DELETE_PROJECT_TAB, payload)
145145
},
@@ -199,9 +199,19 @@ const actions = {
199199
})
200200
commit(types.DELETE_USER_STATE, payload)
201201
},
202-
[types.setImagePath]: ({ commit }, payload) => {
203-
console.log('image payload', payload)
204-
commit(types.SET_IMAGE_PATH, payload)
202+
// [types.setImagePath]: ({ commit }, payload) => {
203+
// console.log('image payload', payload)
204+
// commit(types.SET_IMAGE_PATH, payload)
205+
// },
206+
[types.openProject]: ({ commit }, payload) => {
207+
// open project imagePath, componentPath, routePath
208+
console.log('image', payload.imagePath)
209+
console.log('component', payload.componentMap)
210+
console.log('route', payload.routes)
211+
commit(types.SET_IMAGE_PATH, payload.imagePath)
212+
commit(types.SET_COMPONENT_MAP, payload.componentMap)
213+
commit(types.SET_ROUTES, payload.routes)
214+
205215
}
206216
}
207217

src/store/mutations.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ const mutations = {
119119
componentChildrenMultiselectValue: [],
120120
modalOpen: false,
121121
parentSelected: false,
122-
imagePath: {}
122+
imagePath: {
123+
HomeView: ''
124+
}
123125
})
124126
},
125127

src/store/state/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ const newState = {
3939
componentChildrenMultiselectValue: [],
4040
modalOpen: false,
4141
parentSelected: false,
42-
imagePath: {}
42+
imagePath: {
43+
HomeView: ''
44+
}
4345
}
4446

4547
// const defaultState =

src/store/types.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,5 @@ export const removeStateFromComponent = 'removeStateFromComponent'
108108
export const deleteUserState = 'deleteUserState'
109109
// open image action
110110
export const setImagePath = 'setImagePath'
111+
// open project action
112+
export const openProject = 'openProject'

0 commit comments

Comments
 (0)