Skip to content

Commit

Permalink
remove plugin html2canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
Atipat Pankong committed Jun 26, 2024
1 parent 9aec549 commit ac6430a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
18 changes: 4 additions & 14 deletions src/pages/SchedulePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Unit from '../components/UnitSection.vue'
import axios from '../http'
import html2canvas from 'html2canvas'
import type { Options } from 'html2canvas'
import { createCaptureStyleTag } from '@/utils/createCaptureStyle'
import appendCopyright from '@/utils/appendCopyright'
const store = useStore()
const theme = computed(() => store.getters['theme/getTheme'])
Expand Down Expand Up @@ -67,12 +67,10 @@ const savePhoto = (base64: string) => {
}
const download = async () => {
const createBy = printcontent.value.lastElementChild as HTMLElement
createBy.className = 'mx-1 text-right block dark:text-white'
const options: Partial<Options> = {
windowWidth: 2560,
onclone: (cloneDocument) => {
createCaptureStyleTag(cloneDocument)
onclone: (_, element) => {
appendCopyright(element)
},
}
if (theme.value === 'dark') {
Expand All @@ -82,8 +80,6 @@ const download = async () => {
const printCanvas = await html2canvas(printcontent.value, options)
savePhoto(printCanvas.toDataURL())
createBy.className = 'hidden'
}
const timeToCol = (timeString: string) => {
Expand Down Expand Up @@ -191,7 +187,7 @@ onMounted(() => {
</div>
</div>
</div>
<div ref="printcontent" class="overflow-x-auto border mx-1 rounded-lg">
<div id="print-content" ref="printcontent" class="overflow-x-auto border mx-1 rounded-lg">
<div id="table" class="overflow-x-hidden table-w">
<div class="grid grid-cols-168">
<div
Expand Down Expand Up @@ -243,12 +239,6 @@ onMounted(() => {
</div>
</div>
</div>
<span id="create-by" class="hidden"
>created by
<a href="https://ku-table.vercel.app" class="text-blue-600 underline"
>https://ku-table.vercel.app
</a>
</span>
</div>
<unit class="dark:text-white" :lang="isCheck" />
</div>
Expand Down
13 changes: 13 additions & 0 deletions src/utils/appendCopyright.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default function appendCopyright(element: HTMLElement) {
const spanElement = document.createElement('span')
spanElement.innerText = 'created by'
spanElement.className = 'mx-1 text-right block dark:text-white'
const link = document.createElement('a')
link.setAttribute('href', 'https://ku-table.vercel.app')
link.innerText = 'https://ku-table.vercel.app'
link.className = 'text-blue-600 underline pl-1'

spanElement.appendChild(link)

element.appendChild(spanElement)
}
7 changes: 0 additions & 7 deletions src/utils/createCaptureStyle.ts

This file was deleted.

0 comments on commit ac6430a

Please sign in to comment.