Merge pull request #61 from fishcpy/descriptive

为友链描述信息添加新来源
This commit is contained in:
宏尘 2025-03-12 20:39:57 +08:00 committed by GitHub
commit 730e0e16f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 180 additions and 2 deletions

View File

@ -951,6 +951,11 @@ spec:
label: 友链页面-RSS订阅地址
placeholder: '请输入RSS订阅地址'
help: '用于交换友链时添加朋友圈的RSS订阅地址。'
- $formkit: text
name: links_descriptive
label: 友链页面-自定义描述
placeholder: '请输入描述'
help: '用于交换友链时添加的描述(留空使用用户信息)。'
- $formkit: code
name: links_info
label: "友链页面-补充信息"
@ -1213,6 +1218,8 @@ spec:
label: 小火车
- value: 'error/common/error_concise'
label: 简洁
- value: 'error/common/error_travellings'
label: 智能归航
- value: 'error/common/error_default'
label: 默认
- value: 'error/common/error_custom'
@ -1239,6 +1246,8 @@ spec:
label: 小火车
- value: 'error/common/error_concise'
label: 简洁
- value: 'error/common/error_travellings'
label: 智能归航
- value: 'error/common/error_default'
label: 默认
- value: 'error/common/error_custom'

View File

@ -0,0 +1,168 @@
<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="https://www.thymeleaf.org"
th:fragment="error_fragment">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>[[${error.status + ' - ' + #strings.defaultString(error.title, 'Internal server error')}]]</title>
<link rel="icon" th:href="${site.favicon}">
<style>
* {
color: #111827;
}
a {
text-decoration: none;
}
body {
transition: background-color 0.5s;
}
@media (prefers-color-scheme: dark) {
* {
color: #f9fafb;
}
body {
background: #111111;
}
}
.blink {
position: fixed;
height: 100%;
width: 100%;
text-align: center;
display: flex;
display: -webkit-flex;
align-items: center;
justify-content: center;
animation: blink 4s linear infinite;
-webkit-animation: blink 4s linear infinite;
-moz-animation: blink 4s linear infinite;
-ms-animation: blink 4s linear infinite;
-o-animation: blink 4s linear infinite;
}
@keyframes blink {
0% {
opacity: 0;
transform: scale(1);
}
40% {
opacity: 0.3;
transform: scale(1);
}
80% {
opacity: 1;
transform: scale(0.98);
}
100% {
opacity: 0.2;
transform: scale(1.2);
}
}
.botCenter {
position: fixed;
width: 100%;
height: 50px;
bottom: 10px;
line-height: 20px;
font-size: 12px;
text-align: center;
animation: botCenter 3s linear;
}
@keyframes botCenter {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.links {
--link-color: #5372b4;
color: var(--link-color);
}
.links:hover {
border-bottom: 2px solid var(--link-color);
}
@media (prefers-color-scheme: dark) {
.links {
--link-color: #9ca3af;
}
}
.loading-bar {
width: 200px;
height: 10px;
background-color: #ddd;
margin: 20px auto;
border-radius: 5px;
overflow: hidden;
}
.loading-bar-inner {
width: 0;
height: 100%;
background-color: #007bff;
border-radius: 5px;
animation: fillBar 2s ease-in-out forwards;
}
@keyframes fillBar {
0% {
width: 0;
}
100% {
width: 100%;
}
}
</style>
</head>
<body>
<div class="blink">
<div>
<h1>[[${error.status + ' ' + #strings.defaultString(error.title, 'Internal server error')}]]</h1>
<p th:if="${error.status >= 500 && error.status < 600}">围观群众太过热情,服务器繁忙,请稍后访问。</p>
<p th:if="${error.status >= 400 && error.status < 500}">抱歉,您请求的页面不存在。</p>
<p th:if="${error.status >= 400 && error.status < 500}">可能是输入的网址有误,或者该页面已被移动或删除。</p>
<a th:if="${error.status >= 400 && error.status < 500}" href="/" class="back-link">手动返回首页</a></p>
<div th:if="${error.status >= 400 && error.status < 500}" class="loading-bar">
<div class="loading-bar-inner"></div>
</div>
</div>
</div>
<script th:inline="javascript">
const websites = [
"/"
];
function redirectToRandomWebsite() {
// 获取错误状态码(通过解析标题文本)
const errorCode = [[${error.status}]];
// 仅当 400 <= 错误码 < 500 时执行跳转
if (errorCode >= 400 && errorCode < 500) {
const randomIndex = Math.floor(Math.random() * websites.length);
const randomWebsite = websites[randomIndex];
setTimeout(() => {
window.location.href = randomWebsite;
}, 4000);
}
}
window.onload = redirectToRandomWebsite;
</script>
</body>
</html>

View File

@ -33,13 +33,14 @@
</th:block>
<hr th:if="${theme.config.page_config.show_exchange_info || !#strings.isEmpty(theme.config.page_config.links_info)}"/>
<th:block th:if="${theme.config.page_config.show_exchange_info}"
th:with="bloggerAvatar= ${#strings.defaultString(theme.config.page_config.links_blogger_avatar, contributor.avatar)}">
th:with="bloggerAvatar= ${#strings.defaultString(theme.config.page_config.links_blogger_avatar, contributor.avatar)},
descriptive= ${#strings.defaultString(theme.config.page_config.links_descriptive, contributor.bio)}">
<p style="margin-bottom: 4px">申请友链的方法:</p>
<ul>
<li>名称:[[${site.title}]]</li>
<li>地址:<a th:href="${site.url}" target="_blank" th:text="${site.url}"></a></li>
<li>图标:<a th:href="${bloggerAvatar}" target="_blank" th:text="${bloggerAvatar}"></a></li>
<li>描述:[[${contributor.bio}]]</li>
<li>描述:[[${descriptive}]]</li>
<li th:if="${!#strings.isEmpty(theme.config.page_config.links_rss_address)}">订阅:<a th:href="${theme.config.page_config.links_rss_address}" target="_blank" th:text="${theme.config.page_config.links_rss_address}"></a></li>
</ul>
</th:block>