diff --git a/src/configs/theme.ts b/src/configs/theme.ts new file mode 100644 index 00000000..19a3667f --- /dev/null +++ b/src/configs/theme.ts @@ -0,0 +1,30 @@ +export const PRESET_THEMES = [ + { color: '#42464b', background: '#ffffff', text: '#333' }, + { color: '#5d82ba', background: '#ffffff', text: '#333' }, + { color: '#005a6f', background: '#ffffff', text: '#333' }, + { color: '#232d05', background: '#fff244', text: '#333' }, + { color: '#d0614c', background: '#dfb044', text: '#333' }, + { color: '#86a1ad', background: '#dfdbd4', text: '#333' }, + { color: '#697586', background: '#d5c4a4', text: '#333' }, + { color: '#333333', background: '#7acfa6', text: '#333' }, + { color: '#42464b', background: '#415065', text: '#fff' }, + { color: '#0c5999', background: '#35a2cd', text: '#fff' }, + { color: '#c49a41', background: '#8c4357', text: '#fff' }, + { color: '#dfaa00', background: '#2e4e7d', text: '#fff' }, + { color: '#d1ad88', background: '#f99070', text: '#fff' }, + { color: '#464d52', background: '#657984', text: '#fff' }, + { color: '#ffcfb6', background: '#1e4c6f', text: '#fff' }, + { color: '#c3a043', background: '#43292a', text: '#fff' }, + { color: '#ffffff', background: '#171925', text: '#fff' }, + { color: '#df9636', background: '#5b89a0', text: '#fff' }, + { color: '#b898a4', background: '#93716b', text: '#fff' }, + { color: '#c47a11', background: '#187db1', text: '#fff' }, + { color: '#333333', background: '#759564', text: '#fff' }, + { color: '#355b5e', background: '#424b50', text: '#fff' }, + { color: '#d29090', background: '#942a32', text: '#fff' }, + { color: '#00cfdf', background: '#3b434d', text: '#fff' }, + { color: '#424246', background: '#c70042', text: '#fff' }, + { color: '#2e4155', background: '#b35d44', text: '#fff' }, + { color: '#11bfce', background: '#8f98aa', text: '#fff' }, + { color: '#333333', background: '#549688', text: '#fff' }, +] \ No newline at end of file diff --git a/src/store/constants.ts b/src/store/constants.ts index 6685e65b..f9c918d0 100644 --- a/src/store/constants.ts +++ b/src/store/constants.ts @@ -15,6 +15,7 @@ export enum MutationTypes { SET_CLIPING_IMAGE_ELEMENT_ID = 'setClipingImageElementId', // slides + SET_THEME = 'setTheme', SET_SLIDES = 'setSlides', ADD_SLIDE = 'addSlide', UPDATE_SLIDE = 'updateSlide', diff --git a/src/store/index.ts b/src/store/index.ts index 2ca3144a..913d7d2f 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -4,7 +4,7 @@ import { actions } from './actions' import { mutations } from './mutations' import { MutationTypes, ActionTypes } from './constants' -import { Slide } from '@/types/slides' +import { Slide, SlideTheme } from '@/types/slides' import { CreatingElement } from '@/types/edit' import { ToolbarState } from '@/types/toolbar' import { slides } from '@/mocks/index' @@ -24,6 +24,7 @@ export interface State { creatingElement: CreatingElement | null; availableFonts: FontName[]; toolbarState: ToolbarState; + theme: SlideTheme; slides: Slide[]; slideIndex: number; snapshotCursor: number; @@ -46,6 +47,12 @@ const state: State = { creatingElement: null, availableFonts: [], toolbarState: 'slideStyle', + theme: { + themeColor: '#d14424', + fontColor: '#333', + fontName: '微软雅黑', + backgroundColor: '#fff', + }, slides: slides, slideIndex: 0, snapshotCursor: -1, diff --git a/src/store/mutations.ts b/src/store/mutations.ts index 2f08df9d..26d42190 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -2,7 +2,7 @@ import { MutationTree } from 'vuex' import omit from 'lodash/omit' import { MutationTypes } from './constants' import { State } from './index' -import { Slide, PPTElement } from '@/types/slides' +import { Slide, PPTElement, SlideTheme } from '@/types/slides' import { CreatingElement } from '@/types/edit' import { FONT_NAMES } from '@/configs/fontName' import { isSupportFontFamily } from '@/utils/fontFamily' @@ -74,6 +74,10 @@ export const mutations: MutationTree = { // slides + [MutationTypes.SET_THEME](state, themeProps: Partial) { + state.theme = { ...state.theme, ...themeProps } + }, + [MutationTypes.SET_SLIDES](state, slides: Slide[]) { state.slides = slides }, diff --git a/src/types/slides.ts b/src/types/slides.ts index d2fcfcef..efff4cd0 100644 --- a/src/types/slides.ts +++ b/src/types/slides.ts @@ -200,4 +200,11 @@ export interface Slide { background?: SlideBackground; animations?: PPTAnimation[]; turningMode?: 'no' | 'fade' | 'slideX' | 'slideY'; +} + +export interface SlideTheme { + backgroundColor: string; + themeColor: string; + fontColor: string; + fontName: string; } \ No newline at end of file diff --git a/src/views/Editor/Toolbar/SlideStylePanel.vue b/src/views/Editor/Toolbar/SlideStylePanel.vue index a417c654..f95ca721 100644 --- a/src/views/Editor/Toolbar/SlideStylePanel.vue +++ b/src/views/Editor/Toolbar/SlideStylePanel.vue @@ -94,7 +94,7 @@ -
+
@@ -103,7 +103,8 @@
字体: