mirror of
https://ghfast.top/https://github.com/zsjy/halo-theme-dream2.0-plus.git
synced 2025-03-15 14:19:52 +08:00
增强安全链接拦截范围
This commit is contained in:
parent
9af8051600
commit
f414c4ce0b
@ -559,11 +559,14 @@ const commonContext = {
|
||||
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() // 防止链接默认行为,即打开新页面
|
||||
$(document).on('click', 'a', (event) => {
|
||||
var href = $(event.currentTarget).attr('href')
|
||||
var hostname = window.location.hostname
|
||||
|
||||
// 判断是否为下载链接
|
||||
const isDownloadLink = (url) => {
|
||||
const downloadExtensions = ['.pdf', '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.zip', '.rar', '.7z', '.tar', '.gz', '.bz2', '.dmg', '.exe', '.msi', '.iso', '.apk']
|
||||
return downloadExtensions.some(ext => url.toLowerCase().endsWith(ext))
|
||||
}
|
||||
const isInternalLink = (url, siteDomain) => {
|
||||
// 将URL和站点域名转换为小写,去除前导和尾随空格
|
||||
url = url.toLowerCase().trim()
|
||||
@ -581,9 +584,14 @@ const commonContext = {
|
||||
// 对比URL和站点域名
|
||||
return url.includes(siteDomain)
|
||||
}
|
||||
|
||||
var tempwindow = window.open('_blank')
|
||||
tempwindow.location = isInternalLink(href, hostname) ? href : (DreamConfig.security_link_url + '?target=' + encodeURIComponent(href))
|
||||
if (isDownloadLink(href)) {
|
||||
event.preventDefault()
|
||||
// 如果是下载链接,直接跳转
|
||||
window.open(href, '_blank')
|
||||
} else if (!isInternalLink(href, hostname)) {
|
||||
event.preventDefault()
|
||||
window.open((DreamConfig.security_link_url + '?target=' + encodeURIComponent(href)), '_blank')
|
||||
}
|
||||
})
|
||||
},
|
||||
/* 灰色模式 */
|
||||
|
4
templates/assets/js/common.min.js
vendored
4
templates/assets/js/common.min.js
vendored
File diff suppressed because one or more lines are too long
@ -80,9 +80,7 @@
|
||||
for (let time of custom_gray_mode_time_list) {
|
||||
let type = time.realNode.time_span;
|
||||
let desc = time.realNode.time_span_desc;
|
||||
if (gray_mode_time_list.indexOf(type) === -1) {
|
||||
gray_mode_time_list.push({time: type, desc: desc});
|
||||
}
|
||||
gray_mode_time_list.push({time: type, desc: desc});
|
||||
}
|
||||
}
|
||||
DreamConfig["gray_mode_time_list"] = gray_mode_time_list;
|
||||
|
@ -110,7 +110,7 @@
|
||||
}
|
||||
|
||||
.loading {
|
||||
animation: fadein 0.6s ease-out;
|
||||
animation: fadein 0.3s ease-out;
|
||||
}
|
||||
|
||||
html.light .others-topic,
|
||||
@ -161,7 +161,7 @@
|
||||
text-align: center;
|
||||
padding: 35px;
|
||||
border-radius: 24px;
|
||||
animation: fadein 0.6s ease-out;
|
||||
animation: fadein 0.3s ease-out;
|
||||
width: 400px;
|
||||
max-width: 90%;
|
||||
border: 2px solid rgba(255, 255, 255, 0.4);
|
||||
|
@ -30,7 +30,7 @@ spec:
|
||||
settingName: theme-dream2-plus-setting
|
||||
configMapName: theme-dream2-plus-configMap
|
||||
# 版本号
|
||||
version: 1.4.2.beta1
|
||||
version: 1.4.2.beta2
|
||||
# 最低支持的 Halo 版本
|
||||
require: ">=2.20.0"
|
||||
# 许可
|
||||
|
Loading…
x
Reference in New Issue
Block a user