format with prettier
This commit is contained in:
parent
f7178d212a
commit
3c35c1e552
10 changed files with 540 additions and 466 deletions
|
|
@ -1,17 +1,17 @@
|
|||
import { PDFOptions } from 'puppeteer'
|
||||
/**
|
||||
import { PDFOptions } from "puppeteer"
|
||||
/**
|
||||
* @prop {string} template template ID
|
||||
* @prop {string} reportName outputname
|
||||
* @prop {htmlTemplateOption} htmlOption? support only html-template
|
||||
* @prop {object} data json data for apply template
|
||||
*/
|
||||
export interface templateOption {
|
||||
template: string
|
||||
reportName: string
|
||||
htmlOption?:htmlTemplateOption
|
||||
data: object
|
||||
template: string
|
||||
reportName: string
|
||||
htmlOption?: htmlTemplateOption
|
||||
data: object
|
||||
}
|
||||
/**
|
||||
/**
|
||||
* @prop {number} navigationTimeout page.setDefaultNavigationTimeout(navigationTimeout)
|
||||
* @prop {number} querySelector Element of page
|
||||
* @prop {number} waitUntil 'networkidle0' or 'networkidle0'
|
||||
|
|
@ -21,48 +21,48 @@ export interface templateOption {
|
|||
* @prop {PDFOptions} pdfOption PdfOptions of Puppeteer
|
||||
*/
|
||||
export interface htmlTemplateOption {
|
||||
navigationTimeout?:number
|
||||
querySelector?: string
|
||||
waitUntil?:string
|
||||
preloadWait?:number
|
||||
preloadScroll?:number
|
||||
preloadLoop?:number
|
||||
pdfOption?: PDFOptions
|
||||
navigationTimeout?: number
|
||||
querySelector?: string
|
||||
waitUntil?: string
|
||||
preloadWait?: number
|
||||
preloadScroll?: number
|
||||
preloadLoop?: number
|
||||
pdfOption?: PDFOptions
|
||||
}
|
||||
|
||||
|
||||
|
||||
export interface IDictionary<TValue> {
|
||||
[key: string]: TValue
|
||||
[key: string]: TValue
|
||||
}
|
||||
export function mimeToExtension(mime: string): string {
|
||||
const mimeList: IDictionary<string> = {
|
||||
"application/pdf": "pdf",
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
||||
"application/msword": "doc",
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
|
||||
"application/vnd.ms-excel": "xls",
|
||||
"application/vnd.ms-powerpoint": "ppt",
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
|
||||
"application/vnd.oasis.opendocument.text": "odt",
|
||||
"application/vnd.oasis.opendocument.spreadsheet": "ods",
|
||||
"application/vnd.oasis.opendocument.presentation": "odp",
|
||||
"text/html": "html",
|
||||
"application/json": "json",
|
||||
"text/csv": "csv",
|
||||
"text/markdown": "md",
|
||||
"text/plain": "txt",
|
||||
"application/rtf": "rtf",
|
||||
"image/png": "png",
|
||||
"image/jpeg": "jpeg",
|
||||
}
|
||||
if (mimeList[mime]) {
|
||||
return mimeList[mime]
|
||||
} else if (mime.match(/^application\/x\./)) {
|
||||
return mime.substr(mime.indexOf(".") + 1)
|
||||
} else {
|
||||
return mime
|
||||
}
|
||||
const mimeList: IDictionary<string> = {
|
||||
"application/pdf": "pdf",
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document":
|
||||
"docx",
|
||||
"application/msword": "doc",
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
|
||||
"application/vnd.ms-excel": "xls",
|
||||
"application/vnd.ms-powerpoint": "ppt",
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.presentation":
|
||||
"pptx",
|
||||
"application/vnd.oasis.opendocument.text": "odt",
|
||||
"application/vnd.oasis.opendocument.spreadsheet": "ods",
|
||||
"application/vnd.oasis.opendocument.presentation": "odp",
|
||||
"text/html": "html",
|
||||
"application/json": "json",
|
||||
"text/csv": "csv",
|
||||
"text/markdown": "md",
|
||||
"text/plain": "txt",
|
||||
"application/rtf": "rtf",
|
||||
"image/png": "png",
|
||||
"image/jpeg": "jpeg",
|
||||
}
|
||||
if (mimeList[mime]) {
|
||||
return mimeList[mime]
|
||||
} else if (mime.match(/^application\/x\./)) {
|
||||
return mime.substr(mime.indexOf(".") + 1)
|
||||
} else {
|
||||
return mime
|
||||
}
|
||||
}
|
||||
/** javascript-obfuscator:disable
|
||||
* @swagger
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue