diff --git a/settings.yaml b/settings.yaml index 81df286..5658464 100644 --- a/settings.yaml +++ b/settings.yaml @@ -1397,6 +1397,45 @@ spec: label: 开启 - value: false 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 label: '定制主题' formSchema: diff --git a/src/css/security-link.less b/src/css/security-link.less new file mode 100644 index 0000000..4471617 --- /dev/null +++ b/src/css/security-link.less @@ -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; + } + + } + + } + + } + + + } +} \ No newline at end of file diff --git a/src/js/common.js b/src/js/common.js index 22a5b46..01d0528 100644 --- a/src/js/common.js +++ b/src/js/common.js @@ -288,7 +288,7 @@ const commonContext = { let timer = null document.addEventListener('visibilitychange', function () { 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 } DreamConfig.document_hidden_title && (document.title = DreamConfig.document_hidden_title) @@ -296,7 +296,7 @@ const commonContext = { } else { document.title = DreamConfig.document_visible_title || originTitle DreamConfig.document_visible_title && (timer = setTimeout(function () { - if(document.title === DreamConfig.document_visible_title){ + if (document.title === DreamConfig.document_visible_title) { document.title = originTitle } }, 2000)) @@ -424,19 +424,19 @@ const commonContext = { let nowYear = now.getFullYear() const grt = new Date(DreamConfig.website_time) let getYear = grt.getFullYear() - if(nowYear === getYear) { - webCopyright.innerText = '© '+nowYear+' '+ DreamConfig.site_title + if (nowYear === getYear) { + webCopyright.innerText = '© ' + nowYear + ' ' + DreamConfig.site_title return } - webCopyright.innerText = '© '+getYear + '-'+nowYear+' '+ DreamConfig.site_title + webCopyright.innerText = '© ' + getYear + '-' + nowYear + ' ' + DreamConfig.site_title }, /* 激活侧边栏人生倒计时 */ initTimeCount() { if (!$('.timelife').length) { return } - if(timeLifeHour === new Date().getHours()) { + if (timeLifeHour === new Date().getHours()) { return } let timelife = [ @@ -523,15 +523,47 @@ const commonContext = { }) $('.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() { - if(DreamConfig.gray_mode === true) { + if (DreamConfig.gray_mode === true) { $('html').addClass('gray-mode') - } else if(DreamConfig.gray_mode === 'custom') { + } else if (DreamConfig.gray_mode === 'custom') { var now = new Date().getTime() var startTime = new Date(DreamConfig.gray_mode_start_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') } } @@ -566,7 +598,7 @@ const commonContext = { }, /* 显示主题版本信息 */ showThemeVersion() { - if(!DreamConfig.enable_console_version_info) { + if (!DreamConfig.enable_console_version_info) { return } window.logger(`%c页面加载耗时:${Math.round(performance.now())}ms | Theme By Dream2 Plus ${DreamConfig.theme_version}`, diff --git a/templates/assets/css/security-link.min.css b/templates/assets/css/security-link.min.css new file mode 100644 index 0000000..d2afe84 --- /dev/null +++ b/templates/assets/css/security-link.min.css @@ -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} \ No newline at end of file diff --git a/templates/assets/img/warning.webp b/templates/assets/img/warning.webp new file mode 100644 index 0000000..b3988b7 Binary files /dev/null and b/templates/assets/img/warning.webp differ diff --git a/templates/assets/js/common.min.js b/templates/assets/js/common.min.js index 6e38c1a..3519d34 100644 --- a/templates/assets/js/common.min.js +++ b/templates/assets/js/common.min.js @@ -11,4 +11,4 @@