主题:隐私提示及背景音乐

- 首页提示选择是否开启音乐
 - 网络请求 timeout=30s
This commit is contained in:
周中平 2023-10-31 18:04:47 +08:00
parent 0990cb9b66
commit 47918d49a1
Signed by: zhouzhongping
GPG Key ID: 6666822800008000
4 changed files with 95 additions and 8 deletions

View File

@ -31,8 +31,6 @@ class Config:
logger.error(f"没有权限读取配置文件 {self.path} {str(e)}") logger.error(f"没有权限读取配置文件 {self.path} {str(e)}")
raise raise
logger.info(f"配置文件 {self.path} 加载成功")
@property @property
def rss_url(self): def rss_url(self):
try: try:

View File

@ -13,14 +13,14 @@ def check_website_status(url):
:return:True 可以访问False 不可以 :return:True 可以访问False 不可以
""" """
try: try:
response = requests.get(url, timeout=5) # Set timeout to 5 seconds response = requests.get(url, timeout=30) # Set timeout to 5 seconds
if response.status_code == 200: if response.status_code == 200:
return True return True
else: else:
logger.error(f"{url} 网站无法访问,状态码:{response.status_code}") logger.error(f"{url} 网站无法访问,状态码:{response.status_code}")
return False return False
except requests.Timeout as e: except requests.Timeout as e:
logger.error(f"{url} 请求超时,错误:{e}") logger.error(f"{url} 请求超时 30 秒,错误:{e}")
return False return False
except requests.ConnectionError as e: except requests.ConnectionError as e:
logger.error(f"{url} 连接错误,错误:{e}") logger.error(f"{url} 连接错误,错误:{e}")
@ -57,7 +57,7 @@ def get_domain_life(url):
domain_url = f"https://rdap.verisign.com/com/v1/domain/{url}" domain_url = f"https://rdap.verisign.com/com/v1/domain/{url}"
try: try:
response = requests.get(domain_url, headers=headers) response = requests.get(domain_url, headers=headers, timeout=30)
response.raise_for_status() # Raises stored HTTPError, if one occurred. response.raise_for_status() # Raises stored HTTPError, if one occurred.
registration_date = response.json().get('events')[0].get('eventDate') registration_date = response.json().get('events')[0].get('eventDate')

View File

@ -76,6 +76,47 @@ html {
#tab1 { #tab1 {
background-image: url('../img/page1.jpg'); background-image: url('../img/page1.jpg');
position: relative;
}
.popup {
position: absolute;
bottom: 0.5rem;
background: #fff;
padding: 1.5rem;
border: 1px solid #d1d1d1;
}
.popup > .notice > hr {
margin: 1rem 0;
}
.popup > .selection {
text-align: right;
}
.selection > button {
border: none;
padding: 0.75rem 1rem;
margin: 0.5rem 0 0 0.5rem;
}
.allow {
cursor: pointer;
}
.deny {
background-color: #059862;
cursor: pointer;
color: #fff;
padding: 0.5rem 0;
opacity: 0.8;
}
.deny:hover,
.deny:focus {
opacity: 1;
cursor: pointer;
} }
#tab2 { #tab2 {

View File

@ -13,10 +13,37 @@
<link rel="stylesheet" href="painting/css/animate.min.css"> <link rel="stylesheet" href="painting/css/animate.min.css">
<link rel="stylesheet" href="painting/css/painting.css"> <link rel="stylesheet" href="painting/css/painting.css">
{% endif %} {% endif %}
<script async src="https://umami.7wate.org/script.js" data-website-id="635fec50-bc6c-4ac2-909a-e2a7403438be"></script> <script async src="https://umami.7wate.org/script.js"
data-website-id="635fec50-bc6c-4ac2-909a-e2a7403438be"></script>
</head> </head>
<body> <body>
<div class="container active animate__animated animate__fadeIn animate__slow" id="tab1"></div> <div class="container active animate__animated animate__fadeIn animate__slow" id="tab1">
<audio id="bgm" loop>
{% if web_status == 1 %}
<source src="{{ url_for('static', filename='painting/music/bgm.mp3') }}" type="audio/mpeg">Your browser does not support the audio element.
{% else %}
<source src="painting/Time.ogg" type="audio/music/bgm.mp3">Your browser does not support the audio element.
{% endif %}
</audio>
<div class="popup">
<div class="notice">
<h4>温馨提示</h4>
<hr>
<p>EndofYear 使用互联网上公开的 RSS 数据源,并使用自建的 Umami 服务统计访问量,绝对不会主动获取个人隐私信息。🫣🫣🫣
<br>
<br>
开启方式:小手轻轻点 ~
<a href="https://github.com/7Wate/EndOfYear"></a>
</p>
</div>
<div class="selection">
<button value="true" class="allow">开启音乐</button>
<button value="false" class="deny">静音进入</button>
</div>
</div>
</div>
<div class="container animate__animated animate__fadeIn animate__slow" id="tab2"> <div class="container animate__animated animate__fadeIn animate__slow" id="tab2">
<div class="tab2-box"> <div class="tab2-box">
<p class="animate__animated animate__fadeIn animate__delay-1s">亲爱的{{ data.blog_name }}</p> <p class="animate__animated animate__fadeIn animate__delay-1s">亲爱的{{ data.blog_name }}</p>
@ -70,11 +97,14 @@
</div> </div>
<script> <script>
// 屏幕尺寸
console.log("Window inner size: ", window.innerWidth, "x", window.innerHeight); console.log("Window inner size: ", window.innerWidth, "x", window.innerHeight);
console.log("Window outer size: ", window.outerWidth, "x", window.outerHeight); console.log("Window outer size: ", window.outerWidth, "x", window.outerHeight);
console.log("Screen size: ", screen.width, "x", screen.height); console.log("Screen size: ", screen.width, "x", screen.height);
console.log("Screen available size: ", screen.availWidth, "x", screen.availHeight); console.log("Screen available size: ", screen.availWidth, "x", screen.availHeight);
var carousel = {
// 轮播切换
let carousel = {
currentIndex: 0, currentIndex: 0,
tabs: [], tabs: [],
@ -98,6 +128,24 @@
window.onload = function () { window.onload = function () {
carousel.init(); carousel.init();
}; };
// 弹出提示
let popup = document.querySelector('.popup');
let allowButton = document.querySelector('.allow');
let denyButton = document.querySelector('.deny');
let audioElement = document.getElementById('bgm');
allowButton.addEventListener('click', function (event) {
event.stopPropagation();
audioElement.play(); // 播放音乐
popup.style.display = 'none'; // 隐藏弹出窗口
});
denyButton.addEventListener('click', function (event) {
event.stopPropagation();
audioElement.pause();
popup.style.display = 'none'; // 隐藏弹出窗口
});
</script> </script>
</body> </body>