Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
tc0715888 authored Jan 13, 2025
1 parent 770d7a9 commit 7567bba
Showing 1 changed file with 32 additions and 16 deletions.
48 changes: 32 additions & 16 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,37 @@ <h3 class="page-head">
<span class="price">价格: {{ domain.price }} 欧/美元</span>
{% endif %}
</div>
<div class="domain-actions">
<span class="whois-check">
[<a href="{{ site.whois_provider }}{{ domain.domain }}"
target="_blank" title="查看 WHOIS 信息">
<i class="fa fa-search"></i> WHOIS查询</a>]
</span>
{% if site.domain_managers[tld] %}
[<a href="{{ site.domain_managers[tld].url }}"
target="_blank" title="域名管理">
<i class="fa fa-cog"></i> 管理</a>]
{% endif %}
</div>
<div class="expiry-date {% if remaining <= 30 %}expiry-warning{% endif %}">
{{ warningText }}续费日期: {{ renewalDateStr }}
(剩余 {{ remaining }} 天)
</div>
<script>
var registrationDateString = '{{ domain.registration_date }}';
var registrationDate = new Date(registrationDateString);
var today = new Date();
today.setHours(0, 0, 0, 0);

// 计算下一个续费日期
var nextRenewalDate = new Date(registrationDate);
nextRenewalDate.setFullYear(today.getFullYear());

// 如果今年的续费日期已经过了,就计算明年的续费日期
if (nextRenewalDate < today) {
nextRenewalDate.setFullYear(today.getFullYear() + 1);
}

// 计算剩余天数
var timeDiff = nextRenewalDate.getTime() - today.getTime();
var remaining = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));

// 格式化续费日期
var renewalDateStr = nextRenewalDate.getFullYear() + '-' +
String(nextRenewalDate.getMonth() + 1).padStart(2, '0') + '-' +
String(nextRenewalDate.getDate()).padStart(2, '0');

// 根据剩余天数决定显示样式
var warningClass = remaining <= 30 ? 'expiry-warning' : '';
document.write('<div class="expiry-date ' + warningClass + '">' +
(remaining <= 30 ? '⚠️ ' : '') +
'续费日期: ' + renewalDateStr +
' (剩余 ' + remaining + ' 天)</div>');
</script>
</a>
</li>
{%- endfor -%}
Expand Down Expand Up @@ -168,3 +183,4 @@ <h3>域名汇总信息</h3>

</html>


0 comments on commit 7567bba

Please sign in to comment.