feat:增加打印功能
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
import { ZERO } from "../dataset/constant/Common"
|
||||
|
||||
export function writeText(text: string) {
|
||||
if (!text) return
|
||||
window.navigator.clipboard.writeText(text.replaceAll(ZERO, `\n`))
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import { ZERO } from "../dataset/constant/Common"
|
||||
|
||||
export function debounce(func: Function, delay: number) {
|
||||
let timer: number
|
||||
return function (...args: any) {
|
||||
@@ -11,11 +9,6 @@ export function debounce(func: Function, delay: number) {
|
||||
}
|
||||
}
|
||||
|
||||
export function writeText(text: string) {
|
||||
if (!text) return
|
||||
window.navigator.clipboard.writeText(text.replaceAll(ZERO, `\n`))
|
||||
}
|
||||
|
||||
export function deepClone(obj: any) {
|
||||
if (!obj || typeof obj !== 'object') {
|
||||
return obj
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
export function printImageBase64(base64: string) {
|
||||
const iframe = document.createElement('iframe')
|
||||
document.body.append(iframe)
|
||||
const doc = iframe.contentWindow!.document
|
||||
doc.open()
|
||||
const image = doc.createElement('img')
|
||||
image.style.width = '794px'
|
||||
image.style.height = '1123px'
|
||||
image.src = base64
|
||||
const style = document.createElement('style')
|
||||
const stylesheet = `*{margin:0;padding:0;}`
|
||||
style.append(document.createTextNode(stylesheet))
|
||||
setTimeout(() => {
|
||||
doc.write(`${style.outerHTML}${image.outerHTML}`)
|
||||
iframe.contentWindow?.print()
|
||||
doc.close()
|
||||
iframe.remove()
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user