feat: 新增前进后退按钮,修改粘贴的位置问题

This commit is contained in:
mtrun 2022-03-28 11:38:44 +08:00
parent 7d5f607b92
commit 4b21f3a753
5 changed files with 95 additions and 25 deletions

View File

@ -1,15 +1,15 @@
<template> <template>
<n-layout-header bordered class="go-header"> <n-layout-header bordered class="go-header">
<header class="go-header-box"> <header class="go-header-box">
<div> <div class="header-item left">
<n-space> <n-space>
<slot name="left"></slot> <slot name="left"></slot>
</n-space> </n-space>
</div> </div>
<div> <div class="header-item center">
<slot name="center"></slot> <slot name="center"></slot>
</div> </div>
<div> <div class="header-item right">
<n-space> <n-space>
<slot name="ri-left"> </slot> <slot name="ri-left"> </slot>
<lang-select></lang-select> <lang-select></lang-select>
@ -31,11 +31,23 @@ import { ThemeColorSelect } from '@/components/ThemeColorSelect'
<style lang="scss" scoped> <style lang="scss" scoped>
@include go(header) { @include go(header) {
&-box { &-box {
display: flex; display: grid;
justify-content: space-between; grid-template-columns: repeat(3, 33.33%);
align-items: center; .header-item {
padding: 0 60px; display: flex;
align-items: center;
&.left {
justify-content: start;
}
&.center {
justify-content: center;
}
&.right {
justify-content: end;
}
}
height: $--header-height; height: $--header-height;
padding: 0 60px;
} }
} }
</style> </style>

View File

@ -7,7 +7,7 @@ import {
Trash as TrashIcon, Trash as TrashIcon,
Pencil as PencilIcon, Pencil as PencilIcon,
HammerOutline as HammerIcon, HammerOutline as HammerIcon,
DesktopOutline as DesktopOutlineIcon, DesktopOutline as DesktopOutlineIcon,
DownloadOutline as DownloadIcon, DownloadOutline as DownloadIcon,
Open as OpenIcon, Open as OpenIcon,
Send as SendIcon, Send as SendIcon,
@ -47,7 +47,9 @@ DesktopOutline as DesktopOutlineIcon,
Square as SquareIcon, Square as SquareIcon,
ColorPalette as ColorPaletteIcon, ColorPalette as ColorPaletteIcon,
Leaf as LeafIcon, Leaf as LeafIcon,
ColorWand as ColorWandIcon ColorWand as ColorWandIcon,
ArrowBack as ArrowBackIcon,
ArrowForward as ArrowForwardIcon
} from '@vicons/ionicons5' } from '@vicons/ionicons5'
import { import {
@ -172,7 +174,11 @@ const ionicons5 = {
// 气球 // 气球
LeafIcon, LeafIcon,
// 颜色 // 颜色
ColorWandIcon ColorWandIcon,
// 撤回
ArrowBackIcon,
// 前进
ArrowForwardIcon
} }
const carbon = { const carbon = {

View File

@ -351,8 +351,8 @@ export const useChartEditStore = defineStore({
// 生成新 id // 生成新 id
e.id = getUUID() e.id = getUUID()
// 偏移位置 // 偏移位置
e.attr.x = e.attr.x + 30 e.attr.x = this.getMousePosition.x + 30
e.attr.y = e.attr.y + 30 e.attr.y = this.getMousePosition.y + 30
return e return e
} }
const isCut = recordCharts.type === HistoryActionTypeEnum.CUT const isCut = recordCharts.type === HistoryActionTypeEnum.CUT

View File

@ -10,7 +10,18 @@
<n-space> <n-space>
<n-tooltip v-for="item in btnList" :key="item.key" placement="bottom" trigger="hover"> <n-tooltip v-for="item in btnList" :key="item.key" placement="bottom" trigger="hover">
<template #trigger> <template #trigger>
<n-button :type="styleHandle(item)" size="small" ghost @click="clickHandle(item)"> <n-button size="small" ghost :type="styleHandle(item)" @click="clickHandle(item)">
<component :is="item.icon"></component>
</n-button>
</template>
<span>{{ item.title }}</span>
</n-tooltip>
<n-divider vertical />
<n-tooltip v-for="item in historyList" :key="item.key" placement="bottom" trigger="hover">
<template #trigger>
<n-button size="small" ghost type="primary" :disabled="!item.select" @click="clickHistoryHandle(item)">
<component :is="item.icon"></component> <component :is="item.icon"></component>
</n-button> </n-button>
</template> </template>
@ -21,25 +32,33 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { toRefs, Ref, reactive } from 'vue' import { toRefs, Ref, reactive, computed } from 'vue'
import { renderIcon, goDialog, goHome } from '@/utils' import { renderIcon, goDialog, goHome } from '@/utils'
import { icon } from '@/plugins' import { icon } from '@/plugins'
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
import { useRemoveKeyboard } from '../hooks/useKeyboard.hook' import { useRemoveKeyboard } from '../hooks/useKeyboard.hook'
const { LayersIcon, BarChartIcon, PrismIcon, HomeIcon } = icon.ionicons5 import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore'
import { HistoryStackEnum } from '@/store/modules/chartHistoryStore/chartHistoryStore.d'
import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
const { LayersIcon, BarChartIcon, PrismIcon, HomeIcon, ArrowBackIcon, ArrowForwardIcon } = icon.ionicons5
const { setItem } = useChartLayoutStore() const { setItem } = useChartLayoutStore()
const { getLayers, getCharts, getDetails } = toRefs(useChartLayoutStore()) const { getLayers, getCharts, getDetails } = toRefs(useChartLayoutStore())
const chartEditStore = useChartEditStore()
const chartHistoryStore = useChartHistoryStore()
interface ItemType { interface ItemType<T> {
key: ChartLayoutStoreEnum key: T
select: Ref<boolean> | boolean select: Ref<boolean> | boolean
title: string title: string
icon: any icon: any
} }
const btnList = reactive<ItemType[]>([ const btnList = reactive<ItemType<ChartLayoutStoreEnum>[]>([
{ {
key: ChartLayoutStoreEnum.CHARTS, key: ChartLayoutStoreEnum.CHARTS,
select: getCharts, select: getCharts,
@ -60,19 +79,53 @@ const btnList = reactive<ItemType[]>([
} }
]) ])
const isBackStack = computed(()=> chartHistoryStore.getBackStack.length> 1)
const isForwardStack = computed(()=> chartHistoryStore.getForwardStack.length> 0)
const historyList = reactive<ItemType<HistoryStackEnum>[]>([
{
key: HistoryStackEnum.BACK_STACK,
//
select: isBackStack,
title: '后退',
icon: renderIcon(ArrowBackIcon)
},
{
key: HistoryStackEnum.FORWARD_STACK,
select: isForwardStack,
title: '前进',
icon: renderIcon(ArrowForwardIcon)
}
])
// store ContentConfigurations collapsed // store ContentConfigurations collapsed
const styleHandle = (item: ItemType) => { const styleHandle = (item: ItemType<ChartLayoutStoreEnum>) => {
if (item.key === ChartLayoutStoreEnum.DETAILS) { if (item.key === ChartLayoutStoreEnum.DETAILS) {
return item.select ? '' : 'primary' return item.select ? '' : 'primary'
} }
return item.select ? 'primary' : '' return item.select ? 'primary' : ''
} }
const clickHandle = (item: ItemType) => { //
const clickHandle = (item: ItemType<ChartLayoutStoreEnum>) => {
setItem(item.key, !item.select) setItem(item.key, !item.select)
} }
//
const clickHistoryHandle = (item: ItemType<HistoryStackEnum>) => {
switch (item.key) {
case HistoryStackEnum.BACK_STACK:
chartEditStore.setBack()
break;
case HistoryStackEnum.FORWARD_STACK:
chartEditStore.setForward()
break;
}
}
//
const goHomeHandle = () => { const goHomeHandle = () => {
goDialog({ goDialog({
message: '返回将不会保存任何操作', message: '返回将不会保存任何操作',
@ -87,6 +140,5 @@ const goHomeHandle = () => {
<style lang="scss" scoped> <style lang="scss" scoped>
.header-left-btn { .header-left-btn {
margin-left: -37px; margin-left: -37px;
padding-right: 149px; }
}
</style> </style>

View File

@ -20,7 +20,7 @@ const KeyboardHandle = (e: KeyboardEvent) => {
if (isMacRes) return if (isMacRes) return
const key = e.key.toLowerCase() const key = e.key.toLowerCase()
// 删除 // 删除单纯的delete会和其他位置冲突
// if (key === keyboardValue.delete) { // if (key === keyboardValue.delete) {
// chartEditStore.removeComponentList() // chartEditStore.removeComponentList()
// return // return