改用PDF.js Viewer

This commit is contained in:
zhbaor 2021-11-02 01:35:31 +08:00
parent 316b7f1e05
commit 38b6a3bd57
364 changed files with 169161 additions and 13 deletions

View file

@ -28,7 +28,11 @@
<tr v-for="(file, j) in category.files" :key="j">
<td>{{ file }}</td>
<td class="text-center">
<a :href="`${url_root}${file}`"><i class="bi bi-book"></i></a>
<a
:href="`${url_root}pdfjs/web/viewer.html?file=${url_root}${file}`"
target="_blank"
><i class="bi bi-book"></i
></a>
</td>
<td class="text-center">
<a :href="`${url_root}${file}`"><i class="bi bi-cloud-download"></i></a>
@ -44,17 +48,18 @@
</div>
</div>
</div>
<canvas id="pdfCanvas"></canvas>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import * as pdfjsLib from 'pdfjs-dist';
export default defineComponent({
name: 'App',
data() {
return {
url_root: '/~lixiangyu/',
// url_root: '/~lixiangyu/',
url_root: '/',
categories: [
{
name: 'Computer',
@ -63,9 +68,5 @@ export default defineComponent({
],
};
},
mounted() {
pdfjsLib.GlobalWorkerOptions.workerSrc = '//mozilla.github.io/pdf.js/build/pdf.worker.js';
pdfjsLib.getDocument('https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/examples/learning/helloworld.pdf');
},
});
</script>