feat: update layout

This commit is contained in:
Qiuxia Fan
2021-12-23 19:33:40 +08:00
parent 91abc20fef
commit 4992d1567d
4 changed files with 24 additions and 53 deletions

View File

@@ -19,17 +19,17 @@ import { store } from "@/store";
import { GridItemData } from "@/types/dashboard";
interface DashboardState {
layouts: GridItemData[];
layout: GridItemData[];
}
export const dashboardStore = defineStore({
id: "dashboard",
state: (): DashboardState => ({
layouts: [],
layout: [],
}),
actions: {
setLayouts(data: GridItemData[]) {
this.layouts = data;
setLayout(data: GridItemData[]) {
this.layout = data;
},
addWidget() {
const newWidget: GridItemData = {
@@ -37,13 +37,13 @@ export const dashboardStore = defineStore({
y: 0,
w: 12,
h: 3,
i: String(this.layouts.length),
i: String(this.layout.length),
};
this.layouts = this.layouts.map((d: GridItemData) => {
this.layout = this.layout.map((d: GridItemData) => {
d.y = d.y + 3;
return d;
});
this.layouts.push(newWidget);
this.layout.push(newWidget);
},
},
});