编辑区域结构调整

This commit is contained in:
pipipi-pikachu 2020-12-26 10:29:39 +08:00
parent 626eb622f8
commit be74d0b9ca
5 changed files with 80 additions and 73 deletions

View File

@ -28,10 +28,10 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { PropType } from 'vue' import { PropType, defineComponent } from 'vue'
import { ContextmenuItem } from './types' import { ContextmenuItem } from './types'
export default { export default defineComponent({
name: 'contextmenu-content', name: 'contextmenu-content',
props: { props: {
menus: { menus: {
@ -47,7 +47,7 @@ export default {
required: true, required: true,
}, },
}, },
} })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -59,8 +59,8 @@ $subMenuWidth: 120px;
width: $menuWidth; width: $menuWidth;
padding: 5px 0; padding: 5px 0;
background: #fff; background: #fff;
border: 1px solid #ccc; border: 1px solid #eee;
box-shadow: 3px 3px 3px rgba(#000, 0.3); box-shadow: 3px 3px 3px rgba(#000, 0.15);
border-radius: 2px; border-radius: 2px;
list-style: none; list-style: none;
margin: 0; margin: 0;
@ -69,7 +69,7 @@ $subMenuWidth: 120px;
padding: 0 20px; padding: 0 20px;
color: #555; color: #555;
font-size: 12px; font-size: 12px;
transition: all 0.2s; transition: all .1s;
white-space: nowrap; white-space: nowrap;
height: $menuHeight; height: $menuHeight;
line-height: $menuHeight; line-height: $menuHeight;

View File

@ -17,7 +17,7 @@ export default defineComponent({
}, },
gridColor: { gridColor: {
type: String, type: String,
default: 'rgba(100, 100, 100, 0.2)', default: 'rgba(100, 100, 100, 0.1)',
}, },
}, },
setup(props) { setup(props) {

View File

@ -5,7 +5,7 @@
> >
<template v-if="showGridLines"> <template v-if="showGridLines">
<GridLines /> <GridLines />
<GridLines :gridSize="100" gridColor="rgba(100, 100, 100, 0.3)" /> <GridLines :gridSize="100" gridColor="rgba(100, 100, 100, 0.35)" />
</template> </template>
</div> </div>
</template> </template>

View File

@ -8,12 +8,15 @@
v-click-outside="removeEditorAreaFocus" v-click-outside="removeEditorAreaFocus"
> >
<div <div
class="operates" class="viewport-wrapper"
:style="{ :style="{
width: viewportStyles.width + 'px',
height: viewportStyles.height + 'px',
left: viewportStyles.left + 'px', left: viewportStyles.left + 'px',
top: viewportStyles.top + 'px', top: viewportStyles.top + 'px',
}" }"
> >
<div class="operates">
<AlignmentLine <AlignmentLine
v-for="(line, index) in alignmentLines" v-for="(line, index) in alignmentLines"
:key="index" :key="index"
@ -37,18 +40,18 @@
:rotateElement="rotateElement" :rotateElement="rotateElement"
:scaleElement="scaleElement" :scaleElement="scaleElement"
/> />
<SlideBackground
:style="{
width: viewportStyles.width * canvasScale + 'px',
height: viewportStyles.height * canvasScale + 'px',
}"
/>
</div> </div>
<div <div
class="viewport" class="viewport"
ref="viewportRef" ref="viewportRef"
:style="{ :style="{ transform: `scale(${canvasScale})` }"
width: viewportStyles.width + 'px',
height: viewportStyles.height + 'px',
left: viewportStyles.left + 'px',
top: viewportStyles.top + 'px',
transform: `scale(${canvasScale})`,
}"
> >
<MouseSelection <MouseSelection
v-if="mouseSelectionState.isShow" v-if="mouseSelectionState.isShow"
@ -58,9 +61,6 @@
:height="mouseSelectionState.height" :height="mouseSelectionState.height"
:quadrant="mouseSelectionState.quadrant" :quadrant="mouseSelectionState.quadrant"
/> />
<SlideBackground />
<EditableElement <EditableElement
v-for="(element, index) in elementList" v-for="(element, index) in elementList"
:key="element.id" :key="element.id"
@ -71,6 +71,7 @@
/> />
</div> </div>
</div> </div>
</div>
</template> </template>
<script lang="ts"> <script lang="ts">
@ -173,6 +174,11 @@ export default defineComponent({
else if(e.deltaY < 0) throttleScaleCanvas('+') else if(e.deltaY < 0) throttleScaleCanvas('+')
} }
const showGridLines = computed(() => store.state.showGridLines)
const toggleGridLines = () => {
store.commit(MutationTypes.SET_GRID_LINES_STATE, !showGridLines.value)
}
const contextmenus = (): ContextmenuItem[] => { const contextmenus = (): ContextmenuItem[] => {
return [ return [
{ {
@ -185,6 +191,13 @@ export default defineComponent({
subText: 'Ctrl + V', subText: 'Ctrl + V',
handler: pasteElement, handler: pasteElement,
}, },
{
text: '网格参考线',
children: [
{ text: '网格线', handler: toggleGridLines },
{ text: '参考线' },
],
},
{ {
text: '清空本页', text: '清空本页',
handler: deleteAllElements, handler: deleteAllElements,
@ -226,13 +239,14 @@ export default defineComponent({
background-color: #f9f9f9; background-color: #f9f9f9;
position: relative; position: relative;
} }
.viewport { .viewport-wrapper {
position: absolute; position: absolute;
transform-origin: 0 0;
background-color: #fff;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, .1); box-shadow: 0 0 20px 0 rgba(0, 0, 0, .1);
} }
.operates { .viewport {
position: absolute; position: absolute;
top: 0;
left: 0;
transform-origin: 0 0;
} }
</style> </style>

View File

@ -18,7 +18,6 @@
<IconFont class="handler-item viewport-size" type="icon-minus" @click="scaleCanvas('-')" /> <IconFont class="handler-item viewport-size" type="icon-minus" @click="scaleCanvas('-')" />
<span class="text">{{canvasScalePercentage}}</span> <span class="text">{{canvasScalePercentage}}</span>
<IconFont class="handler-item viewport-size" type="icon-plus" @click="scaleCanvas('+')" /> <IconFont class="handler-item viewport-size" type="icon-plus" @click="scaleCanvas('+')" />
<IconFont class="handler-item viewport-size" type="icon-number" @click="toggleGridLines()" />
</div> </div>
</div> </div>
</template> </template>
@ -26,7 +25,7 @@
<script lang="ts"> <script lang="ts">
import { defineComponent, computed } from 'vue' import { defineComponent, computed } from 'vue'
import { useStore } from 'vuex' import { useStore } from 'vuex'
import { MutationTypes, State } from '@/store' import { State } from '@/store'
import useScaleCanvas from '@/hooks/useScaleCanvas' import useScaleCanvas from '@/hooks/useScaleCanvas'
import useHistorySnapshot from '@/hooks/useHistorySnapshot' import useHistorySnapshot from '@/hooks/useHistorySnapshot'
@ -35,7 +34,6 @@ export default defineComponent({
setup() { setup() {
const store = useStore<State>() const store = useStore<State>()
const canvasScale = computed(() => store.state.canvasScale) const canvasScale = computed(() => store.state.canvasScale)
const showGridLines = computed(() => store.state.showGridLines)
const canUndo = computed(() => store.getters.canUndo) const canUndo = computed(() => store.getters.canUndo)
const canRedo = computed(() => store.getters.canRedo) const canRedo = computed(() => store.getters.canRedo)
@ -44,14 +42,9 @@ export default defineComponent({
const { scaleCanvas } = useScaleCanvas() const { scaleCanvas } = useScaleCanvas()
const { redo, undo } = useHistorySnapshot() const { redo, undo } = useHistorySnapshot()
const toggleGridLines = () => {
store.commit(MutationTypes.SET_GRID_LINES_STATE, !showGridLines.value)
}
return { return {
scaleCanvas, scaleCanvas,
canvasScalePercentage, canvasScalePercentage,
toggleGridLines,
canUndo, canUndo,
canRedo, canRedo,
redo, redo,