job51-gitlab-cr-node-skill-prompt-optimize 1.3.8 → 1.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/anthropic.env +5 -0
- package/.claude/rules/code-review-rules.md +209 -0
- package/.claude/settings.json +10 -0
- package/.claude/settings.local.json +24 -1
- package/.claude/skills/simple-code-review/SKILL.md +68 -0
- package/.npmignore +12 -0
- package/index.js +628 -535
- package/mr-review-template.md +23 -141
- package/package.json +8 -4
- package/PDF_CONVERSION_README.md +0 -131
- package/convert-report-to-pdf.js +0 -240
- package/print-div-pdf.html +0 -167
- package/refactor(ci)_ /346/233/264/346/226/260GitLab CI/351/205/215/347/275/256/345/271/266/344/274/230/345/214/226/347/253/236/344/272/211/345/210/206/346/236/220/346/227/245/345/277/227/346/234/215/345/212/241 (!118) /302/267 Merge requests /302/267 51JobWeb _ dev-boot-test /302/267 GitLab.pdf +0 -0
package/print-div-pdf.html
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="zh-CN">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>打印Div为PDF示例</title>
|
|
7
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
|
|
8
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
|
|
9
|
-
<style>
|
|
10
|
-
body {
|
|
11
|
-
font-family: Arial, sans-serif;
|
|
12
|
-
padding: 20px;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
#contentToPrint {
|
|
16
|
-
border: 2px solid #ccc;
|
|
17
|
-
padding: 20px;
|
|
18
|
-
margin: 20px 0;
|
|
19
|
-
background-color: #f9f9f9;
|
|
20
|
-
min-height: 300px;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
button {
|
|
24
|
-
background-color: #4CAF50;
|
|
25
|
-
color: white;
|
|
26
|
-
padding: 10px 20px;
|
|
27
|
-
border: none;
|
|
28
|
-
cursor: pointer;
|
|
29
|
-
border-radius: 4px;
|
|
30
|
-
font-size: 16px;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
button:hover {
|
|
34
|
-
background-color: #45a049;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
h2 {
|
|
38
|
-
color: #333;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
p {
|
|
42
|
-
line-height: 1.6;
|
|
43
|
-
}
|
|
44
|
-
</style>
|
|
45
|
-
</head>
|
|
46
|
-
<body>
|
|
47
|
-
<h1>打印Div为PDF示例</h1>
|
|
48
|
-
|
|
49
|
-
<button onclick="printDivToPDF()">打印指定区域为PDF</button>
|
|
50
|
-
|
|
51
|
-
<div id="contentToPrint">
|
|
52
|
-
<h2>这是一个要打印到PDF的区域</h2>
|
|
53
|
-
<p>这里是第一段内容。这是一些测试文本,用来展示如何将特定的div区域打印为PDF。</p>
|
|
54
|
-
<p>这里是第二段内容。可以看到我们有丰富的文本内容可以被转换成PDF。</p>
|
|
55
|
-
<ul>
|
|
56
|
-
<li>列表项 1</li>
|
|
57
|
-
<li>列表项 2</li>
|
|
58
|
-
<li>列表项 3</li>
|
|
59
|
-
</ul>
|
|
60
|
-
<p>最后的段落,展示更多内容。</p>
|
|
61
|
-
</div>
|
|
62
|
-
|
|
63
|
-
<div>
|
|
64
|
-
<p>这个区域不会被打印到PDF中,因为它不在目标div内。</p>
|
|
65
|
-
</div>
|
|
66
|
-
|
|
67
|
-
<script>
|
|
68
|
-
// 获取jsPDF实例
|
|
69
|
-
const { jsPDF } = window.jspdf;
|
|
70
|
-
|
|
71
|
-
function printDivToPDF() {
|
|
72
|
-
// 获取要打印的div元素
|
|
73
|
-
const element = document.getElementById('contentToPrint');
|
|
74
|
-
|
|
75
|
-
// 使用html2canvas将div转换为canvas
|
|
76
|
-
html2canvas(element, {
|
|
77
|
-
scale: 2, // 提高清晰度
|
|
78
|
-
useCORS: true, // 允许跨域图像
|
|
79
|
-
backgroundColor: '#ffffff' // 设置背景色
|
|
80
|
-
}).then(canvas => {
|
|
81
|
-
// 将canvas转换为数据URL
|
|
82
|
-
const imgData = canvas.toDataURL('image/png');
|
|
83
|
-
|
|
84
|
-
// 创建PDF
|
|
85
|
-
const pdf = new jsPDF('p', 'mm', 'a4');
|
|
86
|
-
|
|
87
|
-
// 计算图片在PDF中的尺寸以适应页面宽度
|
|
88
|
-
const imgWidth = 210; // A4页面宽度(mm)
|
|
89
|
-
const pageHeight = 295; // A4页面高度(mm)
|
|
90
|
-
const imgHeight = canvas.height * imgWidth / canvas.width;
|
|
91
|
-
|
|
92
|
-
let heightLeft = imgHeight;
|
|
93
|
-
let position = 0;
|
|
94
|
-
|
|
95
|
-
// 第一页添加图像
|
|
96
|
-
pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
|
|
97
|
-
heightLeft -= pageHeight;
|
|
98
|
-
|
|
99
|
-
// 如果内容超过一页,则添加新页
|
|
100
|
-
while (heightLeft >= 0) {
|
|
101
|
-
position = heightLeft - imgHeight;
|
|
102
|
-
pdf.addPage();
|
|
103
|
-
pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
|
|
104
|
-
heightLeft -= pageHeight;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// 保存PDF
|
|
108
|
-
pdf.save('div-content.pdf');
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// 纯函数版本:将div转换为PDF的可重用函数
|
|
113
|
-
function divToPDF(divId, filename = 'output.pdf') {
|
|
114
|
-
return new Promise((resolve, reject) => {
|
|
115
|
-
const element = document.getElementById(divId);
|
|
116
|
-
|
|
117
|
-
if (!element) {
|
|
118
|
-
reject(new Error(`Element with id '${divId}' not found`));
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
html2canvas(element, {
|
|
123
|
-
scale: 2,
|
|
124
|
-
useCORS: true,
|
|
125
|
-
backgroundColor: '#ffffff'
|
|
126
|
-
}).then(canvas => {
|
|
127
|
-
const imgData = canvas.toDataURL('image/png');
|
|
128
|
-
|
|
129
|
-
const pdf = new jsPDF('p', 'mm', 'a4');
|
|
130
|
-
const imgWidth = 210;
|
|
131
|
-
const pageHeight = 295;
|
|
132
|
-
const imgHeight = canvas.height * imgWidth / canvas.width;
|
|
133
|
-
|
|
134
|
-
let heightLeft = imgHeight;
|
|
135
|
-
let position = 0;
|
|
136
|
-
|
|
137
|
-
pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
|
|
138
|
-
heightLeft -= pageHeight;
|
|
139
|
-
|
|
140
|
-
while (heightLeft >= 0) {
|
|
141
|
-
position = heightLeft - imgHeight;
|
|
142
|
-
pdf.addPage();
|
|
143
|
-
pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
|
|
144
|
-
heightLeft -= pageHeight;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
pdf.save(filename);
|
|
148
|
-
resolve(pdf);
|
|
149
|
-
}).catch(error => {
|
|
150
|
-
reject(error);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// 示例:使用纯函数版本
|
|
156
|
-
function printWithFunction() {
|
|
157
|
-
divToPDF('contentToPrint', 'my-document.pdf')
|
|
158
|
-
.then(() => {
|
|
159
|
-
console.log('PDF已成功生成');
|
|
160
|
-
})
|
|
161
|
-
.catch(error => {
|
|
162
|
-
console.error('生成PDF时出错:', error);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
</script>
|
|
166
|
-
</body>
|
|
167
|
-
</html>
|