mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
枚举和常量优化
This commit is contained in:
parent
69092a0518
commit
e6c56f8f83
@ -1,10 +0,0 @@
|
|||||||
export const CHART_THEME_COLORS = [
|
|
||||||
['#d70206', '#f05b4f', '#f4c63d', '#d17905'],
|
|
||||||
['#67d5b5', '#ee7785', '#c89ec4', '#84b1ed'],
|
|
||||||
['#f6ea8c', '#f26d5b', '#c03546', '#492540'],
|
|
||||||
['#583d72', '#9f5f80', '#ffba93', '#ff8e71'],
|
|
||||||
['#59886b', '#c05555', '#ffc85c', '#fff8c1'],
|
|
||||||
['#d87c7c', '#919e8b', '#d7ab82', '#6e7074'],
|
|
||||||
['#1a1a2e', '#16213e', '#0f3460', '#e94560'],
|
|
||||||
['#e01f54', '#001852', '#f5e8c8', '#b8d2c7'],
|
|
||||||
]
|
|
@ -1,10 +1,10 @@
|
|||||||
export const ELEMENT_TYPE = {
|
export const ELEMENT_TYPE_ZH = {
|
||||||
'text': '文本',
|
text: '文本',
|
||||||
'image': '图片',
|
image: '图片',
|
||||||
'shape': '形状',
|
shape: '形状',
|
||||||
'line': '线条',
|
line: '线条',
|
||||||
'chart': '图表',
|
chart: '图表',
|
||||||
'table': '表格',
|
table: '表格',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MIN_SIZE = {
|
export const MIN_SIZE = {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export enum KEYS {
|
export const enum KEYS {
|
||||||
C = 'C',
|
C = 'C',
|
||||||
X = 'X',
|
X = 'X',
|
||||||
Z = 'Z',
|
Z = 'Z',
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
export enum ClipPathTypes {
|
export const enum ClipPathTypes {
|
||||||
RECT = 'rect',
|
RECT = 'rect',
|
||||||
ELLIPSE = 'ellipse',
|
ELLIPSE = 'ellipse',
|
||||||
POLYGON = 'polygon',
|
POLYGON = 'polygon',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ClipPaths {
|
export const enum ClipPaths {
|
||||||
RECT = 'rect',
|
RECT = 'rect',
|
||||||
ROUNDRECT = 'roundRect',
|
ROUNDRECT = 'roundRect',
|
||||||
ELLIPSE = 'ellipse',
|
ELLIPSE = 'ellipse',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export enum MutationTypes {
|
export const enum MutationTypes {
|
||||||
|
|
||||||
// editor
|
// editor
|
||||||
SET_ACTIVE_ELEMENT_ID_LIST = 'setActiveElementIdList',
|
SET_ACTIVE_ELEMENT_ID_LIST = 'setActiveElementIdList',
|
||||||
@ -37,7 +37,7 @@ export enum MutationTypes {
|
|||||||
SET_SCREENING = 'setScreening',
|
SET_SCREENING = 'setScreening',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ActionTypes {
|
export const enum ActionTypes {
|
||||||
INIT_SNAPSHOT_DATABASE = 'initSnapshotDatabase',
|
INIT_SNAPSHOT_DATABASE = 'initSnapshotDatabase',
|
||||||
ADD_SNAPSHOT = 'addSnapshot',
|
ADD_SNAPSHOT = 'addSnapshot',
|
||||||
UN_DO = 'undo',
|
UN_DO = 'undo',
|
||||||
|
@ -3,7 +3,7 @@ import { LinePoolItem } from '@/configs/lines'
|
|||||||
|
|
||||||
export type ElementOrderCommand = 'up' | 'down' | 'top' | 'bottom'
|
export type ElementOrderCommand = 'up' | 'down' | 'top' | 'bottom'
|
||||||
|
|
||||||
export enum ElementOrderCommands {
|
export const enum ElementOrderCommands {
|
||||||
UP = 'up',
|
UP = 'up',
|
||||||
DOWN = 'down',
|
DOWN = 'down',
|
||||||
TOP = 'top',
|
TOP = 'top',
|
||||||
@ -12,7 +12,7 @@ export enum ElementOrderCommands {
|
|||||||
|
|
||||||
export type ElementAlignCommand = 'top'| 'bottom' | 'left' | 'right' | 'vertical' | 'horizontal'
|
export type ElementAlignCommand = 'top'| 'bottom' | 'left' | 'right' | 'vertical' | 'horizontal'
|
||||||
|
|
||||||
export enum ElementAlignCommands {
|
export const enum ElementAlignCommands {
|
||||||
TOP = 'top',
|
TOP = 'top',
|
||||||
BOTTOM = 'bottom',
|
BOTTOM = 'bottom',
|
||||||
LEFT = 'left',
|
LEFT = 'left',
|
||||||
@ -23,7 +23,7 @@ export enum ElementAlignCommands {
|
|||||||
|
|
||||||
export type OperateBorderLine = 'top' | 'bottom' | 'left' | 'right'
|
export type OperateBorderLine = 'top' | 'bottom' | 'left' | 'right'
|
||||||
|
|
||||||
export enum OperateBorderLines {
|
export const enum OperateBorderLines {
|
||||||
T = 'top',
|
T = 'top',
|
||||||
B = 'bottom',
|
B = 'bottom',
|
||||||
L = 'left',
|
L = 'left',
|
||||||
@ -32,7 +32,7 @@ export enum OperateBorderLines {
|
|||||||
|
|
||||||
export type OperateResizeHandler = '' | 'left-top' | 'top' | 'right-top' | 'left' | 'right' | 'left-bottom' | 'bottom' | 'right-bottom'
|
export type OperateResizeHandler = '' | 'left-top' | 'top' | 'right-top' | 'left' | 'right' | 'left-bottom' | 'bottom' | 'right-bottom'
|
||||||
|
|
||||||
export enum OperateResizeHandlers {
|
export const enum OperateResizeHandlers {
|
||||||
LEFT_TOP = 'left-top',
|
LEFT_TOP = 'left-top',
|
||||||
TOP = 'top',
|
TOP = 'top',
|
||||||
RIGHT_TOP = 'right-top',
|
RIGHT_TOP = 'right-top',
|
||||||
@ -45,7 +45,7 @@ export enum OperateResizeHandlers {
|
|||||||
|
|
||||||
export type OperateLineHandler = 'start' | 'end'
|
export type OperateLineHandler = 'start' | 'end'
|
||||||
|
|
||||||
export enum OperateLineHandlers {
|
export const enum OperateLineHandlers {
|
||||||
START = 'start',
|
START = 'start',
|
||||||
END = 'end,'
|
END = 'end,'
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ export interface PPTElementShadow {
|
|||||||
color: string;
|
color: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ElementTypes {
|
export const enum ElementTypes {
|
||||||
TEXT = 'text',
|
TEXT = 'text',
|
||||||
IMAGE = 'image',
|
IMAGE = 'image',
|
||||||
SHAPE = 'shape',
|
SHAPE = 'shape',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ElementTypes, PPTElement } from '@/types/slides'
|
import { PPTElement } from '@/types/slides'
|
||||||
|
|
||||||
// 获取矩形旋转后在画布中的位置范围
|
// 获取矩形旋转后在画布中的位置范围
|
||||||
interface RotatedElementData {
|
interface RotatedElementData {
|
||||||
@ -46,7 +46,7 @@ export const getRectRotatedRange = (element: RotatedElementData) => {
|
|||||||
export const getElementRange = (element: PPTElement) => {
|
export const getElementRange = (element: PPTElement) => {
|
||||||
let minX, maxX, minY, maxY
|
let minX, maxX, minY, maxY
|
||||||
|
|
||||||
if(element.type === ElementTypes.LINE) {
|
if(element.type === 'line') {
|
||||||
minX = element.left
|
minX = element.left
|
||||||
maxX = element.left + Math.max(element.start[0], element.end[0])
|
maxX = element.left + Math.max(element.start[0], element.end[0])
|
||||||
minY = element.top
|
minY = element.top
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import mitt, { Emitter } from 'mitt'
|
import mitt, { Emitter } from 'mitt'
|
||||||
|
|
||||||
export enum EmitterEvents {
|
export const enum EmitterEvents {
|
||||||
UPDATE_TEXT_STATE = 'UPDATE_TEXT_STATE',
|
UPDATE_TEXT_STATE = 'UPDATE_TEXT_STATE',
|
||||||
EXEC_TEXT_COMMAND = 'EXEC_TEXT_COMMAND',
|
EXEC_TEXT_COMMAND = 'EXEC_TEXT_COMMAND',
|
||||||
UPDATE_TABLE_SELECTED_CELL = 'UPDATE_TABLE_SELECTED_CELL',
|
UPDATE_TABLE_SELECTED_CELL = 'UPDATE_TABLE_SELECTED_CELL',
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, defineComponent, reactive, PropType, watchEffect, toRefs } from 'vue'
|
import { computed, defineComponent, reactive, PropType, watchEffect, toRefs } from 'vue'
|
||||||
import { useStore } from '@/store'
|
import { useStore } from '@/store'
|
||||||
import { PPTElement, ElementTypes } from '@/types/slides'
|
import { PPTElement } from '@/types/slides'
|
||||||
import { getElementListRange } from '@/utils/element'
|
import { getElementListRange } from '@/utils/element'
|
||||||
import { OperateResizeHandler, MultiSelectRange } from '@/types/edit'
|
import { OperateResizeHandler, MultiSelectRange } from '@/types/edit'
|
||||||
import useCommonOperate from '../hooks/useCommonOperate'
|
import useCommonOperate from '../hooks/useCommonOperate'
|
||||||
@ -67,7 +67,7 @@ export default defineComponent({
|
|||||||
const disableResize = computed(() => {
|
const disableResize = computed(() => {
|
||||||
return localActiveElementList.value.some(item => {
|
return localActiveElementList.value.some(item => {
|
||||||
if(
|
if(
|
||||||
(item.type === ElementTypes.IMAGE || item.type === ElementTypes.SHAPE) &&
|
(item.type === 'image' || item.type === 'shape') &&
|
||||||
!item.rotate
|
!item.rotate
|
||||||
) return false
|
) return false
|
||||||
return true
|
return true
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Ref, computed } from 'vue'
|
import { Ref, computed } from 'vue'
|
||||||
import { MutationTypes, useStore } from '@/store'
|
import { MutationTypes, useStore } from '@/store'
|
||||||
import { ElementTypes, PPTElement } from '@/types/slides'
|
import { PPTElement } from '@/types/slides'
|
||||||
import { AlignmentLineProps } from '@/types/edit'
|
import { AlignmentLineProps } from '@/types/edit'
|
||||||
import { VIEWPORT_SIZE, VIEWPORT_ASPECT_RATIO } from '@/configs/canvas'
|
import { VIEWPORT_SIZE, VIEWPORT_ASPECT_RATIO } from '@/configs/canvas'
|
||||||
import { getRectRotatedRange, AlignLine, uniqAlignLines } from '@/utils/element'
|
import { getRectRotatedRange, AlignLine, uniqAlignLines } from '@/utils/element'
|
||||||
@ -48,7 +48,7 @@ export default (
|
|||||||
|
|
||||||
// 元素在页面内水平和垂直方向的范围和中心位置(需要特殊计算线条和被旋转的元素)
|
// 元素在页面内水平和垂直方向的范围和中心位置(需要特殊计算线条和被旋转的元素)
|
||||||
for(const el of elementList.value) {
|
for(const el of elementList.value) {
|
||||||
if(el.type === ElementTypes.LINE) continue
|
if(el.type === 'line') continue
|
||||||
if(isActiveGroupElement && el.id === element.id) continue
|
if(isActiveGroupElement && el.id === element.id) continue
|
||||||
if(!isActiveGroupElement && activeElementIdList.value.includes(el.id)) continue
|
if(!isActiveGroupElement && activeElementIdList.value.includes(el.id)) continue
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ export default (
|
|||||||
targetMinY = yRange[0]
|
targetMinY = yRange[0]
|
||||||
targetMaxY = yRange[1]
|
targetMaxY = yRange[1]
|
||||||
}
|
}
|
||||||
else if(element.type === ElementTypes.LINE) {
|
else if(element.type === 'line') {
|
||||||
targetMinX = targetLeft
|
targetMinX = targetLeft
|
||||||
targetMaxX = targetLeft + Math.max(element.start[0], element.end[0])
|
targetMaxX = targetLeft + Math.max(element.start[0], element.end[0])
|
||||||
targetMinY = targetTop
|
targetMinY = targetTop
|
||||||
@ -178,7 +178,7 @@ export default (
|
|||||||
rightValues.push(xRange[1])
|
rightValues.push(xRange[1])
|
||||||
bottomValues.push(yRange[1])
|
bottomValues.push(yRange[1])
|
||||||
}
|
}
|
||||||
else if(element.type === ElementTypes.LINE) {
|
else if(element.type === 'line') {
|
||||||
leftValues.push(left)
|
leftValues.push(left)
|
||||||
topValues.push(top)
|
topValues.push(top)
|
||||||
rightValues.push(left + Math.max(element.start[0], element.end[0]))
|
rightValues.push(left + Math.max(element.start[0], element.end[0]))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { computed, Ref } from 'vue'
|
import { computed, Ref } from 'vue'
|
||||||
import { MutationTypes, useStore } from '@/store'
|
import { MutationTypes, useStore } from '@/store'
|
||||||
import { ElementTypes, PPTElement, PPTImageElement, PPTLineElement, PPTShapeElement } from '@/types/slides'
|
import { PPTElement, PPTImageElement, PPTLineElement, PPTShapeElement } from '@/types/slides'
|
||||||
import { OperateResizeHandlers, AlignmentLineProps, MultiSelectRange } from '@/types/edit'
|
import { OperateResizeHandlers, AlignmentLineProps, MultiSelectRange } from '@/types/edit'
|
||||||
import emitter, { EmitterEvents } from '@/utils/emitter'
|
import emitter, { EmitterEvents } from '@/utils/emitter'
|
||||||
import { VIEWPORT_SIZE, VIEWPORT_ASPECT_RATIO } from '@/configs/canvas'
|
import { VIEWPORT_SIZE, VIEWPORT_ASPECT_RATIO } from '@/configs/canvas'
|
||||||
@ -139,7 +139,7 @@ export default (
|
|||||||
|
|
||||||
for(const el of elementList.value) {
|
for(const el of elementList.value) {
|
||||||
if('rotate' in el && el.rotate) continue
|
if('rotate' in el && el.rotate) continue
|
||||||
if(el.type === ElementTypes.LINE) continue
|
if(el.type === 'line') continue
|
||||||
if(isActiveGroupElement && el.id === element.id) continue
|
if(isActiveGroupElement && el.id === element.id) continue
|
||||||
if(!isActiveGroupElement && activeElementIdList.value.includes(el.id)) continue
|
if(!isActiveGroupElement && activeElementIdList.value.includes(el.id)) continue
|
||||||
|
|
||||||
@ -468,7 +468,7 @@ export default (
|
|||||||
// 根据上面计算的比例,修改所有被激活元素的位置大小
|
// 根据上面计算的比例,修改所有被激活元素的位置大小
|
||||||
// 宽高通过乘以对应的比例得到,位置通过将被操作元素在所有元素整体中的相对位置乘以对应比例获得
|
// 宽高通过乘以对应的比例得到,位置通过将被操作元素在所有元素整体中的相对位置乘以对应比例获得
|
||||||
elementList.value = elementList.value.map(el => {
|
elementList.value = elementList.value.map(el => {
|
||||||
if((el.type === ElementTypes.IMAGE || el.type === ElementTypes.SHAPE) && activeElementIdList.value.includes(el.id)) {
|
if((el.type === 'image' || el.type === 'shape') && activeElementIdList.value.includes(el.id)) {
|
||||||
const originElement = originElementList.find(originEl => originEl.id === el.id) as PPTImageElement | PPTShapeElement
|
const originElement = originElementList.find(originEl => originEl.id === el.id) as PPTImageElement | PPTShapeElement
|
||||||
return {
|
return {
|
||||||
...el,
|
...el,
|
||||||
|
@ -71,7 +71,7 @@ import { computed, defineComponent, ref } from 'vue'
|
|||||||
import { MutationTypes, useStore } from '@/store'
|
import { MutationTypes, useStore } from '@/store'
|
||||||
import { PPTAnimation, PPTElement, Slide } from '@/types/slides'
|
import { PPTAnimation, PPTElement, Slide } from '@/types/slides'
|
||||||
import { ANIMATIONS } from '@/configs/animation'
|
import { ANIMATIONS } from '@/configs/animation'
|
||||||
import { ELEMENT_TYPE } from '@/configs/element'
|
import { ELEMENT_TYPE_ZH } from '@/configs/element'
|
||||||
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
||||||
|
|
||||||
import Draggable from 'vuedraggable'
|
import Draggable from 'vuedraggable'
|
||||||
@ -107,7 +107,7 @@ export default defineComponent({
|
|||||||
for(const animation of currentSlideAnimations.value) {
|
for(const animation of currentSlideAnimations.value) {
|
||||||
const el = currentSlide.value.elements.find(el => el.id === animation.elId)
|
const el = currentSlide.value.elements.find(el => el.id === animation.elId)
|
||||||
if(!el) continue
|
if(!el) continue
|
||||||
const elType = ELEMENT_TYPE[el.type]
|
const elType = ELEMENT_TYPE_ZH[el.type]
|
||||||
const animationType = animationTypes[animation.type]
|
const animationType = animationTypes[animation.type]
|
||||||
|
|
||||||
animationSequence.push({
|
animationSequence.push({
|
||||||
|
@ -103,7 +103,6 @@ import { computed, defineComponent, ref, watch } from 'vue'
|
|||||||
import { IBarChartOptions, ILineChartOptions, IPieChartOptions } from 'chartist'
|
import { IBarChartOptions, ILineChartOptions, IPieChartOptions } from 'chartist'
|
||||||
import { MutationTypes, useStore } from '@/store'
|
import { MutationTypes, useStore } from '@/store'
|
||||||
import { ChartData, PPTChartElement } from '@/types/slides'
|
import { ChartData, PPTChartElement } from '@/types/slides'
|
||||||
import { CHART_THEME_COLORS } from '@/configs/chartTheme'
|
|
||||||
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
||||||
|
|
||||||
import ElementOutline from '../../common/ElementOutline.vue'
|
import ElementOutline from '../../common/ElementOutline.vue'
|
||||||
@ -207,7 +206,6 @@ export default defineComponent({
|
|||||||
updateOptions,
|
updateOptions,
|
||||||
themeColor,
|
themeColor,
|
||||||
gridColor,
|
gridColor,
|
||||||
CHART_THEME_COLORS,
|
|
||||||
updateTheme,
|
updateTheme,
|
||||||
updateGridColor,
|
updateGridColor,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user