modified widget "server-status"

This commit is contained in:
TaurusXin 2021-12-16 15:31:51 +00:00
parent 4ce38d51a7
commit 481db4e836
3 changed files with 58 additions and 26 deletions

26
assets/scss/custom.scss Normal file
View File

@ -0,0 +1,26 @@
.widget.archives {
.widget-archive--list {
border-radius: var(--card-border-radius);
box-shadow: var(--shadow-l1);
background-color: var(--card-background);
}
.status-item {
&:not(:last-of-type) {
border-bottom: 1.5px solid var(--card-separator-color);
}
font-size: 1.4rem;
padding: 18px 25px;
display: flex;
span.year {
flex: 1;
color: var(--card-text-color-main);
font-weight: bold;
}
span.count {
color: var(--card-text-color-tertiary);
}
}
}

View File

@ -5,6 +5,6 @@ widget:
status:
title: 状态
start: 博客建立自:
time: 已稳定运行:
postCount: 总文章数量:
postCount: 文章数量
start: 博客起始
time: 稳定运行

View File

@ -1,39 +1,45 @@
{{/*-- post count */}}
{{ $posts := (where .Site.RegularPages "Section" "==" "post") }}
{{ $postCount := len $posts }}
{{/*-- post count */}} {{ $posts := (where .Site.RegularPages "Section" "==" "post") }} {{
$postCount := len $posts }}
<section class="widget tagCloud">
<div class="widget-icon">
{{ partial "helper/icon" "status" }}
</div>
<section class="widget archives">
<div class="widget-icon">{{ partial "helper/icon" "status" }}</div>
<h2 class="widget-title section-title">{{ T "widget.status.title" }}</h2>
<div class="tagCloud-tags" style="display: flex; flex-direction: column;">
<div style="padding: 10px 0; color: #bababa;">{{ T "widget.status.postCount" }}{{ $postCount }}</div>
<div style="padding: 10px 0; color: #bababa;">{{ T "widget.status.start" }}<span id="start"></span></div>
<div style="padding: 10px 0; color: #bababa;">{{ T "widget.status.time" }}<span id="time"></span></div>
<div class="widget-archive--list">
<div class="status-item">
<span class="year">{{ T "widget.status.postCount" }}</span>
<span class="count">{{ $postCount }}</span>
</div>
<div class="status-item">
<span class="year">{{ T "widget.status.start" }}</span>
<span class="count" id="start"></span>
</div>
<div class="status-item">
<span class="year">{{ T "widget.status.time" }}</span>
<span class="count" id="time"></span>
</div>
</div>
<script>
Date.prototype.format = function(fmt) {
var o = {
"M+" : this.getMonth()+1, //月份
"d+" : this.getDate(), //日
"h+" : this.getHours(), //小时
"m+" : this.getMinutes(), //分
"s+" : this.getSeconds(), //秒
"q+" : Math.floor((this.getMonth()+3)/3), //季度
"S" : this.getMilliseconds() //毫秒
};
Date.prototype.format = function(fmt) {
var o = {
"M+" : this.getMonth()+1, //月份
"d+" : this.getDate(), //日
"h+" : this.getHours(), //小时
"m+" : this.getMinutes(), //分
"s+" : this.getSeconds(), //秒
"q+" : Math.floor((this.getMonth()+3)/3), //季度
"S" : this.getMilliseconds() //毫秒
};
if(/(y+)/.test(fmt)) {
fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
}
for(var k in o) {
if(new RegExp("("+ k +")").test(fmt)){
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
}
}
return fmt;
return fmt;
}