| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import {
- NEXT_PAGE,
- PREVIOUS_PAGE,
- RESET,
- SET_CURRENT_PAGE, SET_SCREEN_SHOT,
- SET_SRC, SET_TOTAL_PAGES, TOGGLE_SHOW_DISCUSSION, USE_SCREEN_SHOT
- } from '@/store/types/pdf-types'
- export default {
- state: {
- src: '',
- totalPages: 0,
- currentPage: 1,
- showDiscussion: false,
- screenShot: false
- },
- mutations: {
- [PREVIOUS_PAGE] (state) {
- state.currentPage = state.currentPage > 0 ? state.currentPage - 1 : state.currentPage
- },
- [NEXT_PAGE] (state) {
- state.currentPage = state.currentPage < state.totalPages ? state.currentPage + 1 : state.currentPage
- },
- [SET_CURRENT_PAGE] (state, payload) {
- state.currentPage = payload.currentPage
- },
- [SET_TOTAL_PAGES] (state, payload) {
- state.totalPages = payload.totalPages
- },
- [SET_SRC] (state, payload) {
- state.src = payload.src
- },
- [TOGGLE_SHOW_DISCUSSION] (state) {
- state.showDiscussion = !state.showDiscussion
- },
- [SET_SCREEN_SHOT] (state) {
- state.screenShot = true
- // 防止没有还原导致不能截图
- setTimeout(() => { state.screenShot = false }, 200)
- },
- [USE_SCREEN_SHOT] (state) {
- state.screenShot = false
- },
- [RESET] (state) {
- state.src = ''
- state.totalPages = 0
- state.currentPage = 1
- state.screenShot = false
- }
- }
- }
|