feat: add widgets

This commit is contained in:
Qiuxia Fan
2021-12-23 16:24:05 +08:00
parent e01fe93c3d
commit 91abc20fef
4 changed files with 53 additions and 29 deletions

View File

@@ -31,6 +31,20 @@ export const dashboardStore = defineStore({
setLayouts(data: GridItemData[]) {
this.layouts = data;
},
addWidget() {
const newWidget: GridItemData = {
x: 0,
y: 0,
w: 12,
h: 3,
i: String(this.layouts.length),
};
this.layouts = this.layouts.map((d: GridItemData) => {
d.y = d.y + 3;
return d;
});
this.layouts.push(newWidget);
},
},
});