update
This commit is contained in:
parent
a7886c2046
commit
19cdb80c1e
|
@ -0,0 +1,92 @@
|
||||||
|
import { Slide } from '@/types/slides'
|
||||||
|
|
||||||
|
export const slides: Slide[] = [
|
||||||
|
{
|
||||||
|
id: 'xxx1',
|
||||||
|
background: ['solid', '#323f4f'],
|
||||||
|
elements: [
|
||||||
|
{
|
||||||
|
elId: 'xxx1',
|
||||||
|
type: 'text',
|
||||||
|
left: 190,
|
||||||
|
top: 50,
|
||||||
|
width: 320,
|
||||||
|
height: 104,
|
||||||
|
rotate: 0,
|
||||||
|
borderStyle: 'solid',
|
||||||
|
borderWidth: 4,
|
||||||
|
borderColor: '#5b7d89',
|
||||||
|
fill: 'rgba(220,220,220,0.8)',
|
||||||
|
shadow: '1px 1px 3px rgba(10,10,10,.5)',
|
||||||
|
padding: 10,
|
||||||
|
opacity: 1,
|
||||||
|
lineHeight: 1.5,
|
||||||
|
segmentSpacing: 10,
|
||||||
|
isLock: false,
|
||||||
|
textType: 'title',
|
||||||
|
content: '<div style=\'text-align: center;\'><span style=\'font-size: 28px;\'><span style=\'color: rgb(232, 107, 153); font-weight: bold;\'>一段测试文字</span>,字号固定为<span style=\'font-weight: bold; font-style: italic; text-decoration-line: underline;\'>28px</span></span></div>',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
elId: 'xxx3',
|
||||||
|
type: 'image',
|
||||||
|
left: 80,
|
||||||
|
top: 250,
|
||||||
|
width: 180,
|
||||||
|
height: 180,
|
||||||
|
rotate: 0,
|
||||||
|
borderStyle: 'solid',
|
||||||
|
borderWidth: 4,
|
||||||
|
borderColor: 'rgba(10,10,10,1)',
|
||||||
|
filter: '',
|
||||||
|
clip: {
|
||||||
|
range: [[30, 0], [100, 70]],
|
||||||
|
shape: 'ellipse'
|
||||||
|
},
|
||||||
|
lockRatio: false,
|
||||||
|
isLock: false,
|
||||||
|
imgUrl: 'https://img.lessonplan.cn/IMG/Show/ppt/3ab74e91-c34f-499d-9711-166e423d4dd6/1573622467064v2-7aa3ce420052983d91c6d01b47a7441d_hd.jpg',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
elId: 'xxx2',
|
||||||
|
type: 'image',
|
||||||
|
left: 750,
|
||||||
|
top: 320,
|
||||||
|
width: 150,
|
||||||
|
height: 150,
|
||||||
|
rotate: 0,
|
||||||
|
borderStyle: 'solid',
|
||||||
|
borderWidth: 6,
|
||||||
|
borderColor: 'rgba(10,10,10,1)',
|
||||||
|
filter: '',
|
||||||
|
clip: {
|
||||||
|
range: [[0, 0], [100, 100]],
|
||||||
|
shape: 'roundRect'
|
||||||
|
},
|
||||||
|
lockRatio: true,
|
||||||
|
isLock: false,
|
||||||
|
imgUrl: 'https://img.lessonplan.cn/IMG/Show/ppt/3ab74e91-c34f-499d-9711-166e423d4dd6/62d9adb3-e7a6-4dc4-a352-095cffb49f08/b1be1a2f-f893-47d3-a8a3-eac7d04d395f/1596159381259v2-b2c69096d25ae16bf6ca09e30add3e65_hd.jpg',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'sajd172',
|
||||||
|
elements: [
|
||||||
|
{
|
||||||
|
elId: 'yyx1',
|
||||||
|
type: 'text',
|
||||||
|
left: 590,
|
||||||
|
top: 90,
|
||||||
|
width: 220,
|
||||||
|
height: 188,
|
||||||
|
rotate: 0,
|
||||||
|
padding: 10,
|
||||||
|
opacity: 1,
|
||||||
|
lineHeight: 1.5,
|
||||||
|
segmentSpacing: 10,
|
||||||
|
isLock: false,
|
||||||
|
textType: 'content',
|
||||||
|
content: '<div>😀 😐 😶 😜 🔔 ⭐ ⚡ 🔥 👍 💡 🔰 🎀 🎁 🥇 🏅 🏆 🎈 🎉 💎 🚧 ⛔ 📢 ⌛ ⏰ 🕒 🧩 🎵 📎 🔒 🔑 ⛳ 📌 📍 💬 📅 📈 📋 📜 📁 📱 💻 💾 🌏 🚚 🚡 🚢💧 🌐 🧭 💰 💳 🛒</div>',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
|
@ -1,4 +1,6 @@
|
||||||
export enum MutationTypes {
|
export enum MutationTypes {
|
||||||
|
|
||||||
|
// editor
|
||||||
SET_ACTIVE_ELEMENT_ID_LIST = 'setActiveElementIdList',
|
SET_ACTIVE_ELEMENT_ID_LIST = 'setActiveElementIdList',
|
||||||
SET_HANDLE_ELEMENT_ID = 'setHandleElementId',
|
SET_HANDLE_ELEMENT_ID = 'setHandleElementId',
|
||||||
SET_EDITOR_AREA_SHOW_SCALE = 'setEditorAreaShowScale',
|
SET_EDITOR_AREA_SHOW_SCALE = 'setEditorAreaShowScale',
|
||||||
|
@ -7,4 +9,22 @@ export enum MutationTypes {
|
||||||
SET_THUMBNAILS_FOCUS = 'setThumbnailsFocus',
|
SET_THUMBNAILS_FOCUS = 'setThumbnailsFocus',
|
||||||
SET_EDITORAREA_FOCUS = 'setEditorAreaFocus',
|
SET_EDITORAREA_FOCUS = 'setEditorAreaFocus',
|
||||||
SET_AVAILABLE_FONTS = 'setAvailableFonts',
|
SET_AVAILABLE_FONTS = 'setAvailableFonts',
|
||||||
|
|
||||||
|
// slides
|
||||||
|
SET_SLIDES = 'setSlides',
|
||||||
|
SET_SLIDE = 'setSlide',
|
||||||
|
ADD_SLIDE = 'addSlide',
|
||||||
|
ADD_SLIDES = 'addSlides',
|
||||||
|
UPDATE_SLIDE = 'updateSlide',
|
||||||
|
DELETE_SLIDE = 'deleteSlide',
|
||||||
|
UPDATE_SLIDE_INDEX = 'updateSlideIndex',
|
||||||
|
ADD_ELEMENTS = 'addElements',
|
||||||
|
UPDATE_ELEMENT = 'updateElement',
|
||||||
|
UPDATE_ELEMENTS = 'updateElements',
|
||||||
|
|
||||||
|
// history
|
||||||
|
SET_CURSOR = 'setCursor',
|
||||||
|
UNDO = 'undo',
|
||||||
|
REDO = 'redo',
|
||||||
|
SET_HISTORY_RECORD_LENGTH = 'setHistoryRecordLength',
|
||||||
}
|
}
|
|
@ -4,6 +4,8 @@ import { State } from './state'
|
||||||
export type Getters = {
|
export type Getters = {
|
||||||
activeElementList(state: State): PPTElement[];
|
activeElementList(state: State): PPTElement[];
|
||||||
handleElement(state: State): PPTElement | null;
|
handleElement(state: State): PPTElement | null;
|
||||||
|
canUndo(state: State): boolean;
|
||||||
|
canRedo(state: State): boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getters: Getters = {
|
export const getters: Getters = {
|
||||||
|
@ -12,9 +14,18 @@ export const getters: Getters = {
|
||||||
if(!currentSlide || !currentSlide.elements) return []
|
if(!currentSlide || !currentSlide.elements) return []
|
||||||
return currentSlide.elements.filter(element => state.activeElementIdList.includes(element.elId))
|
return currentSlide.elements.filter(element => state.activeElementIdList.includes(element.elId))
|
||||||
},
|
},
|
||||||
|
|
||||||
handleElement(state) {
|
handleElement(state) {
|
||||||
const currentSlide = state.slides[state.slideIndex]
|
const currentSlide = state.slides[state.slideIndex]
|
||||||
if(!currentSlide || !currentSlide.elements) return null
|
if(!currentSlide || !currentSlide.elements) return null
|
||||||
return currentSlide.elements.find(element => state.handleElementId === element.elId) || null
|
return currentSlide.elements.find(element => state.handleElementId === element.elId) || null
|
||||||
},
|
},
|
||||||
|
|
||||||
|
canUndo(state) {
|
||||||
|
return state.cursor > 0
|
||||||
|
},
|
||||||
|
|
||||||
|
canRedo(state) {
|
||||||
|
return state.cursor < state.historyRecordLength - 1
|
||||||
|
},
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
import { Slide } from '@/types/slides'
|
import { Slide } from '@/types/slides'
|
||||||
|
import { slides } from '@/mocks/index'
|
||||||
|
|
||||||
export type State = {
|
export type State = {
|
||||||
activeElementIdList: string[];
|
activeElementIdList: string[];
|
||||||
|
@ -11,6 +12,8 @@ export type State = {
|
||||||
availableFonts: string[];
|
availableFonts: string[];
|
||||||
slides: Slide[];
|
slides: Slide[];
|
||||||
slideIndex: number;
|
slideIndex: number;
|
||||||
|
cursor: number;
|
||||||
|
historyRecordLength: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const state: State = {
|
export const state: State = {
|
||||||
|
@ -22,6 +25,8 @@ export const state: State = {
|
||||||
thumbnailsFocus: false,
|
thumbnailsFocus: false,
|
||||||
editorAreaFocus: false,
|
editorAreaFocus: false,
|
||||||
availableFonts: [],
|
availableFonts: [],
|
||||||
slides: [],
|
slides: slides,
|
||||||
slideIndex: 0,
|
slideIndex: 0,
|
||||||
|
cursor: -1,
|
||||||
|
historyRecordLength: 0,
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
export interface PPTElementBaseProps {
|
export interface PPTElementBaseProps {
|
||||||
elId: string;
|
elId: string;
|
||||||
isLock: boolean;
|
isLock: boolean;
|
||||||
groupId: string;
|
|
||||||
left: number;
|
left: number;
|
||||||
top: number;
|
top: number;
|
||||||
|
groupId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PPTElementSizeProps {
|
export interface PPTElementSizeProps {
|
||||||
|
@ -18,40 +18,48 @@ export interface PPTElementBorderProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PPTTextElement extends PPTElementBaseProps, PPTElementSizeProps, PPTElementBorderProps {
|
export interface PPTTextElement extends PPTElementBaseProps, PPTElementSizeProps, PPTElementBorderProps {
|
||||||
|
type: 'text';
|
||||||
textType: string;
|
textType: string;
|
||||||
content: string;
|
content: string;
|
||||||
rotate?: number;
|
rotate?: number;
|
||||||
fill?: string;
|
fill?: string;
|
||||||
opactity?: number;
|
opacity?: number;
|
||||||
lineHeight?: number;
|
lineHeight?: number;
|
||||||
segmentSapcing?: number;
|
segmentSpacing?: number;
|
||||||
letterSpacing?: number;
|
letterSpacing?: number;
|
||||||
shadow?: string;
|
shadow?: string;
|
||||||
padding?: number;
|
padding?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ImageClip {
|
||||||
|
range: [[number, number], [number, number]];
|
||||||
|
shape: string;
|
||||||
|
}
|
||||||
export interface PPTImageElement extends PPTElementBaseProps, PPTElementSizeProps, PPTElementBorderProps {
|
export interface PPTImageElement extends PPTElementBaseProps, PPTElementSizeProps, PPTElementBorderProps {
|
||||||
|
type: 'image';
|
||||||
lockRatio: boolean;
|
lockRatio: boolean;
|
||||||
imgUrl: string;
|
imgUrl: string;
|
||||||
rotate?: number;
|
rotate?: number;
|
||||||
filter?: string;
|
filter?: string;
|
||||||
clip?: string;
|
clip?: ImageClip;
|
||||||
flip?: string;
|
flip?: string;
|
||||||
shadow?: string;
|
shadow?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PPTShapeElement extends PPTElementBaseProps, PPTElementSizeProps, PPTElementBorderProps {
|
export interface PPTShapeElement extends PPTElementBaseProps, PPTElementSizeProps, PPTElementBorderProps {
|
||||||
|
type: 'shape';
|
||||||
svgCode: string;
|
svgCode: string;
|
||||||
lockRatio: boolean;
|
lockRatio: boolean;
|
||||||
fill: string;
|
fill: string;
|
||||||
rotate?: number;
|
rotate?: number;
|
||||||
opactity?: number;
|
opacity?: number;
|
||||||
shadow?: string;
|
shadow?: string;
|
||||||
text?: string;
|
text?: string;
|
||||||
textAlign?: string;
|
textAlign?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PPTIconElement extends PPTElementBaseProps, PPTElementSizeProps {
|
export interface PPTIconElement extends PPTElementBaseProps, PPTElementSizeProps {
|
||||||
|
type: 'icon';
|
||||||
color: string;
|
color: string;
|
||||||
lockRatio: boolean;
|
lockRatio: boolean;
|
||||||
svgCode: string;
|
svgCode: string;
|
||||||
|
@ -60,6 +68,7 @@ export interface PPTIconElement extends PPTElementBaseProps, PPTElementSizeProps
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PPTLineElement extends PPTElementBaseProps {
|
export interface PPTLineElement extends PPTElementBaseProps {
|
||||||
|
type: 'line';
|
||||||
start: [number, number];
|
start: [number, number];
|
||||||
end: [number, number];
|
end: [number, number];
|
||||||
width: number;
|
width: number;
|
||||||
|
@ -82,6 +91,7 @@ export interface PieChartData {
|
||||||
value: number
|
value: number
|
||||||
}
|
}
|
||||||
export interface PPTChartElement extends PPTElementBaseProps, PPTElementSizeProps, PPTElementBorderProps {
|
export interface PPTChartElement extends PPTElementBaseProps, PPTElementSizeProps, PPTElementBorderProps {
|
||||||
|
type: 'chart';
|
||||||
chartType: string;
|
chartType: string;
|
||||||
theme: string;
|
theme: string;
|
||||||
data: PieChartData[] | BarChartData;
|
data: PieChartData[] | BarChartData;
|
||||||
|
@ -94,6 +104,7 @@ export interface TableCell {
|
||||||
bgColor: string;
|
bgColor: string;
|
||||||
}
|
}
|
||||||
export interface PPTTableElement extends PPTElementBaseProps, PPTElementSizeProps {
|
export interface PPTTableElement extends PPTElementBaseProps, PPTElementSizeProps {
|
||||||
|
type: 'table';
|
||||||
borderTheme: string;
|
borderTheme: string;
|
||||||
theme: string;
|
theme: string;
|
||||||
rowSizes: number[];
|
rowSizes: number[];
|
||||||
|
@ -101,6 +112,7 @@ export interface PPTTableElement extends PPTElementBaseProps, PPTElementSizeProp
|
||||||
data: TableCell[][];
|
data: TableCell[][];
|
||||||
}
|
}
|
||||||
export interface PPTIframeElement extends PPTElementBaseProps, PPTElementSizeProps, PPTElementBorderProps {
|
export interface PPTIframeElement extends PPTElementBaseProps, PPTElementSizeProps, PPTElementBorderProps {
|
||||||
|
type: 'iframe';
|
||||||
src: string;
|
src: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +133,7 @@ export interface PPTAnimation {
|
||||||
|
|
||||||
export interface Slide {
|
export interface Slide {
|
||||||
id: string;
|
id: string;
|
||||||
background: [string, string];
|
|
||||||
elements: PPTElement[];
|
elements: PPTElement[];
|
||||||
animations: PPTAnimation[];
|
background?: [string, string];
|
||||||
|
animations?: PPTAnimation[];
|
||||||
}
|
}
|
Loading…
Reference in New Issue