feat: 增加截图新配置
This commit is contained in:
		
							parent
							
								
									841c31d4ec
								
							
						
					
					
						commit
						03ff09289f
					
				|  | @ -13,19 +13,21 @@ export class Image { | ||||||
|    * @returns |    * @returns | ||||||
|    */ |    */ | ||||||
|   getHelloComponent(uid: number, data: DataType) { |   getHelloComponent(uid: number, data: DataType) { | ||||||
|     // 生成 html 地址
 |     // 生成 html 地址 或 html字符串
 | ||||||
|     const Address = Com.create(<Hello data={data} />, { |     const Address = Com.create(<Hello data={data} />, { | ||||||
|       /** |       /** | ||||||
|        * 注意,不设置json_dir时, |        * 注意,不设置json_dir时, | ||||||
|        * html_head路径应该是../public/output.css |        * html_head路径应该是../public/output.css | ||||||
|        * 且html_head默认值路径也是../public/output.css |        * 且html_head默认值路径也是../public/output.css | ||||||
|        * 因此,不增加其他head的话,html_head和join_dir都可以胜利 |        * 因此,不增加其他head的话,html_head和join_dir都可以省略 | ||||||
|        * { html_name: `${uid}.html`} |        * { html_name: `${uid}.html`} | ||||||
|        */ |        */ | ||||||
|       html_head: `<link rel="stylesheet" href="../../public/output.css"></link>`, |       html_head: `<link rel="stylesheet" href="../../public/output.css"></link>`, | ||||||
|       // html/hello/uid.html
 |       // html/hello/uid.html
 | ||||||
|       join_dir: 'hello', |       join_dir: 'hello', | ||||||
|       html_name: `${uid}.html` |       html_name: `${uid}.html` | ||||||
|  |       // 不生成文件,返回的将是html字符串
 | ||||||
|  |       // file_create:false
 | ||||||
|     }) |     }) | ||||||
|     return Pup.render(Address) |     return Pup.render(Address) | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | @ -8,6 +8,7 @@ type ComponentCreateOpsionType = { | ||||||
|   html_name?: string |   html_name?: string | ||||||
|   join_dir?: string |   join_dir?: string | ||||||
|   html_body?: string |   html_body?: string | ||||||
|  |   file_create?: boolean | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  | @ -39,6 +40,12 @@ export class Component { | ||||||
|     const head = `<head>${options?.html_head ?? Link}</head>` |     const head = `<head>${options?.html_head ?? Link}</head>` | ||||||
|     const body = `<body> ${str} ${options?.html_body ?? ''}</body>` |     const body = `<body> ${str} ${options?.html_body ?? ''}</body>` | ||||||
|     const html = `${DOCTYPE}<html>${head}${body}</html>` |     const html = `${DOCTYPE}<html>${head}${body}</html>` | ||||||
|  |     if ( | ||||||
|  |       typeof options?.file_create == 'boolean' && | ||||||
|  |       options?.file_create == false | ||||||
|  |     ) { | ||||||
|  |       return html | ||||||
|  |     } | ||||||
|     writeFileSync(address, html) |     writeFileSync(address, html) | ||||||
|     return address |     return address | ||||||
|   } |   } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue