{{ define "main" }}
<div style="text-align:center;padding:80px 20px">
<h2>正在跳转...</h2>
<p style="color:#999">如果没有自动跳转，请点击下方链接</p>
<p><a id="target-link" href="#" target="_blank" rel="noopener" style="color:#374151;word-break:break-all"></a></p>
<p id="countdown" style="color:#999;font-size:14px"></p>
</div>
{{ end }}

{{ define "scripts" }}
<script>
(function(){
  var params = new URLSearchParams(window.location.search);
  var target = params.get('target');
  var linkEl = document.getElementById('target-link');
  var countdownEl = document.getElementById('countdown');
  if(!target){
    linkEl.textContent = '无效链接';
    return;
  }
  try{ target = atob(target); }catch(e){}
  linkEl.href = target;
  linkEl.textContent = target;
  var sec = 3;
  countdownEl.textContent = sec + ' 秒后自动跳转';
  var timer = setInterval(function(){
    sec--;
    if(sec <= 0){
      clearInterval(timer);
      window.location.href = target;
    } else {
      countdownEl.textContent = sec + ' 秒后自动跳转';
    }
  }, 1000);
})();
</script>
{{ end }}
