新增:安全链接中转页

This commit is contained in:
j m 2024-04-06 17:30:35 +08:00
parent be72942528
commit a379039ed1
9 changed files with 260 additions and 12 deletions

View File

@ -1397,6 +1397,45 @@ spec:
label: 开启 label: 开启
- value: false - value: false
label: 关闭 label: 关闭
- group: security_link_config
label: '安全链接'
formSchema:
- $formkit: radio
name: enable_security_link
id: enable_security_link
label: 开启 安全链接页面
value: false
help: '开启安全链接页面前,请先使用’安全链接页面模版‘创建页面。'
options:
- value: true
label: 开启
- value: false
label: 关闭
- $formkit: attachment
name: security_link_site_img
if: $get(enable_security_link).value
label: 安全链接页面-站点图标
placeholder: '请输入/选择安全链接页面站点的图标'
help: '请输入/选择安全链接页面站点的图标留空使用站点的favicon。'
- $formkit: text
name: security_link_url
label: 安全链接页面-URL
if: $get(enable_security_link).value
validation: required
placeholder: '请输入使用’安全链接页面模版‘创建的页面访问路径'
help: '输入使用’安全链接页面模版‘创建的页面访问路径,不能省略’/‘。'
- $formkit: attachment
name: security_link_tip_img
if: $get(enable_security_link).value
label: 安全链接页面-提示区域图标
placeholder: '请输入/选择安全链接页面提示区域的图标'
help: '输入/选择安全链接页面提示区域的图标,留空使用默认图标。'
- $formkit: text
name: security_link_tip_desc
if: $get(enable_security_link).value
label: 安全链接页面-提示区域文本描述
placeholder: '请输入安全链接页面提示区域的文本描述'
help: '输入安全链接页面提示区域的文本描述,留空使用默认文本描述。'
- group: custom - group: custom
label: '定制主题' label: '定制主题'
formSchema: formSchema:

133
src/css/security-link.less Normal file
View File

@ -0,0 +1,133 @@
@charset "utf-8";
// 移动设备最大宽度
@mobile-max-width: 768px;
// 平板最小宽度
@table-min-width: 769px;
// 笔记本电脑最小宽度
@laptop-min-width: 1024px;
// 桌面设备最小宽度
@desktop-min-width: 1216px;
// 显示器最小宽度
@display-min-width: 1700px;
// 宽屏设备最小宽度
@widescreen-min-width: 2200px;
html {
background-color: var(--bg-f);
color: var(--main);
font-family: "Dream Font", serif;
body {
width: 100%;
height: 100%;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
position: absolute;
@media (max-width: (@mobile-max-width - 1)) {
.content {
max-width: 90% !important;
min-width: auto !important;
}
}
.content {
max-width: 500px;
min-width: 360px;
margin-bottom: 10%;
&-title {
padding: 24px;
align-items: center;
display: flex;
justify-content: center;
img {
height: 3rem;
width: auto;
}
span {
font-size: 1.5rem;
margin-left: 10px;
font-weight: bold;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
.others {
padding: 24px;
border-radius: 15px;
border: var(--theme) solid 1px;
background-color: var(--background);
&-tip {
display: flex;
padding: 20px;
background-color: var(--theme);
align-items: center;
border-radius: 10px;
img {
height: 2rem;
width: 2rem;
}
span {
margin-left: 10px;
color: #fafafa;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
}
&-topic {
margin-top: 20px;
word-break: break-all;
span {
}
.site-title {
color: var(--theme);
}
a {
color: var(--theme);
}
}
&-end {
justify-content: flex-end;
margin-top: 20px;
display: flex;
a {
border-radius: 2rem;
width: 4rem;
padding: 5px;
text-align: center;
color: var(--theme);
border: var(--theme) solid 1px;
text-decoration: none;
}
}
}
}
}
}

View File

@ -288,7 +288,7 @@ const commonContext = {
let timer = null let timer = null
document.addEventListener('visibilitychange', function () { document.addEventListener('visibilitychange', function () {
if (document.hidden) { if (document.hidden) {
if(!DreamConfig.document_visible_title || document.title !== DreamConfig.document_visible_title) { if (!DreamConfig.document_visible_title || document.title !== DreamConfig.document_visible_title) {
originTitle = document.title originTitle = document.title
} }
DreamConfig.document_hidden_title && (document.title = DreamConfig.document_hidden_title) DreamConfig.document_hidden_title && (document.title = DreamConfig.document_hidden_title)
@ -296,7 +296,7 @@ const commonContext = {
} else { } else {
document.title = DreamConfig.document_visible_title || originTitle document.title = DreamConfig.document_visible_title || originTitle
DreamConfig.document_visible_title && (timer = setTimeout(function () { DreamConfig.document_visible_title && (timer = setTimeout(function () {
if(document.title === DreamConfig.document_visible_title){ if (document.title === DreamConfig.document_visible_title) {
document.title = originTitle document.title = originTitle
} }
}, 2000)) }, 2000))
@ -424,19 +424,19 @@ const commonContext = {
let nowYear = now.getFullYear() let nowYear = now.getFullYear()
const grt = new Date(DreamConfig.website_time) const grt = new Date(DreamConfig.website_time)
let getYear = grt.getFullYear() let getYear = grt.getFullYear()
if(nowYear === getYear) { if (nowYear === getYear) {
webCopyright.innerText = '© '+nowYear+' '+ DreamConfig.site_title webCopyright.innerText = '© ' + nowYear + ' ' + DreamConfig.site_title
return return
} }
webCopyright.innerText = '© '+getYear + '-'+nowYear+' '+ DreamConfig.site_title webCopyright.innerText = '© ' + getYear + '-' + nowYear + ' ' + DreamConfig.site_title
}, },
/* 激活侧边栏人生倒计时 */ /* 激活侧边栏人生倒计时 */
initTimeCount() { initTimeCount() {
if (!$('.timelife').length) { if (!$('.timelife').length) {
return return
} }
if(timeLifeHour === new Date().getHours()) { if (timeLifeHour === new Date().getHours()) {
return return
} }
let timelife = [ let timelife = [
@ -523,15 +523,47 @@ const commonContext = {
}) })
$('.aside-timelife').html(htmlStr) $('.aside-timelife').html(htmlStr)
}, },
/* 安全链接 */
initSecurityLink() {
if (!DreamConfig.enable_security_link || !DreamConfig.security_link_url || DreamConfig.security_link_url.length === 0) {
return
}
$(document).on('click', 'a[target=_blank]', (event) => {
event.preventDefault() // 防止链接默认行为,即打开新页面
var href = $(event.currentTarget).attr('href')
var hostname = window.location.hostname
const isInternalLink = (url, siteDomain) => {
// 将URL和站点域名转换为小写去除前导和尾随空格
url = url.toLowerCase().trim()
siteDomain = siteDomain.toLowerCase().trim()
// 如果URL是协议相对路径或者绝对路径则转换为完整的URL
if (url.startsWith('//')) {
url = window.location.protocol + url
} else if (url.startsWith('/')) {
url = window.location.origin + url
}
// 如果URL以'http://'或'https://'开头,则去除尾部斜杠
if (url.startsWith('http://') || url.startsWith('https://')) {
url = url.replace(/\/$/, '')
}
// 对比URL和站点域名
return url.includes(siteDomain)
}
var tempwindow = window.open('_blank')
tempwindow.location = isInternalLink(href, hostname) ? href : (DreamConfig.security_link_url + '?target=' + encodeURIComponent(href))
})
},
/* 灰色模式 */ /* 灰色模式 */
initGrayMode() { initGrayMode() {
if(DreamConfig.gray_mode === true) { if (DreamConfig.gray_mode === true) {
$('html').addClass('gray-mode') $('html').addClass('gray-mode')
} else if(DreamConfig.gray_mode === 'custom') { } else if (DreamConfig.gray_mode === 'custom') {
var now = new Date().getTime() var now = new Date().getTime()
var startTime = new Date(DreamConfig.gray_mode_start_time).getTime() var startTime = new Date(DreamConfig.gray_mode_start_time).getTime()
var endTime = new Date(DreamConfig.gray_mode_end_time).getTime() var endTime = new Date(DreamConfig.gray_mode_end_time).getTime()
if(now >= startTime && now <= endTime) { if (now >= startTime && now <= endTime) {
$('html').addClass('gray-mode') $('html').addClass('gray-mode')
} }
} }
@ -566,7 +598,7 @@ const commonContext = {
}, },
/* 显示主题版本信息 */ /* 显示主题版本信息 */
showThemeVersion() { showThemeVersion() {
if(!DreamConfig.enable_console_version_info) { if (!DreamConfig.enable_console_version_info) {
return return
} }
window.logger(`%c页面加载耗时${Math.round(performance.now())}ms | Theme By Dream2 Plus ${DreamConfig.theme_version}`, window.logger(`%c页面加载耗时${Math.round(performance.now())}ms | Theme By Dream2 Plus ${DreamConfig.theme_version}`,

View File

@ -0,0 +1 @@
@charset "utf-8";html{background-color:var(--bg-f);color:var(--main);font-family:"Dream Font",serif}html body{width:100%;height:100%;overflow:hidden;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;position:absolute}@media (max-width:767px){html body .content{max-width:90%!important;min-width:auto!important}}html body .content{max-width:500px;min-width:360px;margin-bottom:10%}html body .content-title{padding:24px;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}html body .content-title img{height:3rem;width:auto}html body .content-title span{font-size:1.5rem;margin-left:10px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}html body .content .others{padding:24px;border-radius:15px;border:var(--theme) solid 1px;background-color:var(--background)}html body .content .others-tip,html body .content-title{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}html body .content .others-tip{padding:20px;background-color:var(--theme);border-radius:10px}html body .content .others-tip img{height:2rem;width:2rem}html body .content .others-tip span{margin-left:10px;color:#fafafa;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}html body .content .others-topic{margin-top:20px;word-break:break-all}html body .content .others-topic .site-title,html body .content .others-topic a{color:var(--theme)}html body .content .others-end{-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end;margin-top:20px;display:-webkit-box;display:-ms-flexbox;display:flex}html body .content .others-end a{border-radius:2rem;width:4rem;padding:5px;text-align:center;color:var(--theme);border:var(--theme) solid 1px;text-decoration:none}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -11,4 +11,4 @@
</div> </div>
<div class="progress-percentage">${e.percent}</div> <div class="progress-percentage">${e.percent}</div>
</div> </div>
</div>`}),$(".aside-timelife").html(n)}},initGrayMode(){var e,t,n;(!0===DreamConfig.gray_mode||"custom"===DreamConfig.gray_mode&&(e=(new Date).getTime(),t=new Date(DreamConfig.gray_mode_start_time).getTime(),n=new Date(DreamConfig.gray_mode_end_time).getTime(),t<=e)&&e<=n)&&$("html").addClass("gray-mode")},initEffects(){Utils.isMobile()||(DreamConfig.cursor_move&&Utils.cachedScript(`${DreamConfig.theme_base}/js/cursor/move/${DreamConfig.cursor_move}.min.js?mew=`+DreamConfig.theme_version),DreamConfig.cursor_click&&Utils.cachedScript(`${DreamConfig.theme_base}/js/cursor/click/${DreamConfig.cursor_click}.min.js?mew=`+DreamConfig.theme_version),DreamConfig.enable_live2d&&Utils.cachedScript(DreamConfig.theme_base+"/js/autoload.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_lantern_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/lantern.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_sakura_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/sakura.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_snowflake_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/snowflake.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_universe_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/universe.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_circle_magic_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/circleMagic.min.js?mew="+DreamConfig.theme_version))},initTagCloud(){$(".tagcloud").length&&DreamConfig.show_tagcloud_style&&tagcloud({selector:".tagcloud .card-content",fontsize:18,radius:75,mspeed:"slow",ispeed:"slow",direction:45,keep:!1})},showThemeVersion(){DreamConfig.enable_console_version_info&&window.logger(`%c${Math.round(performance.now())}ms | Theme By Dream2 Plus `+DreamConfig.theme_version,"color:#fff; background: linear-gradient(270deg, #986fee, #8695e6, #68b7dd, #18d7d3); padding: 8px 15px; border-radius: 0 15px 0 15px")}};window.commonContext=t;let o=-1;{const n=["initCarousel","sparkInput","websiteTime"],i=["initEffects","showThemeVersion"];Object.keys(t).forEach(e=>!n.includes(e)&&!i.includes(e)&&t[e]()),document.addEventListener("DOMContentLoaded",function(){$("html").addClass("loaded"),n.forEach(e=>t[e]&&t[e]())}),window.addEventListener("load",function(){i.forEach(e=>t[e]&&t[e]()),$("html").addClass("ready")})}})(); </div>`}),$(".aside-timelife").html(n)}},initSecurityLink(){DreamConfig.enable_security_link&&DreamConfig.security_link_url&&0!==DreamConfig.security_link_url.length&&$(document).on("click","a[target=_blank]",e=>{e.preventDefault();var t,e=$(e.currentTarget).attr("href"),n=window.location.hostname;window.open("_blank").location=(n=n,t=(t=e).toLowerCase().trim(),n=n.toLowerCase().trim(),t.startsWith("//")?t=window.location.protocol+t:t.startsWith("/")&&(t=window.location.origin+t),(t=t.startsWith("http://")||t.startsWith("https://")?t.replace(/\/$/,""):t).includes(n)?e:DreamConfig.security_link_url+"?target="+encodeURIComponent(e))})},initGrayMode(){var e,t,n;(!0===DreamConfig.gray_mode||"custom"===DreamConfig.gray_mode&&(e=(new Date).getTime(),t=new Date(DreamConfig.gray_mode_start_time).getTime(),n=new Date(DreamConfig.gray_mode_end_time).getTime(),t<=e)&&e<=n)&&$("html").addClass("gray-mode")},initEffects(){Utils.isMobile()||(DreamConfig.cursor_move&&Utils.cachedScript(`${DreamConfig.theme_base}/js/cursor/move/${DreamConfig.cursor_move}.min.js?mew=`+DreamConfig.theme_version),DreamConfig.cursor_click&&Utils.cachedScript(`${DreamConfig.theme_base}/js/cursor/click/${DreamConfig.cursor_click}.min.js?mew=`+DreamConfig.theme_version),DreamConfig.enable_live2d&&Utils.cachedScript(DreamConfig.theme_base+"/js/autoload.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_lantern_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/lantern.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_sakura_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/sakura.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_snowflake_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/snowflake.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_universe_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/universe.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_circle_magic_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/circleMagic.min.js?mew="+DreamConfig.theme_version))},initTagCloud(){$(".tagcloud").length&&DreamConfig.show_tagcloud_style&&tagcloud({selector:".tagcloud .card-content",fontsize:18,radius:75,mspeed:"slow",ispeed:"slow",direction:45,keep:!1})},showThemeVersion(){DreamConfig.enable_console_version_info&&window.logger(`%c页面加载耗时${Math.round(performance.now())}ms | Theme By Dream2 Plus `+DreamConfig.theme_version,"color:#fff; background: linear-gradient(270deg, #986fee, #8695e6, #68b7dd, #18d7d3); padding: 8px 15px; border-radius: 0 15px 0 15px")}};window.commonContext=t;let o=-1;{const n=["initCarousel","sparkInput","websiteTime"],i=["initEffects","showThemeVersion"];Object.keys(t).forEach(e=>!n.includes(e)&&!i.includes(e)&&t[e]()),document.addEventListener("DOMContentLoaded",function(){$("html").addClass("loaded"),n.forEach(e=>t[e]&&t[e]())}),window.addEventListener("load",function(){i.forEach(e=>t[e]&&t[e]()),$("html").addClass("ready")})}})();

View File

@ -104,6 +104,9 @@
DreamConfig["show_tagcloud_style"] = [[${theme.config.sidebar.show_tagcloud_style}]]; DreamConfig["show_tagcloud_style"] = [[${theme.config.sidebar.show_tagcloud_style}]];
/** 控制台主题信息 */ /** 控制台主题信息 */
DreamConfig["enable_console_version_info"] = [[${theme.config.enhance.enable_console_version_info}]]; DreamConfig["enable_console_version_info"] = [[${theme.config.enhance.enable_console_version_info}]];
/** 安全链接配置 */
DreamConfig["enable_security_link"] = [[${theme.config.security_link_config.enable_security_link}]];
DreamConfig["security_link_url"] = [[${theme.config.security_link_config.security_link_url}]];
DreamConfig["theme_version"] = [[${theme.spec.version}]]; DreamConfig["theme_version"] = [[${theme.spec.version}]];
DreamConfig["theme_base"] = "[(${#theme.assets('/')})]"; DreamConfig["theme_base"] = "[(${#theme.assets('/')})]";

View File

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="https://www.thymeleaf.org"
th:class="${theme.config.basic_style.theme_style}"
th:with="urlCode = ${param.target},
url = ${#uris.unescapePath(urlCode)}">
<head>
<meta charset="utf-8"/>
<title th:text="${singlePage.spec.title + ' - ' + site.title + (#strings.isEmpty(site.subtitle) ? '' : '|' + site.subtitle)}"></title>
<link rel="preload stylesheet" as="style" th:href="@{/assets/css/theme.min.css(mew=${theme.spec.version})}">
<link data-pjax rel="preload stylesheet" as="style" th:href="@{/assets/css/security-link.min.css(mew=${theme.spec.version})}"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<th:block th:replace="~{common/config}"/>
</head>
<body>
<div class="content">
<div class="content-title">
<img th:src="${#strings.isEmpty(theme.config.security_link_config.security_link_site_img) ? site.favicon : theme.config.security_link_config.security_link_site_img}" alt="favicon">
<span th:title="${site.title}">[[${site.title}]]</span>
</div>
<div class="others">
<div class="others-tip">
<img th:src="${#strings.isEmpty(theme.config.security_link_config.security_link_tip_img) ? #theme.assets('/img/warning.webp') : theme.config.security_link_config.security_link_tip_img}" alt="">
<span>[[${#strings.isEmpty(theme.config.security_link_config.security_link_tip_desc) ? '请注意您的账号和财产安全!': theme.config.security_link_config.security_link_tip_desc}]]</span>
</div>
<div class="others-topic">
<span>您即将离开</span><span class="site-title">[[${site.title}]]</span><span>,去往:</span><a class="loading-color2">[[${url}]]</a>
</div>
<div class="others-end">
<a th:href="${url}" target="_self">继续</a>
</div>
</div>
</div>
</body>
</html>

View File

@ -11,6 +11,12 @@ spec:
name: 智识家 name: 智识家
# 作者网址 # 作者网址
website: https://www.sw0.top website: https://www.sw0.top
customTemplates:
page:
- name: 安全链接页面模版
description: 支持安全链接页面配置
screenshot:
file: security_link.html
# 主题描述 # 主题描述
description: '梦之城,童话梦境' description: '梦之城,童话梦境'
# 主题logo地址 # 主题logo地址
@ -22,6 +28,6 @@ spec:
settingName: theme-dream-setting settingName: theme-dream-setting
configMapName: theme-dream-configMap configMapName: theme-dream-configMap
# 版本号 # 版本号
version: 1.0.4 version: 1.0.4.50
# 最低支持的 Halo 版本 # 最低支持的 Halo 版本
require: ">=2.6.0" require: ">=2.6.0"