Skip to content

Commit 611313f

Browse files
committed
refactor: dashboard add item
1 parent 7786ff1 commit 611313f

File tree

28 files changed

+1058
-152
lines changed

28 files changed

+1058
-152
lines changed

frontend/components.d.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,6 @@ export {}
88
/* prettier-ignore */
99
declare module 'vue' {
1010
export interface GlobalComponents {
11-
ElAvatar: typeof import('element-plus/es')['ElAvatar']
12-
ElButton: typeof import('element-plus/es')['ElButton']
13-
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
14-
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
15-
ElCol: typeof import('element-plus/es')['ElCol']
16-
ElDialog: typeof import('element-plus/es')['ElDialog']
17-
ElDropdown: typeof import('element-plus/es')['ElDropdown']
18-
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
19-
ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
20-
ElForm: typeof import('element-plus/es')['ElForm']
21-
ElFormItem: typeof import('element-plus/es')['ElFormItem']
22-
ElIcon: typeof import('element-plus/es')['ElIcon']
23-
ElInput: typeof import('element-plus/es')['ElInput']
24-
ElMenu: typeof import('element-plus/es')['ElMenu']
25-
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
26-
ElOption: typeof import('element-plus/es')['ElOption']
27-
ElRow: typeof import('element-plus/es')['ElRow']
28-
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
29-
ElSelect: typeof import('element-plus/es')['ElSelect']
30-
ElStep: typeof import('element-plus/es')['ElStep']
31-
ElSteps: typeof import('element-plus/es')['ElSteps']
32-
ElTable: typeof import('element-plus/es')['ElTable']
33-
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
34-
ElTabPane: typeof import('element-plus/es')['ElTabPane']
35-
ElTabs: typeof import('element-plus/es')['ElTabs']
36-
ElTooltip: typeof import('element-plus/es')['ElTooltip']
3711
Icon: typeof import('./src/components/icon-custom/src/Icon.vue')['default']
3812
Layout: typeof import('./src/components/layout/index.vue')['default']
3913
RouterLink: typeof import('vue-router')['RouterLink']

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"dependencies": {
1212
"lodash": "^4.17.21",
13+
"snowflake-id": "^1.1.0",
1314
"vue": "^3.5.13",
1415
"vue-router": "^4.5.0",
1516
"web-storage-cache": "^1.1.1"
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading

frontend/src/assets/svg/dv-tab.svg

Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading

frontend/src/router/index.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import Layout from '@/components/layout/index.vue'
44
import login from '@/views/login/index.vue'
55
import chat from '@/views/chat/index.vue'
66
import ds from '@/views/ds/index.vue'
7-
import DashboardEditor from '@/views/dashboard/DashboardEditor.vue'
7+
import DashboardEditor from '@/views/dashboard/editor/index.vue'
8+
import Dashboard from '@/views/dashboard/index.vue'
89
import setting from '@/views/setting/index.vue'
910
import { watchRouter } from './watch'
1011
const router = createRouter({
@@ -55,11 +56,24 @@ const router = createRouter({
5556
{
5657
path: 'index',
5758
name: 'dashboard',
58-
component: DashboardEditor,
59+
component: Dashboard,
5960
meta: { title: 'Dashboard', icon: 'dashboard' }
6061
}
6162
]
6263
},
64+
{
65+
path: '/dashboard-edit',
66+
redirect: '/dashboard-edit/index',
67+
component: Layout,
68+
children: [
69+
{
70+
path: 'index',
71+
name: 'dashboard-edit',
72+
component: DashboardEditor,
73+
meta: { title: 'dashboard-edit', icon: 'dashboard' }
74+
}
75+
]
76+
},
6377
{
6478
path: '/setting',
6579
component: Layout,

frontend/src/stores/dashboard/dashboard.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@ import {store} from "@/stores";
44
export const dashboardStore = defineStore('dashboard', {
55
state: () => {
66
return {
7-
curComponent: null
7+
curComponent: null,
8+
canvasStyle: {},
9+
componentData: [],
10+
dashboardInfo: {
11+
id: null,
12+
name: 'New Dashboard',
13+
pid: null,
14+
dataState: null,
15+
optType: null,
16+
status: null,
17+
type: null,
18+
mobileLayout: false
19+
}
820
}
921
},
1022
getters: {
@@ -15,7 +27,14 @@ export const dashboardStore = defineStore('dashboard', {
1527
actions: {
1628
setCurComponent(value: any) {
1729
this.curComponent = value
30+
},
31+
setComponentData(value: any) {
32+
this.componentData = value
33+
},
34+
setCanvasStyle(value: any) {
35+
this.canvasStyle = value
1836
}
37+
1938
}
2039
})
2140

frontend/src/utils/canvas.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// @ts-ignore
2+
import SnowflakeID from 'snowflake-id';
3+
4+
const snowflake = new SnowflakeID({
5+
mid: 42,
6+
offset: (2010 - 1970) * 365 * 24 * 3600 * 1000
7+
});
8+
9+
export const guid = () => {
10+
return snowflake.generate();
11+
}
12+
13+
export interface CanvasItem {
14+
_dragId: string | number
15+
x: number
16+
y: number
17+
sizeX: number
18+
sizeY: number
19+
[key: string]: any
20+
}
21+
22+
23+
export type CanvasCoord = {
24+
x1: number
25+
y1: number
26+
x2: number
27+
y2: number
28+
c1: number
29+
c2: number
30+
el: {
31+
x: number
32+
y: number
33+
sizeX: number
34+
sizeY: number
35+
_dragId: string | number
36+
[key: string]: any
37+
}
38+
}
39+
40+
export type DashboardInfo = {
41+
dataState: string,
42+
optType: string,
43+
id: number,
44+
name: string,
45+
pid: number,
46+
status: number,
47+
type: string,
48+
mobileLayout: boolean,
49+
}

0 commit comments

Comments
 (0)