添加友链页面描述信息来源

This commit is contained in:
fishcpy 2025-03-12 18:23:32 +08:00
parent 9270dfe326
commit effa4a5ae8
3 changed files with 22 additions and 32 deletions

View File

@ -951,24 +951,9 @@ spec:
label: 友链页面-RSS订阅地址
placeholder: '请输入RSS订阅地址'
help: '用于交换友链时添加朋友圈的RSS订阅地址。'
- $formkit: radio
name: use_user_bio
label: 友链页面-描述来源
value: true
options:
- value: true
label: 使用用户信息
- value: false
label: 单独提供
- $formkit: text
name: links_descriptive
label: 友链页面-自定义描述
placeholder: '请输入描述'
help: '用于交换友链时添加的描述。'
if: $get(use_user_bio).value == false
- $formkit: text
name: links_descriptive
label: 友链页面-描述(仅在选择单独提供时可用)
label: 友链页面-自定义描述(留空使用用户信息)
placeholder: '请输入描述'
help: '用于交换友链时添加的描述。'
- $formkit: code
@ -1234,7 +1219,7 @@ spec:
- value: 'error/common/error_concise'
label: 简洁
- value: 'error/common/error_travellings'
label: 类似开往页面
label: 智能归航
- value: 'error/common/error_default'
label: 默认
- value: 'error/common/error_custom'
@ -1262,7 +1247,7 @@ spec:
- value: 'error/common/error_concise'
label: 简洁
- value: 'error/common/error_travellings'
label: 类似开往页面
label: 智能归航
- value: 'error/common/error_default'
label: 默认
- value: 'error/common/error_custom'

View File

@ -141,21 +141,26 @@
</div>
</div>
</div>
<div class="botCenter">
本页面基于 <a href="https://github.com/travellings-link/travellings" class="links" target="_blank">开往</a> 制作
</div>
<script>
const websites = [
"/"
// 在此处添加更多友链地址
"/",
"https://example.com"
];
function redirectToRandomWebsite() {
const randomIndex = Math.floor(Math.random() * websites.length);
const randomWebsite = websites[randomIndex];
setTimeout(() => {
window.location.href = randomWebsite;
}, 4000);
// 获取错误状态码(通过解析标题文本)
const errorCode = parseInt(document.querySelector('h1').textContent.split(' ')[0]);
// 仅当 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;

View File

@ -40,11 +40,11 @@
<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 th:if="${theme.config.page_config.use_user_bio}">
描述:<span th:text="${contributor.bio}"></span>
</li>
<li th:unless="${theme.config.page_config.use_user_bio}" th:if="${!#strings.isEmpty(descriptive)}">
描述:<span th:text="${descriptive}"></span>
<li th:with="descriptive = ${#strings.defaultString(theme.config.page_config.links_descriptive, '')}">
<span th:if="${!#strings.isEmpty(descriptive)}">描述:</span>
<span th:if="${!#strings.isEmpty(descriptive)}" th:text="${descriptive}"></span>
<span th:if="${#strings.isEmpty(descriptive)}">描述:</span>
<span th:if="${#strings.isEmpty(descriptive)}" th:text="${contributor.bio}"></span>
</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>