feat: add config panel

This commit is contained in:
Qiuxia Fan
2021-12-23 22:44:01 +08:00
parent b39109eae6
commit fea4c202b3
4 changed files with 51 additions and 89 deletions

View File

@@ -19,6 +19,7 @@ import { store } from "@/store";
import { GridItemData } from "@/types/dashboard";
interface DashboardState {
showConfig: boolean;
layout: GridItemData[];
}
@@ -26,6 +27,7 @@ export const dashboardStore = defineStore({
id: "dashboard",
state: (): DashboardState => ({
layout: [],
showConfig: false,
}),
actions: {
setLayout(data: GridItemData[]) {
@@ -36,11 +38,11 @@ export const dashboardStore = defineStore({
x: 0,
y: 0,
w: 12,
h: 3,
h: 12,
i: String(this.layout.length),
};
this.layout = this.layout.map((d: GridItemData) => {
d.y = d.y + 3;
d.y = d.y + newWidget.h;
return d;
});
this.layout.push(newWidget);
@@ -48,6 +50,9 @@ export const dashboardStore = defineStore({
removeWidget(item: GridItemData) {
this.layout = this.layout.filter((d: GridItemData) => d.i !== item.i);
},
setConfigPanel(show: boolean) {
this.showConfig = show;
},
},
});