From 91abc20fef46470b08f3516ce58cd87dad2f76c0 Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Thu, 23 Dec 2021 16:24:05 +0800 Subject: [PATCH] feat: add widgets --- src/store/modules/dashboard.ts | 14 ++++++++ src/views/dashboard/Edit.vue | 33 +++++++++++++++-- .../widget/{GridItem.vue => Item.vue} | 0 .../widget/{GridLayout.vue => Layout.vue} | 35 +++++-------------- 4 files changed, 53 insertions(+), 29 deletions(-) rename src/views/dashboard/widget/{GridItem.vue => Item.vue} (100%) rename src/views/dashboard/widget/{GridLayout.vue => Layout.vue} (69%) diff --git a/src/store/modules/dashboard.ts b/src/store/modules/dashboard.ts index c0a4c8df..2c549e18 100644 --- a/src/store/modules/dashboard.ts +++ b/src/store/modules/dashboard.ts @@ -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); + }, }, }); diff --git a/src/views/dashboard/Edit.vue b/src/views/dashboard/Edit.vue index 556c406a..e035f0c6 100644 --- a/src/views/dashboard/Edit.vue +++ b/src/views/dashboard/Edit.vue @@ -14,7 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. -->