From 8acadf71230c08414ae150cad607290de62a6d96 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Fri, 16 May 2025 12:02:21 +0800 Subject: [PATCH] refactor: dashboard --- frontend/components.d.ts | 9 +- frontend/src/router/index.ts | 5 +- frontend/src/stores/dashboard/dashboard.ts | 38 +-- frontend/src/stores/index.ts | 10 + ...eviewDashboard.vue => DashboardEditor.vue} | 0 .../views/dashboard/canvas/DsCanvasCore.vue | 231 ++++++------------ frontend/src/views/dashboard/css/DeDrag.less | 102 -------- 7 files changed, 111 insertions(+), 284 deletions(-) create mode 100644 frontend/src/stores/index.ts rename frontend/src/views/dashboard/{PreviewDashboard.vue => DashboardEditor.vue} (100%) delete mode 100644 frontend/src/views/dashboard/css/DeDrag.less diff --git a/frontend/components.d.ts b/frontend/components.d.ts index e8f6eea3..a036034d 100644 --- a/frontend/components.d.ts +++ b/frontend/components.d.ts @@ -11,8 +11,9 @@ declare module 'vue' { ElAvatar: typeof import('element-plus/es')['ElAvatar'] ElButton: typeof import('element-plus/es')['ElButton'] ElCheckbox: typeof import('element-plus/es')['ElCheckbox'] + ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup'] + ElCol: typeof import('element-plus/es')['ElCol'] ElDialog: typeof import('element-plus/es')['ElDialog'] - ElDrawer: typeof import('element-plus/es')['ElDrawer'] ElDropdown: typeof import('element-plus/es')['ElDropdown'] ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem'] ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu'] @@ -23,13 +24,13 @@ declare module 'vue' { ElMenu: typeof import('element-plus/es')['ElMenu'] ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] ElOption: typeof import('element-plus/es')['ElOption'] - ElPagination: typeof import('element-plus/es')['ElPagination'] ElRow: typeof import('element-plus/es')['ElRow'] + ElScrollbar: typeof import('element-plus/es')['ElScrollbar'] ElSelect: typeof import('element-plus/es')['ElSelect'] - ElSlider: typeof import('element-plus/es')['ElSlider'] + ElStep: typeof import('element-plus/es')['ElStep'] + ElSteps: typeof import('element-plus/es')['ElSteps'] ElTable: typeof import('element-plus/es')['ElTable'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] - ElTableV2: typeof import('element-plus/es')['ElTableV2'] ElTabPane: typeof import('element-plus/es')['ElTabPane'] ElTabs: typeof import('element-plus/es')['ElTabs'] ElTooltip: typeof import('element-plus/es')['ElTooltip'] diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 4b735479..35cfaee5 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -5,6 +5,7 @@ import login from '@/views/login/index.vue' import chat from '@/views/chat/index.vue' import ds from '@/views/ds/index.vue' import dashboard from '@/views/dashboard/index.vue' +import DashboardEditor from '@/views/dashboard/DashboardEditor.vue' import setting from '@/views/setting/index.vue' import { watchRouter } from './watch' const router = createRouter({ @@ -24,7 +25,7 @@ const router = createRouter({ path: 'index', name: 'chat', component: chat, - meta: { title: 'Data Q&A', icon: 'chat'} + meta: { title: 'Data Q&A', icon: 'chat' } } ] }, @@ -55,7 +56,7 @@ const router = createRouter({ { path: 'index', name: 'dashboard', - component: dashboard, + component: DashboardEditor, meta: { title: 'Dashboard', icon: 'dashboard' } } ] diff --git a/frontend/src/stores/dashboard/dashboard.ts b/frontend/src/stores/dashboard/dashboard.ts index b8d09f92..15f37dd1 100644 --- a/frontend/src/stores/dashboard/dashboard.ts +++ b/frontend/src/stores/dashboard/dashboard.ts @@ -1,19 +1,25 @@ -import { defineStore } from 'pinia' +import {defineStore} from 'pinia' +import {store} from "@/stores"; -export const useDashboardStore = defineStore('dashboardStore', { - state: () => { - return { - curComponent: null +export const dashboardStore = defineStore('dashboard', { + state: () => { + return { + curComponent: null + } + }, + getters: { + getCurComponent(): any { + return this.curComponent + } + }, + actions: { + setCurComponent(value: any) { + this.curComponent = value + } } - }, - getters: { - getCurComponent(): any { - return this.curComponent - } - }, - actions: { - setCurComponent(value: any) { - this.curComponent = value - } - } }) + + +export const dashboardStoreWithOut = () => { + return dashboardStore(store) +} \ No newline at end of file diff --git a/frontend/src/stores/index.ts b/frontend/src/stores/index.ts new file mode 100644 index 00000000..65964ea8 --- /dev/null +++ b/frontend/src/stores/index.ts @@ -0,0 +1,10 @@ +import type { App } from 'vue' +import { createPinia } from 'pinia' + +const store = createPinia() + +export const setupStore = (app: App) => { + app.use(store) +} + +export { store } diff --git a/frontend/src/views/dashboard/PreviewDashboard.vue b/frontend/src/views/dashboard/DashboardEditor.vue similarity index 100% rename from frontend/src/views/dashboard/PreviewDashboard.vue rename to frontend/src/views/dashboard/DashboardEditor.vue diff --git a/frontend/src/views/dashboard/canvas/DsCanvasCore.vue b/frontend/src/views/dashboard/canvas/DsCanvasCore.vue index 15f397bb..3e7c16fd 100644 --- a/frontend/src/views/dashboard/canvas/DsCanvasCore.vue +++ b/frontend/src/views/dashboard/canvas/DsCanvasCore.vue @@ -1,10 +1,16 @@ diff --git a/frontend/src/views/dashboard/css/DeDrag.less b/frontend/src/views/dashboard/css/DeDrag.less deleted file mode 100644 index 8a6184e5..00000000 --- a/frontend/src/views/dashboard/css/DeDrag.less +++ /dev/null @@ -1,102 +0,0 @@ -.dragAndResize -{ - position: relative; - user-select: none; - * - { - box-sizing: border-box; - margin: 0; - padding: 0; - } - .item - { - position: absolute; - - width: 100px; - height: 100px; - - cursor: move; - - border: 1px solid; - background-color: #fff; - - .resizeHandle - { - position: absolute; - background: #fff; - border: 1px solid #59c7f9; - width: 8px; - height: 8px; - border-radius: 50%; - z-index: 0; - } - } - - .moveAnimation - { - transition: top 80ms ease; - } - - .canNotDrag - { - cursor: default!important; - } - - .cloneNode - { - z-index: 3; - - transition: none; - - opacity: .5; - } - - .movingItem - { - position: absolute; - - border: none; - &:before - { - position: absolute; - z-index: 2; - top: 0; - left: 0; - - width: 100%; - height: 100%; - - content: ''; - - background-color: #bbb; - } - } - - .positionBox - { - position: fixed; - top: 0; - right: 100px; - - overflow: auto; - - width: 500px; - height: 500px; - - border: 1px solid; - } - - .coords - { - position: fixed; - right: 100px; - bottom: 200px; - - overflow: auto; - - width: 200px; - height: 200px; - - border: 1px solid; - } -}