Skip to content

Commit b170450

Browse files
committed
feat: dashboard preview single
1 parent 7b2695e commit b170450

File tree

8 files changed

+121
-42
lines changed

8 files changed

+121
-42
lines changed
Lines changed: 1 addition & 1 deletion
Loading

frontend/src/components/layout/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ const name = ref('admin')
171171
const activeMenu = computed(() => route.path)
172172
const routerList = computed(() => {
173173
return router.getRoutes().filter(route => {
174-
return !route.path.includes('canvas') && route.path !== '/login' && !route.path.includes('/system') && !route.redirect && route.path !== '/:pathMatch(.*)*' && !route.path.includes('dsTable')
174+
return !route.path.includes('canvas') &&!route.path.includes('preview') && route.path !== '/login' && !route.path.includes('/system') && !route.redirect && route.path !== '/:pathMatch(.*)*' && !route.path.includes('dsTable')
175175
})
176176
})
177177

frontend/src/router/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import login from "@/views/login/index.vue";
66
import chat from "@/views/chat/index.vue";
77
import ds from "@/views/ds/index.vue";
88
import DashboardEditor from "@/views/dashboard/editor/index.vue";
9+
import DashboardPreview from "@//views/dashboard/preview/SQPreviewSingle.vue";
910
import Dashboard from "@/views/dashboard/index.vue";
1011
import Model from "@/views/system/model/index.vue";
1112
// import User from "@/views/system/user/index.vue";
@@ -75,6 +76,12 @@ const router = createRouter({
7576
component: DashboardEditor,
7677
meta: { title: "canvas", icon: "dashboard" },
7778
},
79+
{
80+
path: "/dashboard-preview",
81+
name: "preview",
82+
component: DashboardPreview,
83+
meta: { title: "DashboardPreview", icon: "dashboard" },
84+
},
7885
/* {
7986
path: "/setting",
8087
component: Layout,

frontend/src/views/dashboard/preview/SQComponentWrapper.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ const viewDemoInnerId = computed(() => 'enlarge-inner-content-' + configItem.val
5656
<style lang="less" scoped>
5757
.wrapper-outer {
5858
position: absolute;
59+
5960
.wrapper-inner {
6061
width: 100%;
6162
height: 100%;
6263
position: relative;
64+
background: #fff;
6365
background-size: 100% 100% !important;
6466
6567
.wrapper-inner-adaptor {

frontend/src/views/dashboard/preview/SQPreview.vue

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,10 @@ const props = defineProps({
4646
}
4747
})
4848
49-
const { canvasStyleData, componentData, showPosition,
50-
canvasId
51-
} = toRefs(props)
49+
const { canvasStyleData, componentData, showPosition, canvasId} = toRefs(props)
5250
const domId = 'preview-' + canvasId.value
5351
const previewCanvas = ref(null)
54-
const renderReady = ref(false)
52+
const renderReady = ref(true)
5553
const state = reactive({
5654
initState: true,
5755
scrollMain: 0
@@ -64,7 +62,7 @@ const baseHeight = ref(0)
6462
const baseMarginLeft = ref(0)
6563
const baseMarginTop = ref(0)
6664
const canvasStyle = computed(() => {
67-
return {}
65+
return {background: '#f5f6f7'}
6866
})
6967
7068
const restore = () => {
@@ -83,9 +81,9 @@ function nowItemStyle(item: CanvasItem) {
8381
const sizeInit = () => {
8482
if (previewCanvas.value) {
8583
//@ts-ignore
86-
const screenWidth = dashboardEditorRef.value.offsetWidth
84+
const screenWidth = previewCanvas.value.offsetWidth
8785
//@ts-ignore
88-
const screenHeight = dashboardEditorRef.value.offsetHeight
86+
const screenHeight = previewCanvas.value.offsetHeight
8987
baseMarginLeft.value = 10
9088
baseMarginTop.value = 10
9189
baseWidth.value = (screenWidth - baseMarginLeft.value) / props.baseMatrixCount.x - baseMarginLeft.value
@@ -97,12 +95,9 @@ const sizeInit = () => {
9795
9896
9997
onMounted(() => {
100-
window.addEventListener('resize', sizeInit)
101-
const erd = elementResizeDetectorMaker()
98+
sizeInit()
10299
//@ts-ignore
103-
erd.listenTo(document.getElementById(domId), () => {
104-
restore()
105-
})
100+
elementResizeDetectorMaker().listenTo(document.getElementById(domId), sizeInit)
106101
})
107102
108103
defineExpose({
@@ -111,13 +106,7 @@ defineExpose({
111106
</script>
112107

113108
<template>
114-
<div
115-
:id="domId"
116-
class="canvas-container"
117-
:style="canvasStyle"
118-
ref="previewCanvas"
119-
v-if="state.initState"
120-
>
109+
<div :id="domId" class="canvas-container" :style="canvasStyle" ref="previewCanvas" v-if="state.initState">
121110
<template v-if="renderReady">
122111
<SQComponentWrapper
123112
v-for="(item, index) in componentData"

frontend/src/views/dashboard/preview/SQPreviewHead.vue

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import dashboardInfoSvg from '@/assets/svg/dashboard-info.svg'
33
import icon_pc_outlined from '@/assets/svg/icon_pc_outlined.svg'
44
import icon_edit_outlined from '@/assets/svg/icon_edit_outlined.svg'
55
import DashboardDetailInfo from "@/views/dashboard/common/DashboardDetailInfo.vue";
6-
const emit = defineEmits(['reload', 'download', 'downloadAsAppTemplate'])
7-
const preview = () => {}
8-
const edit = () =>{}
9-
106
11-
defineProps({
7+
const emit = defineEmits(['reload', 'download', 'downloadAsAppTemplate'])
8+
const preview = () => {
9+
window.open(`#/dashboard-preview?resourceId=${props.dashboardInfo.id}`, '_blank')
10+
}
11+
const edit = () => {
12+
window.open(`#/canvas?resourceId=${props.dashboardInfo.id}`, '_blank')
13+
}
14+
const props = defineProps({
1215
dashboardInfo: {
1316
type: Object,
1417
required: true
@@ -20,28 +23,35 @@ defineProps({
2023
<template>
2124
<div class="preview-head flex-align-center">
2225
<div class="canvas-name ellipsis">{{ dashboardInfo.name }}</div>
23-
<el-divider style="margin: 5px 10px 0 17px" direction="vertical" />
26+
<el-divider style="margin: 5px 10px 0 17px" direction="vertical"/>
2427
<span class="create-area" style="line-height: 22px">Creator:{{ dashboardInfo.createName }}</span>
2528
<div style="padding-top: 4px" class="create-area flex-align-center">
2629
<el-popover show-arrow :offset="8" placement="bottom" width="400" trigger="hover">
2730
<template #reference>
28-
<el-icon class="info-tips"><dashboardInfoSvg class="svg-icon" /></el-icon>
31+
<el-icon class="info-tips">
32+
<dashboardInfoSvg class="svg-icon"/>
33+
</el-icon>
2934
</template>
3035
<DashboardDetailInfo :dashboard-info="dashboardInfo"></DashboardDetailInfo>
3136
</el-popover>
3237
</div>
3338
<div class="canvas-opt-button">
3439
<el-button secondary @click="preview">
3540
<template #icon>
36-
<icon name="icon_pc_outlined"><icon_pc_outlined class="svg-icon" /></icon>
41+
<icon name="icon_pc_outlined">
42+
<icon_pc_outlined class="svg-icon"/>
43+
</icon>
3744
</template>
3845
Preview
3946
</el-button>
4047
<el-button class="custom-button" type="primary" @click="edit">
4148
<template #icon>
42-
<Icon name="icon_edit_outlined"><icon_edit_outlined class="svg-icon" /></Icon>
49+
<Icon name="icon_edit_outlined">
50+
<icon_edit_outlined class="svg-icon"/>
51+
</Icon>
4352
</template>
44-
Edit</el-button
53+
Edit
54+
</el-button
4555
>
4656
</div>
4757
</div>
@@ -55,6 +65,7 @@ defineProps({
5565
.ed-icon {
5666
margin-right: 8px;
5767
}
68+
5869
.arrow-right_icon {
5970
position: absolute;
6071
right: 12px;
@@ -66,18 +77,21 @@ defineProps({
6677
}
6778
}
6879
}
80+
6981
.preview-head {
7082
display: flex;
7183
width: 100%;
7284
min-width: 300px;
7385
height: 56px;
7486
padding: 16px 24px;
7587
border-bottom: 1px solid rgba(31, 35, 41, 0.15);
88+
7689
.canvas-name {
7790
max-width: 200px;
7891
font-size: 16px;
7992
font-weight: 500;
8093
}
94+
8195
.canvas-have-update {
8296
background-color: rgba(52, 199, 36, 0.2);
8397
color: rgba(44, 169, 31, 1);
@@ -88,27 +102,32 @@ defineProps({
88102
padding: 0 4px;
89103
margin-left: 8px;
90104
}
105+
91106
.custom-icon {
92107
cursor: pointer;
93108
margin-left: 8px;
94109
}
110+
95111
.create-area {
96112
color: #646a73;
97113
font-weight: 400;
98114
font-size: 14px;
99115
}
116+
100117
.canvas-opt-button {
101118
display: flex;
102119
justify-content: right;
103120
align-items: center;
104121
flex: 1;
122+
105123
.head-more-icon {
106124
color: #1f2329;
107125
margin-left: 12px;
108126
cursor: pointer;
109127
font-size: 20px;
110128
border-radius: 4px;
111129
position: relative;
130+
112131
&:hover {
113132
&::after {
114133
content: '';
@@ -124,6 +143,7 @@ defineProps({
124143
}
125144
}
126145
}
146+
127147
.info-tips {
128148
margin-left: 4px;
129149
font-size: 16px;

frontend/src/views/dashboard/preview/SQPreviewShow.vue

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,11 @@ const previewCanvasContainer = ref(null)
1414
const dashboardPreview = ref(null)
1515
const slideShow = ref(true)
1616
const dataInitState = ref(true)
17-
const downloadStatus = ref(false)
1817
const state = reactive({
1918
canvasDataPreview: [],
2019
canvasStylePreview: {},
2120
canvasViewInfoPreview: {},
22-
dashboardInfo: {},
23-
showOffset: {
24-
top: 110,
25-
left: 280
26-
}
21+
dashboardInfo: {}
2722
})
2823
2924
const props = defineProps({
@@ -53,12 +48,9 @@ const rootManage = computed(() => {
5348
const mounted = computed(() => {
5449
return resourceTreeRef.value?.mounted
5550
})
56-
57-
5851
function createNew() {
5952
resourceTreeRef.value?.createNewObject()
6053
}
61-
6254
const loadCanvasData = (params: any) => {
6355
dataInitState.value = false
6456
load_resource_prepare({id: params.id},
@@ -128,8 +120,6 @@ defineExpose({
128120
:canvas-style-data="state.canvasStylePreview"
129121
:canvas-view-info="state.canvasViewInfoPreview"
130122
:show-position="showPosition"
131-
:download-status="downloadStatus"
132-
:show-linkage-button="false"
133123
></SQPreview>
134124
</div>
135125
</template>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<script setup lang="ts">
2+
3+
import SQPreview from "@/views/dashboard/preview/SQPreview.vue";
4+
import {load_resource_prepare} from "@/views/dashboard/utils/canvasUtils.ts";
5+
import {onMounted, reactive, ref} from "vue";
6+
import router from "@/router";
7+
8+
const previewCanvasContainer = ref(null)
9+
const dashboardPreview = ref(null)
10+
const dataInitState = ref(true)
11+
const downloadStatus = ref(false)
12+
const state = reactive({
13+
resourceId: null,
14+
canvasDataPreview: [],
15+
canvasStylePreview: {},
16+
canvasViewInfoPreview: {},
17+
dashboardInfo: {}
18+
})
19+
20+
onMounted(() => {
21+
//@ts-ignore
22+
state.resourceId = router.currentRoute.value.query.resourceId
23+
if (state.resourceId) {
24+
loadCanvasData({id: state.resourceId})
25+
}
26+
}
27+
)
28+
29+
30+
const loadCanvasData = (params: any) => {
31+
dataInitState.value = false
32+
load_resource_prepare({id: params.id},
33+
//@ts-ignore
34+
function ({dashboardInfo, canvasDataResult, canvasStyleResult, canvasViewInfoPreview}) {
35+
state.canvasDataPreview = canvasDataResult
36+
state.canvasStylePreview = canvasStyleResult
37+
state.canvasViewInfoPreview = canvasViewInfoPreview
38+
state.dashboardInfo = dashboardInfo
39+
dataInitState.value = true
40+
}
41+
)
42+
}
43+
</script>
44+
45+
<template>
46+
<div ref="previewCanvasContainer" class="content" id="sq-preview-content">
47+
<SQPreview
48+
ref="dashboardPreview"
49+
v-if="state.canvasStylePreview && dataInitState"
50+
:dashboard-info="state.dashboardInfo"
51+
:component-data="state.canvasDataPreview"
52+
:canvas-style-data="state.canvasStylePreview"
53+
:canvas-view-info="state.canvasViewInfoPreview"
54+
:download-status="downloadStatus"
55+
></SQPreview>
56+
</div>
57+
58+
</template>
59+
60+
<style scoped lang="less">
61+
.content {
62+
position: relative;
63+
display: flex;
64+
width: 100%;
65+
height: 100vh;
66+
overflow-x: hidden;
67+
overflow-y: auto;
68+
align-items: center;
69+
}
70+
71+
</style>

0 commit comments

Comments
 (0)