perf: 优化缩放交互

This commit is contained in:
奔跑的面条 2023-03-15 20:58:09 +08:00
parent 8f0f9ea334
commit f3bfdeaccd

View File

@ -13,10 +13,11 @@
<!-- 缩放比例 --> <!-- 缩放比例 -->
<n-select <n-select
:disabled="lockScale" ref="selectInstRef"
class="scale-btn" class="scale-btn"
v-model:value="filterValue" v-model:value="filterValue"
size="mini" size="mini"
:disabled="lockScale"
:options="filterOptions" :options="filterOptions"
@update:value="selectHandle" @update:value="selectHandle"
></n-select> ></n-select>
@ -52,6 +53,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { SelectInst } from 'naive-ui'
import { reactive, ref, toRefs, watchEffect } from 'vue' import { reactive, ref, toRefs, watchEffect } from 'vue'
import { icon } from '@/plugins' import { icon } from '@/plugins'
import { EditHistory } from '../EditHistory/index' import { EditHistory } from '../EditHistory/index'
@ -59,15 +61,18 @@ import EditShortcutKey from '../EditShortcutKey/index.vue'
import { useDesignStore } from '@/store/modules/designStore/designStore' import { useDesignStore } from '@/store/modules/designStore/designStore'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d' import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
const { LockClosedOutlineIcon, LockOpenOutlineIcon } = icon.ionicons5 const { LockClosedOutlineIcon, LockOpenOutlineIcon } = icon.ionicons5
// //
const designStore = useDesignStore() const designStore = useDesignStore()
const themeColor = ref(designStore.getAppTheme) const themeColor = ref(designStore.getAppTheme)
const chartLayoutStore = useChartLayoutStore()
const chartEditStore = useChartEditStore() const chartEditStore = useChartEditStore()
const { lockScale, scale } = toRefs(chartEditStore.getEditCanvas) const { lockScale, scale } = toRefs(chartEditStore.getEditCanvas)
const selectInstRef = ref<SelectInst | null>(null)
// //
let filterOptions = [ let filterOptions = [
@ -98,7 +103,9 @@ const filterValue = ref('')
// //
const selectHandle = (v: number) => { const selectHandle = (v: number) => {
selectInstRef.value?.blur()
if (v === 0) { if (v === 0) {
chartLayoutStore.setItemUnHandle(ChartLayoutStoreEnum.RE_POSITION_CANVAS, true)
chartEditStore.computedScale() chartEditStore.computedScale()
return return
} }