index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <div class="go-edit-bottom">
  3. <n-space>
  4. <!-- 历史记录 -->
  5. <edit-history></edit-history>
  6. <!-- CTRL按键触发展示 -->
  7. <n-text id="keyboard-dress-show" depth="3"></n-text>
  8. <n-divider vertical />
  9. <edit-data-sync></edit-data-sync>
  10. </n-space>
  11. <n-space class="bottom-ri">
  12. <!-- 快捷键提示 -->
  13. <edit-shortcut-key />
  14. <!-- 缩放比例 -->
  15. <n-select
  16. :disabled="lockScale"
  17. class="scale-btn"
  18. v-model:value="filterValue"
  19. size="mini"
  20. :options="filterOptions"
  21. @update:value="selectHandle"
  22. ></n-select>
  23. <!-- 锁定缩放 -->
  24. <n-tooltip trigger="hover">
  25. <template #trigger>
  26. <n-button @click="lockHandle" text>
  27. <n-icon class="lock-icon" :class="{ color: lockScale }" size="18" :depth="2">
  28. <lock-closed-outline-icon v-if="lockScale"></lock-closed-outline-icon>
  29. <lock-open-outline-icon v-else></lock-open-outline-icon>
  30. </n-icon>
  31. </n-button>
  32. </template>
  33. <span>{{ lockScale ? '解锁' : '锁定' }}当前比例</span>
  34. </n-tooltip>
  35. <!-- 拖动 -->
  36. <n-slider
  37. class="scale-slider"
  38. v-model:value="sliderValue"
  39. :default-value="50"
  40. :min="10"
  41. :max="200"
  42. :step="5"
  43. :format-tooltip="sliderFormatTooltip"
  44. :disabled="lockScale"
  45. :marks="sliderMaks"
  46. @update:value="sliderHandle"
  47. ></n-slider>
  48. </n-space>
  49. </div>
  50. </template>
  51. <script setup lang="ts">
  52. import { reactive, ref, toRefs, watchEffect } from 'vue'
  53. import { icon } from '@/plugins'
  54. import { EditHistory } from '../EditHistory/index'
  55. import { EditShortcutKey } from '../EditShortcutKey/index'
  56. import { EditDataSync } from '../EditDataSync/index'
  57. import { useDesignStore } from '@/store/modules/designStore/designStore'
  58. import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
  59. import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
  60. const { LockClosedOutlineIcon, LockOpenOutlineIcon } = icon.ionicons5
  61. // 全局颜色
  62. const designStore = useDesignStore()
  63. const themeColor = ref(designStore.getAppTheme)
  64. const chartEditStore = useChartEditStore()
  65. const { lockScale, scale } = toRefs(chartEditStore.getEditCanvas)
  66. // 缩放选项
  67. let filterOptions = [
  68. {
  69. label: '200%',
  70. value: 200
  71. },
  72. {
  73. label: '150%',
  74. value: 150
  75. },
  76. {
  77. label: '100%',
  78. value: 100
  79. },
  80. {
  81. label: '50%',
  82. value: 50
  83. },
  84. {
  85. label: '自适应',
  86. value: 0
  87. }
  88. ]
  89. // 选择值
  90. const filterValue = ref('')
  91. // 用户自选择
  92. const selectHandle = (v: number) => {
  93. if (v === 0) {
  94. chartEditStore.computedScale()
  95. return
  96. }
  97. chartEditStore.setScale(v / 100)
  98. }
  99. // 点击锁处理
  100. const lockHandle = () => {
  101. chartEditStore.setEditCanvas(EditCanvasTypeEnum.LOCK_SCALE, !lockScale.value)
  102. }
  103. // 拖动
  104. const sliderValue = ref(100)
  105. // 拖动格式化
  106. const sliderFormatTooltip = (v: string) => `${v}%`
  107. // 拖动处理
  108. const sliderHandle = (v: number) => {
  109. chartEditStore.setScale(v / 100)
  110. }
  111. const sliderMaks = reactive({
  112. 100: ''
  113. })
  114. // 监听 scale 变化
  115. watchEffect(() => {
  116. const value = (scale.value * 100).toFixed(0)
  117. filterValue.value = `${value}%`
  118. sliderValue.value = parseInt(value)
  119. })
  120. </script>
  121. <style lang="scss" scoped>
  122. $min-width: 500px;
  123. $max-width: 670px;
  124. @include go('edit-bottom') {
  125. width: 100%;
  126. min-width: $min-width;
  127. min-width: $max-width;
  128. padding: 0 10px;
  129. display: flex;
  130. align-items: center;
  131. justify-content: space-between;
  132. padding: 0 10px;
  133. width: 100%;
  134. min-width: $min-width;
  135. height: 40px;
  136. .bottom-ri {
  137. position: relative;
  138. top: 15px;
  139. .lock-icon {
  140. padding-top: 4px;
  141. &.color {
  142. color: v-bind('themeColor');
  143. }
  144. }
  145. .scale-btn {
  146. width: 90px;
  147. font-size: 12px;
  148. @include deep() {
  149. .n-base-selection-label {
  150. padding: 3px;
  151. }
  152. }
  153. }
  154. .scale-slider {
  155. position: relative;
  156. top: -4px;
  157. width: 100px;
  158. }
  159. }
  160. }
  161. </style>