|
|
@@ -26,13 +26,9 @@ export default {
|
|
|
this._canvas.height = 1080
|
|
|
this._canvas.width = 1440
|
|
|
|
|
|
- const loadingTask = pdfjs.getDocument(this.src)
|
|
|
- loadingTask.promise.then(pdf => {
|
|
|
- this.loading = false
|
|
|
- this._pdf = pdf
|
|
|
- this.$store.commit(SET_TOTAL_PAGES, { totalPages: pdf.numPages })
|
|
|
- this.showPage()
|
|
|
- })
|
|
|
+ if (this.src) {
|
|
|
+ this.load(this.src)
|
|
|
+ }
|
|
|
},
|
|
|
computed: {
|
|
|
...mapState({
|
|
|
@@ -56,9 +52,23 @@ export default {
|
|
|
this.getScreenShot()
|
|
|
this.$store.commit(USE_SCREEN_SHOT)
|
|
|
}
|
|
|
+ },
|
|
|
+ src (value) {
|
|
|
+ if (value) {
|
|
|
+ this.load(value)
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ load (src) {
|
|
|
+ const loadingTask = pdfjs.getDocument(src)
|
|
|
+ loadingTask.promise.then(pdf => {
|
|
|
+ this.loading = false
|
|
|
+ this._pdf = pdf
|
|
|
+ this.$store.commit(SET_TOTAL_PAGES, { totalPages: pdf.numPages })
|
|
|
+ this.showPage()
|
|
|
+ })
|
|
|
+ },
|
|
|
showPage () {
|
|
|
this._pdf && this._pdf.getPage(this.currentPage || 1).then(page => {
|
|
|
const scale = 2.5
|