Skip to content

Commit eb8da71

Browse files
committed
fix delect FavoriteApp error. key error
1 parent 71d64c3 commit eb8da71

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

web/src/commonData/i18n/common/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,8 @@
10651065
"running": "running",
10661066
"stop": "disable",
10671067
"searchPlaceholder": "Search application",
1068-
"tips": "No data or no addition"
1068+
"tips": "No data or no addition",
1069+
"repeat": "You cannot add the same application repeatedly"
10691070
}
10701071
},
10711072
"database": {

web/src/commonData/i18n/common/zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,8 @@
10651065
"running": "运行中",
10661066
"stop": "不可用",
10671067
"searchPlaceholder": "搜索应用系统",
1068-
"tips": "没有数据或者未添加"
1068+
"tips": "没有数据或者未添加",
1069+
"repeat": "不能重复添加相同的应用"
10691070
}
10701071
},
10711072
"database": {

web/src/js/view/newhome/module/workspace/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,12 @@ export default {
168168
this.getVideos();
169169
},
170170
mounted(){
171-
this.listWrap = this.$refs.row.$el.offsetWidth;
171+
this.listWrap = this.$refs.row.$el && this.$refs.row.$el.offsetWidth;
172172
this.initWorkspace();
173173
window.onresize = () => {
174174
const that = this
175175
return (() => {
176-
that.listWrap = this.$refs.row.$el.offsetWidth;
176+
that.listWrap = this.$refs.row.$el && this.$refs.row.$el.offsetWidth;
177177
})()
178178
}
179179
},

web/src/js/view/workspace/index.vue

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ export default {
218218
this.applications = data.applications || [];
219219
})
220220
},
221-
deleteFavoriteApp(favouritesId, index){
222-
api.fetch(`/dss/workspaces/${this.workspaceId}/favorites/${favouritesId}`, 'delete').then(data=>{
221+
deleteFavoriteApp(favoriteId, index){
222+
api.fetch(`/dss/workspaces/${this.workspaceId}/favorites/${favoriteId}`, 'delete').then(data=>{
223223
this.favoriteApps.splice(index, 1);
224224
})
225225
},
@@ -228,14 +228,20 @@ export default {
228228
this.$refs.dynamicForm.validate((valid) => {
229229
if (valid) {
230230
// this.addAppLoading = true;
231+
const menuApplicationId = parseInt(this.formDynamic.selectApp, 10);
232+
const favoriteApp = this.findFavoriteAppsByMenuId(menuApplicationId);
233+
if(favoriteApp) {
234+
return this.$Message.error(`${this.$t('message.workSpace.home.repeat')}`);
235+
}
231236
this.show = false;
232-
api.fetch(`/dss/workspaces/${this.workspaceId}/favorites`, {menuApplicationId: parseInt(this.formDynamic.selectApp, 10)},'post').then(data=>{
237+
api.fetch(`/dss/workspaces/${this.workspaceId}/favorites`, {menuApplicationId: menuApplicationId},'post').then(data=>{
233238
const app = this.findAppByApplicationId(this.formDynamic.selectApp)
234239
this.favoriteApps.push({
235240
...app,
236-
"id": data.favouritesId,
241+
"id": data.favoriteId,
237242
"menuApplicationId": app.id, //application表里的id
238-
})
243+
});
244+
239245
})
240246
}
241247
});
@@ -247,6 +253,12 @@ export default {
247253
return result;
248254
},
249255
256+
findFavoriteAppsByMenuId(menuId){
257+
const arr = this.favoriteApps;
258+
const result = arr.find(item=>item.menuApplicationId==menuId);
259+
return result;
260+
},
261+
250262
flatApps(){
251263
const arr = [];
252264
this.applications.forEach(item=>{

0 commit comments

Comments
 (0)