fix: 消除编辑时provide警告

This commit is contained in:
xiangmaoshuo 2023-03-16 18:13:48 +08:00
parent 93350f0f6a
commit 2d4bd34e56
2 changed files with 8 additions and 3 deletions

View File

@ -83,7 +83,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, computed } from 'vue' import { onMounted, computed, provide } from 'vue'
import { chartColors } from '@/settings/chartThemes/index' import { chartColors } from '@/settings/chartThemes/index'
import { MenuEnum } from '@/enums/editPageEnum' import { MenuEnum } from '@/enums/editPageEnum'
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d' import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
@ -91,7 +91,7 @@ import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle,
import { useContextMenu } from '@/views/chart/hooks/useContextMenu.hook' import { useContextMenu } from '@/views/chart/hooks/useContextMenu.hook'
import { MenuOptionsItemType } from '@/views/chart/hooks/useContextMenu.hook.d' import { MenuOptionsItemType } from '@/views/chart/hooks/useContextMenu.hook.d'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { SCALE_KEY } from '@/views/preview/hooks/useScale.hook'
import { useLayout } from './hooks/useLayout.hook' import { useLayout } from './hooks/useLayout.hook'
import { useAddKeyboard } from '../hooks/useKeyboard.hook' import { useAddKeyboard } from '../hooks/useKeyboard.hook'
import { dragHandle, dragoverHandle, mousedownHandleUnStop, useMouseHandle } from './hooks/useDrag.hook' import { dragHandle, dragoverHandle, mousedownHandleUnStop, useMouseHandle } from './hooks/useDrag.hook'
@ -108,6 +108,9 @@ import { EditTools } from './components/EditTools'
const chartEditStore = useChartEditStore() const chartEditStore = useChartEditStore()
const { handleContextMenu } = useContextMenu() const { handleContextMenu } = useContextMenu()
// scale
provide(SCALE_KEY, null);
// //
useLayout() useLayout()

View File

@ -15,7 +15,9 @@ export const useScale = (localStorageInfo: ChartEditStorageType) => {
provide(SCALE_KEY, scaleRef); provide(SCALE_KEY, scaleRef);
const updateScaleRef = (scale: { width: number; height: number }) => { const updateScaleRef = (scale: { width: number; height: number }) => {
scaleRef.value = scale // 这里需要解构保证赋值给scaleRef的为一个新对象
// 因为scale始终为同一引用
scaleRef.value = { ...scale }
} }
// 屏幕适配 // 屏幕适配