refactor(仪表板): 编辑界面组件改为跟随窗口大小缩放的模式 #10397

This commit is contained in:
wangjiahao 2024-07-02 15:54:37 +08:00
parent 02b999f414
commit 3e4eddfd54
4 changed files with 38 additions and 4 deletions

View File

@ -279,7 +279,7 @@ const { emitter } = useEmitt()
const curScale = computed(() => {
if (dashboardActive.value) {
return (canvasStyleData.value.scale * 1.5) / 100
return (canvasStyleData.value.scale * 1.2) / 100
} else {
return canvasStyleData.value.scale / 100
}
@ -287,7 +287,7 @@ const curScale = computed(() => {
const curBaseScale = computed(() => {
if (dashboardActive.value) {
return (dvMainStore.canvasStyleData.scale * 1.5) / 100
return (dvMainStore.canvasStyleData.scale * 1.2) / 100
} else {
return dvMainStore.canvasStyleData.scale / 100
}

View File

@ -234,6 +234,9 @@ export const dvMainStore = defineStore('dataVisualization', {
style.component['seniorStyleSetting'] || deepCopy(SENIOR_STYLE_SETTING_LIGHT)
this.canvasStyleData = style
},
setCanvasStyleScale(value) {
this.canvasStyleData.scale = value
},
setCanvasViewInfo(canvasViewInfo) {
this.canvasViewInfo = canvasViewInfo
},

View File

@ -520,6 +520,10 @@ export async function decompressionPre(params, callBack) {
callBack(deTemplateData)
}
export function isDashboard() {
return dvInfo.value.type === 'dashboard'
}
export function trackBarStyleCheck(element, trackbarStyle, _scale, trackMenuNumber) {
const { width, height } = element.style
const widthReal = width

View File

@ -10,7 +10,7 @@ import elementResizeDetectorMaker from 'element-resize-detector'
import { getCanvasStyle, syncShapeItemStyle } from '@/utils/style'
import { adaptCurThemeCommonStyle } from '@/utils/canvasStyle'
import CanvasCore from '@/components/data-visualization/canvas/CanvasCore.vue'
import { isMainCanvas } from '@/utils/canvasUtils'
import { isMainCanvas, isDashboard } from '@/utils/canvasUtils'
// change-begin
const props = defineProps({
@ -34,9 +34,15 @@ const props = defineProps({
canvasActive: {
type: Boolean,
default: true
},
outerScale: {
type: Number,
required: false,
default: 1
}
})
const { canvasStyleData, componentData, canvasViewInfo, canvasId, canvasActive } = toRefs(props)
const { canvasStyleData, componentData, canvasViewInfo, canvasId, canvasActive, outerScale } =
toRefs(props)
const domId = ref('de-canvas-' + canvasId.value)
// change-end
@ -46,6 +52,9 @@ const { pcMatrixCount, curOriginThemes } = storeToRefs(dvMainStore)
const canvasOut = ref(null)
const canvasInner = ref(null)
const canvasInitStatus = ref(false)
const scaleWidth = ref(100)
const scaleHeight = ref(100)
const scaleMin = ref(100)
const state = reactive({
screenWidth: 1920,
@ -151,11 +160,29 @@ const canvasSizeInit = () => {
dashboardCanvasSizeInit()
nextTick(() => {
cyGridster.value.canvasSizeInit() //
//
scaleInit()
})
}
})
}
const scaleInit = () => {
nextTick(() => {
if (canvasOut.value) {
//divtableBox.value.clientWidth
let canvasWidth = canvasOut.value.clientWidth
let canvasHeight = canvasOut.value.clientHeight
scaleWidth.value = Math.floor((canvasWidth * 100) / canvasStyleData.value.width)
scaleHeight.value = Math.floor((canvasHeight * 100) / canvasStyleData.value.height)
scaleMin.value = Math.min(scaleWidth.value, scaleHeight.value)
if (isDashboard() && isMainCanvas(canvasId.value)) {
dvMainStore.setCanvasStyleScale(scaleMin.value)
}
}
})
}
const dashboardCanvasSizeInit = () => {
//divtableBox.value.clientWidth
state.screenWidth = canvasOut.value.clientWidth - 4