diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index d4d44684..e3808633 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -32,6 +32,7 @@ "password_reset_successful": "Password reset successful" }, "dashboard": { + "add_component_tips": "Select components from the top toolbar and add them here to create a dashboard", "add_view": "Add Chart", "delete_dashboard_warn": "Delete This Dashboard: {0}", "rename_dashboard": "Rename Dashboard", diff --git a/frontend/src/i18n/zh-CN.json b/frontend/src/i18n/zh-CN.json index b8ff7f19..05911ac2 100644 --- a/frontend/src/i18n/zh-CN.json +++ b/frontend/src/i18n/zh-CN.json @@ -34,6 +34,7 @@ "password_reset_successful": "重置密码成功" }, "dashboard": { + "add_component_tips": "从顶部工具栏中选择组件,添加到这里创建仪表板", "add_view": "添加图表", "delete_dashboard_warn": "是否删除仪表板:{0}", "rename_dashboard": "重命名仪表板", diff --git a/frontend/src/stores/dashboard/dashboard.ts b/frontend/src/stores/dashboard/dashboard.ts index b4e718b8..854aa516 100644 --- a/frontend/src/stores/dashboard/dashboard.ts +++ b/frontend/src/stores/dashboard/dashboard.ts @@ -35,6 +35,9 @@ export const dashboardStore = defineStore('dashboard', { }, }, actions: { + setFullscreenFlag(val: boolean) { + this.fullscreenFlag = val + }, setCurComponent(value: any) { this.curComponent = value this.curComponentId = value && value.id ? value.id : null diff --git a/frontend/src/views/dashboard/canvas/CanvasCore.vue b/frontend/src/views/dashboard/canvas/CanvasCore.vue index b22c2b60..3f7eeee1 100644 --- a/frontend/src/views/dashboard/canvas/CanvasCore.vue +++ b/frontend/src/views/dashboard/canvas/CanvasCore.vue @@ -8,7 +8,10 @@ import { findComponent } from '@/views/dashboard/components/component-list.ts' import { storeToRefs } from 'pinia' import { useEmitt, useEmittLazy } from '@/utils/useEmitt.ts' import html2canvas from 'html2canvas' +import EmptyBackground from '@/views/dashboard/common/EmptyBackground.vue' +import { useI18n } from 'vue-i18n' +const { t } = useI18n() const dashboardStore = dashboardStoreWithOut() const canvasLocked = ref(false) // Is the canvas movement locked, Default false const emits = defineEmits(['parentAddItemBox']) @@ -1174,6 +1177,11 @@ defineExpose({ @mouseup="endMove()" @mousemove="moving()" > + +import { dashboardStoreWithOut } from '@/stores/dashboard/dashboard.ts' + +const dashboardStore = dashboardStoreWithOut() +import { nextTick, onBeforeUnmount, onMounted } from 'vue' +import { useEmitt } from '@/utils/useEmitt.ts' +defineProps({ + themes: { + type: String, + default: 'light', + }, + componentType: { + type: String, + default: 'button', + }, + showPosition: { + required: false, + type: String, + default: 'preview', + }, +}) + +const fullscreenChange = () => { + const isFullscreen = !!document.fullscreenElement + dashboardStore.setFullscreenFlag(isFullscreen) + setTimeout(() => { + useEmitt().emitter.emit('custom-canvas-resize') + }, 100) +} + +const toggleFullscreen = () => { + const bodyNode = document.querySelector('body') + if (!document.fullscreenElement) { + bodyNode?.requestFullscreen() + } else { + document.exitFullscreen() + } +} + +// 针对钉钉windows版无法退出全屏问题 这里主动退出 +const handleKeydown = (event) => { + if (event.key === 'Escape' && document.fullscreenElement) { + document.exitFullscreen() + } +} + +onMounted(() => { + document.addEventListener('fullscreenchange', fullscreenChange) + document.addEventListener('keydown', handleKeydown) +}) + +onBeforeUnmount(() => { + document.removeEventListener('fullscreenchange', fullscreenChange) + document.removeEventListener('keydown', handleKeydown) +}) + +defineExpose({ + toggleFullscreen, +}) + + + + + diff --git a/frontend/src/views/dashboard/css/CanvasStyle.less b/frontend/src/views/dashboard/css/CanvasStyle.less index 407a5686..c321082f 100644 --- a/frontend/src/views/dashboard/css/CanvasStyle.less +++ b/frontend/src/views/dashboard/css/CanvasStyle.less @@ -2,6 +2,7 @@ position: relative; user-select: none; width: 100%; + height: 100%; * { box-sizing: border-box; diff --git a/frontend/src/views/dashboard/editor/DashboardEditor.vue b/frontend/src/views/dashboard/editor/DashboardEditor.vue index 99e11e08..8dae47c2 100644 --- a/frontend/src/views/dashboard/editor/DashboardEditor.vue +++ b/frontend/src/views/dashboard/editor/DashboardEditor.vue @@ -2,7 +2,7 @@ import CanvasCore from '@/views/dashboard/canvas/CanvasCore.vue' import { nextTick, onMounted, type PropType, ref } from 'vue' import type { CanvasItem } from '@/utils/canvas.ts' -import { useEmittLazy } from '@/utils/useEmitt.ts' +import { useEmitt, useEmittLazy } from '@/utils/useEmitt.ts' const canvasCoreRef = ref(null) const dashboardEditorRef = ref(null) @@ -85,6 +85,11 @@ const addItemToBox = (item: CanvasItem) => { canvasCoreRef.value.addItemBox(item) } +useEmitt({ + name: 'custom-canvas-resize', + callback: canvasSizeInit, +}) + defineExpose({ canvasSizeInit, addItemToBox, diff --git a/frontend/src/views/dashboard/editor/Toolbar.vue b/frontend/src/views/dashboard/editor/Toolbar.vue index 8e39bb1c..fe4e774d 100644 --- a/frontend/src/views/dashboard/editor/Toolbar.vue +++ b/frontend/src/views/dashboard/editor/Toolbar.vue @@ -14,10 +14,11 @@ import icon_redo_outlined from '@/assets/svg/icon_redo_outlined.svg' import icon_arrow_left_outlined from '@/assets/svg/icon_arrow-left_outlined.svg' import { saveDashboardResource } from '@/views/dashboard/utils/canvasUtils.ts' import ChatChartSelection from '@/views/dashboard/editor/ChatChartSelection.vue' - +import icon_pc_outlined from '@/assets/svg/icon_pc_outlined.svg' +const fullScreeRef = ref(null) const { t } = useI18n() const dashboardStore = dashboardStoreWithOut() -const { dashboardInfo } = storeToRefs(dashboardStore) +const { dashboardInfo, fullscreenFlag } = storeToRefs(dashboardStore) const snapshotStore = snapshotStoreWithOut() const { snapshotIndex } = storeToRefs(snapshotStore) @@ -30,6 +31,7 @@ const openViewDialog = () => { } import cloneDeep from 'lodash/cloneDeep' +import SQFullscreen from '@/views/dashboard/common/SQFullscreen.vue' let nameEdit = ref(false) let inputName = ref('') @@ -136,10 +138,16 @@ const addChatChart = (views: any) => { emits('addComponent', 'SQView', cloneDeep(view)) }) } + +const previewInner = () => { + if (fullScreeRef.value) { + fullScreeRef.value.toggleFullscreen() + } +} - + @@ -204,6 +212,14 @@ const addChatChart = (views: any) => { + + + + + + + {{ t('dashboard.preview') }} + { @add-chat-chart="addChatChart" @finish="chartSelectionFinish" > +