Skip to content

Commit

Permalink
[new] 模板渲染+github提交
Browse files Browse the repository at this point in the history
  • Loading branch information
notmaster-C committed Jun 19, 2024
1 parent a896322 commit b971cab
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 24 deletions.
68 changes: 45 additions & 23 deletions assets/js/index.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,66 @@
const data={
const data = {
userName: "菜菜",
job:"后端开发工程师",
address:"成都",
age:"24岁",
sex:"男",
tel:15984426676,
email:"[email protected]",
skills:[
job: "后端开发工程师",
address: "成都",
age: "24岁",
sex: "男",
tel: 15984426676,
email: "[email protected]",
lastCommit: [],
skills: [
{
name:"JAVA",
per:88
name: "JAVA",
per: 88
},
{
name:"Golang",
per:88
name: "Golang",
per: 88
},
{
name:"Linux",
per:85
name: "Linux",
per: 85
},
{
name:"Mysql",
per:83
name: "Mysql",
per: 83
},
{
name:"Oracle",
per:80
name: "Oracle",
per: 80
},
]
}
function TimestampToDate(Timestamp) {
let date1 = new Date(Timestamp);
return date1.toLocaleDateString().replace(/\//g, "-") + " " + date1.toTimeString().substr(0, 8);
}
console.log("感谢您的浏览,期待能够加入贵公司!");
layui.use(function(){
var laytpl = layui.laytpl,$=layui.jquery
layui.use(function () {
var laytpl = layui.laytpl, $ = layui.jquery
$('#view').html("渲染中...")
$.ajax({
url: ".git/logs/HEAD",
success: function (res) {
//去掉最后一行的换行符
x = res.substring(0, res.lastIndexOf("\n"))
if (x.lastIndexOf("\n") > 0) {
data.lastCommit = x.substring(x.lastIndexOf("\n"), x.length).trim().split(" ");
console.log("上一次提交信息", data.lastCommit)
console.log("上一次提交时间", data.lastCommit[4] + '000')
console.log("当前时间", new Date().getTime())
let datet=TimestampToDate(parseInt(data.lastCommit[4]+'000'))
data.lastCommit[4] = datet

}
}
})
//引入外部html
$.get('assets/pages/home.html',function(homePage){
$.get('assets/pages/home.html', function (homePage) {
//渲染并输出结果
laytpl(homePage).render(data, function(str){
laytpl(homePage).render(data, function (str) {
$('#view').html(str);
});
});

});
})

13 changes: 12 additions & 1 deletion assets/pages/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,24 @@ <h2>
<hr/>
<p>善于倾听和交流,具有团队精神,能够有效解决问题;</p>
</section>

<!-- github -->
<section class="work info-unit">
<h2>
<i class="fa fa-pencil" aria-hidden="true"></i>Github</h2>
<hr/>
<div>{{=d.lastCommit[2]+'@'+d.lastCommit[3]+'在'+d.lastCommit[4]+'提交了'+d.lastCommit[6]}}</div>
<img style="align-items: center;" src="https://ghchart.rshah.org/notmaster-C" />
</section>

</section>
</section>
</article>



<footer class="footer">
<p>© 2024 蔡蔡 .文档最后更新时间为
<p>{{='© 2024-'+new Date().getFullYear()+d.userName}} .文档最后更新时间为
<time>2024年04月11日</time>.</p>
</footer>

Expand Down

0 comments on commit b971cab

Please sign in to comment.