mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
perf: 代码优化、UI优化
This commit is contained in:
parent
e58095cfe7
commit
8787c5d5b7
@ -21,10 +21,8 @@
|
|||||||
}
|
}
|
||||||
.ant-dropdown-menu {
|
.ant-dropdown-menu {
|
||||||
box-shadow: $boxShadow;
|
box-shadow: $boxShadow;
|
||||||
border: 1px solid $borderColor;
|
|
||||||
}
|
}
|
||||||
.ant-dropdown-menu-item {
|
.ant-dropdown-menu-item {
|
||||||
transition: none;
|
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: rgba($color: $themeColor, $alpha: .2);
|
background-color: rgba($color: $themeColor, $alpha: .2);
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="recent-colors-title">最近使用:</div>
|
<div class="recent-colors-title" v-if="recentColors.length">最近使用:</div>
|
||||||
<div class="recent-colors">
|
<div class="recent-colors">
|
||||||
<div
|
<div
|
||||||
v-for="c in recentColors"
|
v-for="c in recentColors"
|
||||||
|
@ -2,28 +2,28 @@ import { ActionTree } from 'vuex'
|
|||||||
import { IndexableTypeArray } from 'dexie'
|
import { IndexableTypeArray } from 'dexie'
|
||||||
import { State } from './state'
|
import { State } from './state'
|
||||||
import { ActionTypes, MutationTypes } from './constants'
|
import { ActionTypes, MutationTypes } from './constants'
|
||||||
import db, { Snapshot } from '@/utils/database'
|
import { snapshotDB, Snapshot } from '@/utils/database'
|
||||||
|
|
||||||
export const actions: ActionTree<State, State> = {
|
export const actions: ActionTree<State, State> = {
|
||||||
async [ActionTypes.INIT_SNAPSHOT_DATABASE]({ commit, state }) {
|
async [ActionTypes.INIT_SNAPSHOT_DATABASE]({ commit, state }) {
|
||||||
const snapshots: Snapshot[] = await db.snapshots.orderBy('id').toArray()
|
const snapshots: Snapshot[] = await snapshotDB.snapshots.orderBy('id').toArray()
|
||||||
const lastSnapshot = snapshots.slice(-1)[0]
|
const lastSnapshot = snapshots.slice(-1)[0]
|
||||||
|
|
||||||
if (lastSnapshot) {
|
if (lastSnapshot) {
|
||||||
db.snapshots.clear()
|
snapshotDB.snapshots.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
const newFirstSnapshot = {
|
const newFirstSnapshot = {
|
||||||
index: state.slideIndex,
|
index: state.slideIndex,
|
||||||
slides: state.slides,
|
slides: state.slides,
|
||||||
}
|
}
|
||||||
await db.snapshots.add(newFirstSnapshot)
|
await snapshotDB.snapshots.add(newFirstSnapshot)
|
||||||
commit(MutationTypes.SET_SNAPSHOT_CURSOR, 0)
|
commit(MutationTypes.SET_SNAPSHOT_CURSOR, 0)
|
||||||
commit(MutationTypes.SET_SNAPSHOT_LENGTH, 1)
|
commit(MutationTypes.SET_SNAPSHOT_LENGTH, 1)
|
||||||
},
|
},
|
||||||
|
|
||||||
async [ActionTypes.ADD_SNAPSHOT]({ state, commit }) {
|
async [ActionTypes.ADD_SNAPSHOT]({ state, commit }) {
|
||||||
const allKeys = await db.snapshots.orderBy('id').keys()
|
const allKeys = await snapshotDB.snapshots.orderBy('id').keys()
|
||||||
|
|
||||||
let needDeleteKeys: IndexableTypeArray = []
|
let needDeleteKeys: IndexableTypeArray = []
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ export const actions: ActionTree<State, State> = {
|
|||||||
index: state.slideIndex,
|
index: state.slideIndex,
|
||||||
slides: state.slides,
|
slides: state.slides,
|
||||||
}
|
}
|
||||||
await db.snapshots.add(snapshot)
|
await snapshotDB.snapshots.add(snapshot)
|
||||||
|
|
||||||
let snapshotLength = allKeys.length - needDeleteKeys.length + 1
|
let snapshotLength = allKeys.length - needDeleteKeys.length + 1
|
||||||
|
|
||||||
@ -44,10 +44,10 @@ export const actions: ActionTree<State, State> = {
|
|||||||
snapshotLength--
|
snapshotLength--
|
||||||
}
|
}
|
||||||
if (snapshotLength >= 2) {
|
if (snapshotLength >= 2) {
|
||||||
db.snapshots.update(allKeys[snapshotLength - 2] as number, { index: state.slideIndex })
|
snapshotDB.snapshots.update(allKeys[snapshotLength - 2] as number, { index: state.slideIndex })
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.snapshots.bulkDelete(needDeleteKeys)
|
await snapshotDB.snapshots.bulkDelete(needDeleteKeys)
|
||||||
|
|
||||||
commit(MutationTypes.SET_SNAPSHOT_CURSOR, snapshotLength - 1)
|
commit(MutationTypes.SET_SNAPSHOT_CURSOR, snapshotLength - 1)
|
||||||
commit(MutationTypes.SET_SNAPSHOT_LENGTH, snapshotLength)
|
commit(MutationTypes.SET_SNAPSHOT_LENGTH, snapshotLength)
|
||||||
@ -57,7 +57,7 @@ export const actions: ActionTree<State, State> = {
|
|||||||
if (state.snapshotCursor <= 0) return
|
if (state.snapshotCursor <= 0) return
|
||||||
|
|
||||||
const snapshotCursor = state.snapshotCursor - 1
|
const snapshotCursor = state.snapshotCursor - 1
|
||||||
const snapshots: Snapshot[] = await db.snapshots.orderBy('id').toArray()
|
const snapshots: Snapshot[] = await snapshotDB.snapshots.orderBy('id').toArray()
|
||||||
const snapshot = snapshots[snapshotCursor]
|
const snapshot = snapshots[snapshotCursor]
|
||||||
const { index, slides } = snapshot
|
const { index, slides } = snapshot
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ export const actions: ActionTree<State, State> = {
|
|||||||
if (state.snapshotCursor >= state.snapshotLength - 1) return
|
if (state.snapshotCursor >= state.snapshotLength - 1) return
|
||||||
|
|
||||||
const snapshotCursor = state.snapshotCursor + 1
|
const snapshotCursor = state.snapshotCursor + 1
|
||||||
const snapshots: Snapshot[] = await db.snapshots.orderBy('id').toArray()
|
const snapshots: Snapshot[] = await snapshotDB.snapshots.orderBy('id').toArray()
|
||||||
const snapshot = snapshots[snapshotCursor]
|
const snapshot = snapshots[snapshotCursor]
|
||||||
const { index, slides } = snapshot
|
const { index, slides } = snapshot
|
||||||
|
|
||||||
|
@ -18,4 +18,4 @@ class SnapshotDatabase extends Dexie {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new SnapshotDatabase()
|
export const snapshotDB = new SnapshotDatabase()
|
@ -15,7 +15,7 @@
|
|||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
:d="lineData.path"
|
:d="lineData.path"
|
||||||
stroke="#888"
|
stroke="#d14424"
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke-width="1"
|
stroke-width="1"
|
||||||
stroke-linecap
|
stroke-linecap
|
||||||
@ -200,9 +200,10 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
.selection {
|
.selection {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
opacity: .8;
|
||||||
|
|
||||||
&:not(.line) {
|
&:not(.line) {
|
||||||
border: 1px solid #888;
|
border: 1px solid $themeColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="slide-background"
|
class="viewport-background"
|
||||||
:style="backgroundStyle"
|
:style="backgroundStyle"
|
||||||
>
|
>
|
||||||
<GridLines v-if="showGridLines" />
|
<GridLines v-if="showGridLines" />
|
||||||
@ -15,7 +15,7 @@ import GridLines from './GridLines.vue'
|
|||||||
import useSlideBackgroundStyle from '@/hooks/useSlideBackgroundStyle'
|
import useSlideBackgroundStyle from '@/hooks/useSlideBackgroundStyle'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'slide-background',
|
name: 'viewport-background',
|
||||||
components: {
|
components: {
|
||||||
GridLines,
|
GridLines,
|
||||||
},
|
},
|
||||||
@ -35,7 +35,7 @@ export default defineComponent({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.slide-background {
|
.viewport-background {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background-position: center;
|
background-position: center;
|
@ -45,7 +45,7 @@
|
|||||||
:scaleElement="scaleElement"
|
:scaleElement="scaleElement"
|
||||||
:dragLineElement="dragLineElement"
|
:dragLineElement="dragLineElement"
|
||||||
/>
|
/>
|
||||||
<SlideBackground />
|
<ViewportBackground />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@ -101,7 +101,7 @@ import useScreening from '@/hooks/useScreening'
|
|||||||
|
|
||||||
import EditableElement from './EditableElement.vue'
|
import EditableElement from './EditableElement.vue'
|
||||||
import MouseSelection from './MouseSelection.vue'
|
import MouseSelection from './MouseSelection.vue'
|
||||||
import SlideBackground from './SlideBackground.vue'
|
import ViewportBackground from './ViewportBackground.vue'
|
||||||
import AlignmentLine from './AlignmentLine.vue'
|
import AlignmentLine from './AlignmentLine.vue'
|
||||||
import ElementCreateSelection from './ElementCreateSelection.vue'
|
import ElementCreateSelection from './ElementCreateSelection.vue'
|
||||||
import MultiSelectOperate from './Operate/MultiSelectOperate.vue'
|
import MultiSelectOperate from './Operate/MultiSelectOperate.vue'
|
||||||
@ -112,7 +112,7 @@ export default defineComponent({
|
|||||||
components: {
|
components: {
|
||||||
EditableElement,
|
EditableElement,
|
||||||
MouseSelection,
|
MouseSelection,
|
||||||
SlideBackground,
|
ViewportBackground,
|
||||||
AlignmentLine,
|
AlignmentLine,
|
||||||
ElementCreateSelection,
|
ElementCreateSelection,
|
||||||
MultiSelectOperate,
|
MultiSelectOperate,
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="editor-header">
|
<div class="editor-header">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<Dropdown :trigger="['click']">
|
<Dropdown :trigger="['click']" @visibleChange="visible => editDropdownVisible = visible">
|
||||||
<div class="menu-item"><IconEdit /> <span class="text">编辑</span></div>
|
<div class="menu-item" :class="['dropdown-menu', { 'active': editDropdownVisible }]">
|
||||||
|
<IconEdit /> <span class="text">编辑</span>
|
||||||
|
</div>
|
||||||
<template #overlay>
|
<template #overlay>
|
||||||
<Menu>
|
<Menu>
|
||||||
<MenuItem @click="undo()">撤销</MenuItem>
|
<MenuItem @click="undo()">撤销</MenuItem>
|
||||||
@ -14,8 +16,10 @@
|
|||||||
</Menu>
|
</Menu>
|
||||||
</template>
|
</template>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
<Dropdown :trigger="['click']">
|
<Dropdown :trigger="['click']" @visibleChange="visible => screenDropdownVisible = visible">
|
||||||
<div class="menu-item"><IconPpt /> <span class="text">演示</span></div>
|
<div class="menu-item" :class="['dropdown-menu', { 'active': screenDropdownVisible }]">
|
||||||
|
<IconPpt /> <span class="text">演示</span>
|
||||||
|
</div>
|
||||||
<template #overlay>
|
<template #overlay>
|
||||||
<Menu>
|
<Menu>
|
||||||
<MenuItem @click="enterScreeningFromStart()">从头开始</MenuItem>
|
<MenuItem @click="enterScreeningFromStart()">从头开始</MenuItem>
|
||||||
@ -23,8 +27,10 @@
|
|||||||
</Menu>
|
</Menu>
|
||||||
</template>
|
</template>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
<Dropdown :trigger="['click']">
|
<Dropdown :trigger="['click']" @visibleChange="visible => helpDropdownVisible = visible">
|
||||||
<div class="menu-item"><IconHelpcenter /> <span class="text">帮助</span></div>
|
<div class="menu-item" :class="['dropdown-menu', { 'active': helpDropdownVisible }]">
|
||||||
|
<IconHelpcenter /> <span class="text">帮助</span>
|
||||||
|
</div>
|
||||||
<template #overlay>
|
<template #overlay>
|
||||||
<Menu>
|
<Menu>
|
||||||
<MenuItem @click="openDoc()">开发文档</MenuItem>
|
<MenuItem @click="openDoc()">开发文档</MenuItem>
|
||||||
@ -40,11 +46,9 @@
|
|||||||
<IconPpt size="18" fill="#666" style="margin-top: 2px;" />
|
<IconPpt size="18" fill="#666" style="margin-top: 2px;" />
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip :mouseLeaveDelay="0" title="Github 仓库">
|
|
||||||
<a href="https://github.com/pipipi-pikachu/PPTist" target="_blank">
|
<a href="https://github.com/pipipi-pikachu/PPTist" target="_blank">
|
||||||
<div class="menu-item"><IconGithub size="18" fill="#666" /></div>
|
<div class="menu-item"><IconGithub size="18" fill="#666" /></div>
|
||||||
</a>
|
</a>
|
||||||
</Tooltip>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Drawer
|
<Drawer
|
||||||
@ -81,6 +85,10 @@ export default defineComponent({
|
|||||||
const { createSlide, deleteSlide } = useSlideHandler()
|
const { createSlide, deleteSlide } = useSlideHandler()
|
||||||
const { redo, undo } = useHistorySnapshot()
|
const { redo, undo } = useHistorySnapshot()
|
||||||
|
|
||||||
|
const editDropdownVisible = ref(false)
|
||||||
|
const screenDropdownVisible = ref(false)
|
||||||
|
const helpDropdownVisible = ref(false)
|
||||||
|
|
||||||
const showGridLines = computed(() => store.state.showGridLines)
|
const showGridLines = computed(() => store.state.showGridLines)
|
||||||
const toggleGridLines = () => {
|
const toggleGridLines = () => {
|
||||||
store.commit(MutationTypes.SET_GRID_LINES_STATE, !showGridLines.value)
|
store.commit(MutationTypes.SET_GRID_LINES_STATE, !showGridLines.value)
|
||||||
@ -112,6 +120,9 @@ export default defineComponent({
|
|||||||
resetSlides,
|
resetSlides,
|
||||||
openDoc,
|
openDoc,
|
||||||
hotkeyDrawerVisible,
|
hotkeyDrawerVisible,
|
||||||
|
editDropdownVisible,
|
||||||
|
screenDropdownVisible,
|
||||||
|
helpDropdownVisible,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -132,16 +143,24 @@ export default defineComponent({
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.menu-item {
|
.menu-item {
|
||||||
height: 70%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
margin: 0 10px;
|
padding: 0 10px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
.text {
|
.text {
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dropdown-menu {
|
||||||
|
transition: background-color .2s;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background-color: $lightGray;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
@ -52,7 +52,7 @@
|
|||||||
:value="filter.value"
|
:value="filter.value"
|
||||||
@change="value => updateFilter(filter, value)"
|
@change="value => updateFilter(filter, value)"
|
||||||
/>
|
/>
|
||||||
<div class="value">{{`${filter.value}${filter.unit}`}}</div>
|
<div class="value">{{filter.value}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user