File size: 1,249 Bytes
89ce340
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<template>
  <div class="mobile-editor-header">
    <div class="history">
      <div class="history-item" :class="{ 'disable': !canUndo }" @click.stop="undo()"><IconBack /> ๆ’ค้”€</div>
      <div class="history-item" :class="{ 'disable': !canRedo }" @click.stop="redo()"><IconNext /> ้‡ๅš</div>
    </div>
    <div class="back" @click="changeMode('preview')"><IconLogout /> ้€€ๅ‡บ็ผ–่พ‘</div>
  </div>
</template>

<script lang="ts" setup>
import { storeToRefs } from 'pinia'
import { useSnapshotStore } from '@/store'
import type { Mode } from '@/types/mobile'
import useHistorySnapshot from '@/hooks/useHistorySnapshot'

defineProps<{
  changeMode: (mode: Mode) => void
}>()

const { canUndo, canRedo } = storeToRefs(useSnapshotStore())
const { redo, undo } = useHistorySnapshot()
</script>

<style lang="scss" scoped>
.mobile-editor-header {
  height: 50px;
  background-color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px;
  font-size: 13px;
  box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 2;
}
.history {
  display: flex;
  justify-content: center;
  align-items: center;
}
.history-item {
  margin-right: 20px;

  &.disable {
    opacity: .5;
  }
}
</style>