diff --git a/settings.yaml b/settings.yaml index eaedbbd..becbe7a 100644 --- a/settings.yaml +++ b/settings.yaml @@ -1485,6 +1485,20 @@ enhance: https://npm.elemecdn.com placeholder: 请输入 CDN 地址(一行一个) description: '填入可用的 NPM 公共开源 CDN 地址(一行一个),通过 “{CDN 地址}/{项目名}@{版本号}/${文件路径}” 可访问到文件,如:https://unpkg.com/halo-theme-dream@3.2.1/source/js/utils.min.js' + effects_lantern_mode: + name: effects_lantern_mode + label: 喜庆灯笼特效显示模式 + type: radio + default: none + options: + - value: none + label: 不显示 + - value: day + label: 明亮模式 + - value: night + label: 黑暗模式 + - value: all + label: 全模式 effects_sakura_mode: name: effects_sakura_mode label: 樱花飘落特效显示模式 @@ -1499,6 +1513,20 @@ enhance: label: 黑暗模式 - value: all label: 全模式 + effects_snowflake_mode: + name: effects_snowflake_mode + label: 雪花飘落特效显示模式 + type: radio + default: none + options: + - value: none + label: 不显示 + - value: day + label: 明亮模式 + - value: night + label: 黑暗模式 + - value: all + label: 全模式 effects_universe_mode: name: effects_universe_mode label: 宇宙星空特效显示模式 diff --git a/source/js/common.min.js b/source/js/common.min.js index 70e609b..db1d4b8 100644 --- a/source/js/common.min.js +++ b/source/js/common.min.js @@ -1 +1 @@ -(()=>{window.encrypt=e=>window.btoa(unescape(encodeURIComponent(e))),window.decrypt=e=>decodeURIComponent(escape(window.atob(e)));const t={initWidget(){var e=$(".columns .column-right"),t=$(".columns .column-right-shadow");if($(".widget.recent-comments .reply .link").html((e,t)=>Utils.renderedEmojiHtml(t)),e.length&&t.length&&!t[0].children.length)for(const a of e[0].children)t[0].append(a.cloneNode(!0))},initActions(){const a=$(".actions>.bullet-screen");"true"===localStorage.getItem("stop-bullet-screen")&&a.addClass("stop-bullet-screen"),0!==$("halo-comment[bullet-screen]").length&&a.removeClass("is-hidden-all");a.on("click",()=>{var t,e=localStorage.getItem("stop-bullet-screen")||!1;t="true"!==e.toString(),$("halo-comment[bullet-screen]").each(function(){var e=this.shadowRoot.getElementById("halo-comment");t?$(e).attr("stop-bullet-screen","true"):$(e).removeAttr("stop-bullet-screen")}),t?a.addClass("stop-bullet-screen"):a.removeClass("stop-bullet-screen"),localStorage.setItem("stop-bullet-screen",t)})},initTocAndNotice(){var e=location["pathname"],t=(window.tocPjax&&window.tocPjax(),0===$(".widget.toc .card-content ul").length),e="toc"===DreamConfig.notice_show_mode&&!t||"index"===DreamConfig.notice_show_mode&&"/"!==e;t?$(".widget.toc,.action-toc").addClass("is-hidden-all"):$(".widget.toc,.action-toc").removeClass("is-hidden-all"),e?$(".widget.notice").addClass("is-hidden-all"):$(".widget.notice").removeClass("is-hidden-all")},initBanner(){const o=$(".banner-info-desc");if(0!==o.length){const i=o.text();o.text("");let t,a="",n=!0;const s=function(){var e=a.length;n&&e
${this.alt&&DreamConfig.show_img_name?`

${this.alt}

`:""}`)})},initMode(){let e=localStorage.getItem("night")||!1;const t=t=>{t?document.documentElement.classList.add("night"):document.documentElement.classList.remove("night"),$("halo-comment").each(function(){var e=this.shadowRoot.getElementById("halo-comment");$(e)[(t?"add":"remove")+"Class"]("night")}),localStorage.setItem("night",t),e=t};$("#toggle-mode").on("click",()=>t("true"!==e.toString())),"system"===DreamConfig.default_theme&&window.matchMedia("(prefers-color-scheme: dark)").addListener(e=>t(e.matches))},initNavbar(){var t=$(".navbar-nav a"),e=$(".panel-side-menu .link");let a=0;var{href:n,pathname:o}=location;if(o&&"/"!==o)for(let e=0;e$(this).addClass("active"),()=>$(this).removeClass("active")):($(this).on("click",function(e){e.stopPropagation(),$(this).toggleClass("active"),$(document).one("click",()=>$(this).removeClass("active")),e.stopPropagation()}),a.on("click",e=>e.stopPropagation()))})},initScroll(){window.initTop=0,document.addEventListener("scroll",()=>{const e=$(document).scrollTop(),t=(o=e>window.initTop,window.initTop=e,o),a=$("body"),n=$(".actions");var o;50e.preventDefault),$(".navbar .toc-content").on("click",function(e){e.stopPropagation(),$("html").removeClass("disable-scroll"),$(".navbar-mask").removeClass("active slideout"),$(".navbar-slideout").removeClass("active slideout-toc")})},sideMenuMobile(){$(".navbar-slideout-menu .current").parents(".panel-body").show().siblings(".panel").addClass("in"),$(".navbar-slideout-menu .panel").on("click",function(e){e.stopPropagation();var e=$(this),t=e.parent().parent();t.find(".panel").not(e).removeClass("in"),t.find(".panel-body").not(e.siblings(".panel-body")).stop().hide("fast"),e.toggleClass("in").siblings(".panel-body").stop().toggle("fast")})},initEvent(){var e=$("body");function a(e){var e=$(e),t=e.attr("data-close");return t&&""!==t.trim()?e.closest(t.trim()):e}e.on("click",".click-close",function(e){e.stopPropagation(),a(this).remove()}),e.on("click",".click-animation-close",function(e){e.stopPropagation();let t=a(this);t.addClass("close-animation"),setTimeout(()=>t.remove(),300)})},offscreenTip(){if(!Utils.isMobile()&&(DreamConfig.document_hidden_title||DreamConfig.document_visible_title)){const t=document.title;let e=null;document.addEventListener("visibilitychange",function(){document.hidden?(DreamConfig.document_hidden_title&&(document.title=DreamConfig.document_hidden_title),clearTimeout(e)):(document.title=DreamConfig.document_visible_title||t,DreamConfig.document_visible_title&&(e=setTimeout(function(){document.title=t},2e3)))})}},initCarousel(){window.Swiper&&new Swiper(".swiper",{loop:!0,parallax:!0,effect:"slide",spaceBetween:10,speed:600,autoplay:{delay:3e3,disableOnInteraction:!1,pauseOnMouseEnter:!0},pagination:{el:".swiper-pagination",clickable:!0},navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev"}})},sparkInput(){const a=DreamConfig.spark_input_content&&DreamConfig.spark_input_content.filter(e=>0sparkInput(t,a))})},loveTime(){let r=$(".love .love-time");if(0!==r.length){var e=r.attr("data-time");if(/^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}$/.test(e)){const c=new Date,d=new Date(e);setInterval(function(){c.setTime(c.getTime()+1e3);var e=parseInt((c-d)/1e3),t=e%60,a=(e=parseInt(e/60))%60;let n=(e=parseInt(e/60))%24,o=parseInt(e/24),i=0,s=d.getFullYear(),l=c.getFullYear();for(;s${o}天${n}${a}${t}秒`},1e3)}else i.innerText=DreamConfig.website_time}},initEffects(){Utils.isMobile()||(DreamConfig.cursor_move&&Utils.cachedScript(`${DreamConfig.theme_base}/source/js/cursor/move/${DreamConfig.cursor_move}.min.js?mew=`+DreamConfig.theme_version),DreamConfig.cursor_click&&Utils.cachedScript(`${DreamConfig.theme_base}/source/js/cursor/click/${DreamConfig.cursor_click}.min.js?mew=`+DreamConfig.theme_version),DreamConfig.enable_live2d&&Utils.cachedScript(DreamConfig.theme_base+"/source/js/autoload.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_sakura_mode&&Utils.cachedScript(DreamConfig.theme_base+"/source/js/effects/sakura.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_universe_mode&&Utils.cachedScript(DreamConfig.theme_base+"/source/js/effects/universe.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_circle_magic_mode&&Utils.cachedScript(DreamConfig.theme_base+"/source/js/effects/circleMagic.min.js?mew="+DreamConfig.theme_version))},loadMaintain(){DreamConfig.enable_baidu_push&&Utils.baiduPush(),DreamConfig.enable_toutiao_push&&Utils.toutiaoPush()},showThemeVersion(){window.logger(`%c页面加载耗时:${Math.round(performance.now())}ms | Theme By Dream `+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;{const a=["initCarousel","sparkInput","websiteTime"],n=["initEffects","loadMaintain","showThemeVersion"];Object.keys(t).forEach(e=>!a.includes(e)&&!n.includes(e)&&t[e]()),document.addEventListener("DOMContentLoaded",function(){$("html").addClass("loaded"),a.forEach(e=>t[e]&&t[e]())}),window.addEventListener("load",function(){n.forEach(e=>t[e]&&t[e]()),$("html").addClass("ready")})}})(); \ No newline at end of file +(()=>{window.encrypt=e=>window.btoa(unescape(encodeURIComponent(e))),window.decrypt=e=>decodeURIComponent(escape(window.atob(e)));const t={initWidget(){var e=$(".columns .column-right"),t=$(".columns .column-right-shadow");if($(".widget.recent-comments .reply .link").html((e,t)=>Utils.renderedEmojiHtml(t)),e.length&&t.length&&!t[0].children.length)for(const a of e[0].children)t[0].append(a.cloneNode(!0))},initActions(){const a=$(".actions>.bullet-screen");"true"===localStorage.getItem("stop-bullet-screen")&&a.addClass("stop-bullet-screen"),0!==$("halo-comment[bullet-screen]").length&&a.removeClass("is-hidden-all");a.on("click",()=>{var t,e=localStorage.getItem("stop-bullet-screen")||!1;t="true"!==e.toString(),$("halo-comment[bullet-screen]").each(function(){var e=this.shadowRoot.getElementById("halo-comment");t?$(e).attr("stop-bullet-screen","true"):$(e).removeAttr("stop-bullet-screen")}),t?a.addClass("stop-bullet-screen"):a.removeClass("stop-bullet-screen"),localStorage.setItem("stop-bullet-screen",t)})},initTocAndNotice(){var e=location["pathname"],t=(window.tocPjax&&window.tocPjax(),0===$(".widget.toc .card-content ul").length),e="toc"===DreamConfig.notice_show_mode&&!t||"index"===DreamConfig.notice_show_mode&&"/"!==e;t?$(".widget.toc,.action-toc").addClass("is-hidden-all"):$(".widget.toc,.action-toc").removeClass("is-hidden-all"),e?$(".widget.notice").addClass("is-hidden-all"):$(".widget.notice").removeClass("is-hidden-all")},initBanner(){const o=$(".banner-info-desc");if(0!==o.length){const s=o.text();o.text("");let t,a="",n=!0;const i=function(){var e=a.length;n&&e
${this.alt&&DreamConfig.show_img_name?`

${this.alt}

`:""}`)})},initMode(){let e=localStorage.getItem("night")||!1;const t=t=>{t?document.documentElement.classList.add("night"):document.documentElement.classList.remove("night"),$("halo-comment").each(function(){var e=this.shadowRoot.getElementById("halo-comment");$(e)[(t?"add":"remove")+"Class"]("night")}),localStorage.setItem("night",t),e=t};$("#toggle-mode").on("click",()=>t("true"!==e.toString())),"system"===DreamConfig.default_theme&&window.matchMedia("(prefers-color-scheme: dark)").addListener(e=>t(e.matches))},initNavbar(){var t=$(".navbar-nav a"),e=$(".panel-side-menu .link");let a=0;var{href:n,pathname:o}=location;if(o&&"/"!==o)for(let e=0;e$(this).addClass("active"),()=>$(this).removeClass("active")):($(this).on("click",function(e){e.stopPropagation(),$(this).toggleClass("active"),$(document).one("click",()=>$(this).removeClass("active")),e.stopPropagation()}),a.on("click",e=>e.stopPropagation()))})},initScroll(){window.initTop=0,document.addEventListener("scroll",()=>{const e=$(document).scrollTop(),t=(o=e>window.initTop,window.initTop=e,o),a=$("body"),n=$(".actions");var o;50e.preventDefault),$(".navbar .toc-content").on("click",function(e){e.stopPropagation(),$("html").removeClass("disable-scroll"),$(".navbar-mask").removeClass("active slideout"),$(".navbar-slideout").removeClass("active slideout-toc")})},sideMenuMobile(){$(".navbar-slideout-menu .current").parents(".panel-body").show().siblings(".panel").addClass("in"),$(".navbar-slideout-menu .panel").on("click",function(e){e.stopPropagation();var e=$(this),t=e.parent().parent();t.find(".panel").not(e).removeClass("in"),t.find(".panel-body").not(e.siblings(".panel-body")).stop().hide("fast"),e.toggleClass("in").siblings(".panel-body").stop().toggle("fast")})},initEvent(){var e=$("body");function a(e){var e=$(e),t=e.attr("data-close");return t&&""!==t.trim()?e.closest(t.trim()):e}e.on("click",".click-close",function(e){e.stopPropagation(),a(this).remove()}),e.on("click",".click-animation-close",function(e){e.stopPropagation();let t=a(this);t.addClass("close-animation"),setTimeout(()=>t.remove(),300)})},offscreenTip(){if(!Utils.isMobile()&&(DreamConfig.document_hidden_title||DreamConfig.document_visible_title)){const t=document.title;let e=null;document.addEventListener("visibilitychange",function(){document.hidden?(DreamConfig.document_hidden_title&&(document.title=DreamConfig.document_hidden_title),clearTimeout(e)):(document.title=DreamConfig.document_visible_title||t,DreamConfig.document_visible_title&&(e=setTimeout(function(){document.title=t},2e3)))})}},initCarousel(){window.Swiper&&new Swiper(".swiper",{loop:!0,parallax:!0,effect:"slide",spaceBetween:10,speed:600,autoplay:{delay:3e3,disableOnInteraction:!1,pauseOnMouseEnter:!0},pagination:{el:".swiper-pagination",clickable:!0},navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev"}})},sparkInput(){const a=DreamConfig.spark_input_content&&DreamConfig.spark_input_content.filter(e=>0sparkInput(t,a))})},loveTime(){let r=$(".love .love-time");if(0!==r.length){var e=r.attr("data-time");if(/^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}$/.test(e)){const c=new Date,d=new Date(e);setInterval(function(){c.setTime(c.getTime()+1e3);var e=parseInt((c-d)/1e3),t=e%60,a=(e=parseInt(e/60))%60;let n=(e=parseInt(e/60))%24,o=parseInt(e/24),s=0,i=d.getFullYear(),l=c.getFullYear();for(;i${o}天${n}${a}${t}秒`},1e3)}else s.innerText=DreamConfig.website_time}},initEffects(){Utils.isMobile()||(DreamConfig.cursor_move&&Utils.cachedScript(`${DreamConfig.theme_base}/source/js/cursor/move/${DreamConfig.cursor_move}.min.js?mew=`+DreamConfig.theme_version),DreamConfig.cursor_click&&Utils.cachedScript(`${DreamConfig.theme_base}/source/js/cursor/click/${DreamConfig.cursor_click}.min.js?mew=`+DreamConfig.theme_version),DreamConfig.enable_live2d&&Utils.cachedScript(DreamConfig.theme_base+"/source/js/autoload.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_lantern_mode&&Utils.cachedScript(DreamConfig.theme_base+"/source/js/effects/lantern.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_sakura_mode&&Utils.cachedScript(DreamConfig.theme_base+"/source/js/effects/sakura.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_snowflake_mode&&Utils.cachedScript(DreamConfig.theme_base+"/source/js/effects/snowflake.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_universe_mode&&Utils.cachedScript(DreamConfig.theme_base+"/source/js/effects/universe.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_circle_magic_mode&&Utils.cachedScript(DreamConfig.theme_base+"/source/js/effects/circleMagic.min.js?mew="+DreamConfig.theme_version))},loadMaintain(){DreamConfig.enable_baidu_push&&Utils.baiduPush(),DreamConfig.enable_toutiao_push&&Utils.toutiaoPush()},showThemeVersion(){window.logger(`%c页面加载耗时:${Math.round(performance.now())}ms | Theme By Dream `+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;{const a=["initCarousel","sparkInput","websiteTime"],n=["initEffects","loadMaintain","showThemeVersion"];Object.keys(t).forEach(e=>!a.includes(e)&&!n.includes(e)&&t[e]()),document.addEventListener("DOMContentLoaded",function(){$("html").addClass("loaded"),a.forEach(e=>t[e]&&t[e]())}),window.addEventListener("load",function(){n.forEach(e=>t[e]&&t[e]()),$("html").addClass("ready")})}})(); \ No newline at end of file diff --git a/source/js/effects/lantern.min.js b/source/js/effects/lantern.min.js new file mode 100644 index 0000000..acb6ae3 --- /dev/null +++ b/source/js/effects/lantern.min.js @@ -0,0 +1 @@ +(()=>{var r={6224:(t,e,n)=>{var r;void 0!==(n="function"==typeof(r=function(){"use strict";var t,e,n=DreamConfig.effects_lantern_mode;n='@charset "UTF-8";.lantern__warpper{position:fixed;top:12px;left:40px;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;z-index:999}.lantern__warpper.lantern__secondary{left:calc(100% - 130px)}.lantern__warpper.lantern__secondary .lantern__box{-webkit-animation-duration:3s;animation-duration:3s}.lantern__box{position:relative;display:inline-block;width:90px;height:70px;background:rgba(216,0,15,.8);border-radius:50% 50%;animation:lantern-swing 3s ease-in-out infinite alternate-reverse;-webkit-transform-origin:50% -70px;-ms-transform-origin:50% -70px;transform-origin:50% -70px;-webkit-box-shadow:-5px 5px 50px 4px #fa6c00;box-shadow:-5px 5px 50px 4px #fa6c00}.lantern__box:after,.lantern__box:before{content:"";position:absolute;height:8px;width:45px;left:50%;border:1px solid #dc8f03;background:-webkit-gradient(linear,left top,right top,from(#dc8f03),color-stop(orange),color-stop(#dc8f03),color-stop(orange),to(#dc8f03));background:-o-linear-gradient(left,#dc8f03,orange,#dc8f03,orange,#dc8f03);background:linear-gradient(90deg,#dc8f03,orange,#dc8f03,orange,#dc8f03)}.lantern__box:before{top:0;border-radius:5px 5px 0 0;-webkit-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.lantern__box:after{bottom:0;border-radius:0 0 5px 5px;-webkit-transform:translate(-50%,50%);-ms-transform:translate(-50%,50%);transform:translate(-50%,50%)}.lantern__line{position:absolute;width:2px;height:12px;top:0;left:50%;-webkit-transform:translate(-50%,-100%);-ms-transform:translate(-50%,-100%);transform:translate(-50%,-100%);background:#dc8f03}.lantern__circle{width:80%;-webkit-box-sizing:border-box;box-sizing:border-box}.lantern__circle,.lantern__circle .lantern__ellipse{height:100%;margin:0 auto;border-radius:50%;border:2px solid #dc8f03}.lantern__circle .lantern__ellipse{width:50%}.lantern__circle .lantern__text{font-family:华文行楷,Microsoft YaHei,sans-serif;font-size:24.3px;color:#dc8f03;font-weight:700;line-height:66px;text-align:center}.lantern__tail{position:relative;width:4px;height:12px;margin:0 auto;animation:lantern-swing 4s ease-in-out infinite alternate-reverse;background:orange;border-radius:0 0 5px 5px}.lantern__tail .lantern__junction{position:absolute;top:0;left:50%;width:8px;height:8px;-webkit-transform:translate(-50%,8.4px);-ms-transform:translate(-50%,8.4px);transform:translate(-50%,8.4px);background:#e69603;border-radius:50%}.lantern__tail .lantern__rect{position:absolute;top:0;left:50%;-webkit-transform:translate(-50%,10.8px);-ms-transform:translate(-50%,10.8px);transform:translate(-50%,10.8px);width:8px;height:24px;background:orange;border-radius:5px 5px 0 5px}@-webkit-keyframes lantern-swing{0%{-webkit-transform:rotate(-8deg);transform:rotate(-8deg)}to{-webkit-transform:rotate(8deg);transform:rotate(8deg)}}@keyframes lantern-swing{0%{-webkit-transform:rotate(-8deg);transform:rotate(-8deg)}to{-webkit-transform:rotate(8deg);transform:rotate(8deg)}}@media (max-width:460px){.lantern__warpper{top:8px;left:30px}.lantern__warpper.lantern__secondary{left:calc(100% - 80px)}.lantern__box{width:50px;height:40px;-webkit-transform-origin:50% -40px;-ms-transform-origin:50% -40px;transform-origin:50% -40px;-webkit-box-shadow:-5px 5px 50px -1px #fa6c00;box-shadow:-5px 5px 50px -1px #fa6c00}.lantern__box:after,.lantern__box:before{height:4px;width:25px}.lantern__line{width:2px;height:8px}.lantern__circle .lantern__text{font-size:13.5px;line-height:38px}.lantern__tail{width:4px;height:8px}.lantern__tail .lantern__junction{width:8px;height:8px;-webkit-transform:translate(-50%,5.6px);-ms-transform:translate(-50%,5.6px);transform:translate(-50%,5.6px)}.lantern__tail .lantern__rect{-webkit-transform:translate(-50%,7.2px);-ms-transform:translate(-50%,7.2px);transform:translate(-50%,7.2px);width:8px;height:16px}}'+("day"===n?".night .j-china-lantern {display: none}":"night"===n?".j-china-lantern {display: none}.night .j-china-lantern {display: block}":""),r=(r=void 0===r?{}:r).insertAt,n&&"undefined"!=typeof document&&(t=document.head||document.getElementsByTagName("head")[0],(e=document.createElement("style")).type="text/css","top"===r&&t.firstChild?t.insertBefore(e,t.firstChild):t.appendChild(e),e.styleSheet?e.styleSheet.cssText=n:e.appendChild(document.createTextNode(n)));var r;(r=document.createElement("div")).className="j-china-lantern",r.innerHTML='
',document.body.appendChild(r)})?r.call(e,n,e,t):r)&&(t.exports=n)}},a={};!function t(e){var n=a[e];return void 0!==n||(n=a[e]={exports:{}},r[e](n,n.exports,t)),n.exports}(6224)})(); \ No newline at end of file diff --git a/source/js/effects/snowflake.min.js b/source/js/effects/snowflake.min.js new file mode 100644 index 0000000..9dfeb27 --- /dev/null +++ b/source/js/effects/snowflake.min.js @@ -0,0 +1 @@ +(()=>{function t(t){this.maxFlake=(t=t||{}).maxFlake||10,this.flakeSize=t.flakeSize||10,this.fallSpeed=t.fallSpeed||1}const s=DreamConfig.effects_snowflake_mode;let n=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame||function(t){setTimeout(t,1e3/60)};function h(t,e,i,a){this.x=Math.floor(Math.random()*t),this.y=Math.floor(Math.random()*e),this.size=Math.random()*i+2,this.maxSize=i,this.speed=+Math.random()+a,this.fallSpeed=a,this.velY=this.speed,this.velX=0,this.stepSize=Math.random()/30,this.step=0}function o(){var t=document.documentElement.classList.contains("night");if("all"===s||"day"===s&&!t||"night"===s&&t){var e=this.maxFlake,i=this.flakes;ctx=this.ctx,canvas=this.canvas,ctx.clearRect(0,0,canvas.width,canvas.height);for(var a=0;a=canvas.width||this.x<=0||this.y>=canvas.height||this.y<=0)&&this.reset(canvas.width,canvas.height)},h.prototype.reset=function(t,e){this.x=Math.floor(Math.random()*t),this.y=0,this.size=Math.random()*this.maxSize+2,this.speed=+Math.random()+this.fallSpeed,this.velY=this.speed,this.velX=0},h.prototype.render=function(t){var e=t.createRadialGradient(this.x,this.y,0,this.x,this.y,this.size);e.addColorStop(0,"rgba(255, 255, 255, 0.9)"),e.addColorStop(.5,"rgba(255, 255, 255, 0.5)"),e.addColorStop(1,"rgba(255, 255, 255, 0)"),t.save(),t.fillStyle=e,t.beginPath(),t.arc(this.x,this.y,this.size,0,2*Math.PI),t.fill(),t.restore()},new t({maxFlake:150}).start()})(); \ No newline at end of file diff --git a/src/js/common.js b/src/js/common.js index 77eced7..5e2e9c0 100644 --- a/src/js/common.js +++ b/src/js/common.js @@ -479,7 +479,9 @@ const commonContext = { DreamConfig.cursor_move && Utils.cachedScript(`${DreamConfig.theme_base}/source/js/cursor/move/${DreamConfig.cursor_move}.min.js?mew=${DreamConfig.theme_version}`) DreamConfig.cursor_click && Utils.cachedScript(`${DreamConfig.theme_base}/source/js/cursor/click/${DreamConfig.cursor_click}.min.js?mew=${DreamConfig.theme_version}`) DreamConfig.enable_live2d && Utils.cachedScript(`${DreamConfig.theme_base}/source/js/autoload.min.js?mew=${DreamConfig.theme_version}`) + DreamConfig.effects_lantern_mode && Utils.cachedScript(`${DreamConfig.theme_base}/source/js/effects/lantern.min.js?mew=${DreamConfig.theme_version}`) DreamConfig.effects_sakura_mode && Utils.cachedScript(`${DreamConfig.theme_base}/source/js/effects/sakura.min.js?mew=${DreamConfig.theme_version}`) + DreamConfig.effects_snowflake_mode && Utils.cachedScript(`${DreamConfig.theme_base}/source/js/effects/snowflake.min.js?mew=${DreamConfig.theme_version}`) DreamConfig.effects_universe_mode && Utils.cachedScript(`${DreamConfig.theme_base}/source/js/effects/universe.min.js?mew=${DreamConfig.theme_version}`) DreamConfig.effects_circle_magic_mode && Utils.cachedScript(`${DreamConfig.theme_base}/source/js/effects/circleMagic.min.js?mew=${DreamConfig.theme_version}`) }, diff --git a/src/js/effects/lantern.js b/src/js/effects/lantern.js new file mode 100644 index 0000000..3ade447 --- /dev/null +++ b/src/js/effects/lantern.js @@ -0,0 +1,51 @@ +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory() +}((function () { 'use strict' + + const mode = DreamConfig.effects_lantern_mode + + function styleInject(css, ref) { + if ( ref === void 0 ) ref = {} + var insertAt = ref.insertAt + + if (!css || typeof document === 'undefined') { return } + + var head = document.head || document.getElementsByTagName('head')[0] + var style = document.createElement('style') + style.type = 'text/css' + + if (insertAt === 'top') { + if (head.firstChild) { + head.insertBefore(style, head.firstChild) + } else { + head.appendChild(style) + } + } else { + head.appendChild(style) + } + + if (style.styleSheet) { + style.styleSheet.cssText = css + } else { + style.appendChild(document.createTextNode(css)) + } + } + + let mode_css = mode === 'day' ? '.night .j-china-lantern {display: none}' : mode === 'night' ? '.j-china-lantern {display: none}.night .j-china-lantern {display: block}' : '' + + var css_248z = '@charset "UTF-8";.lantern__warpper{position:fixed;top:12px;left:40px;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;z-index:999}.lantern__warpper.lantern__secondary{left:calc(100% - 130px)}.lantern__warpper.lantern__secondary .lantern__box{-webkit-animation-duration:3s;animation-duration:3s}.lantern__box{position:relative;display:inline-block;width:90px;height:70px;background:rgba(216,0,15,.8);border-radius:50% 50%;animation:lantern-swing 3s ease-in-out infinite alternate-reverse;-webkit-transform-origin:50% -70px;-ms-transform-origin:50% -70px;transform-origin:50% -70px;-webkit-box-shadow:-5px 5px 50px 4px #fa6c00;box-shadow:-5px 5px 50px 4px #fa6c00}.lantern__box:after,.lantern__box:before{content:"";position:absolute;height:8px;width:45px;left:50%;border:1px solid #dc8f03;background:-webkit-gradient(linear,left top,right top,from(#dc8f03),color-stop(orange),color-stop(#dc8f03),color-stop(orange),to(#dc8f03));background:-o-linear-gradient(left,#dc8f03,orange,#dc8f03,orange,#dc8f03);background:linear-gradient(90deg,#dc8f03,orange,#dc8f03,orange,#dc8f03)}.lantern__box:before{top:0;border-radius:5px 5px 0 0;-webkit-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.lantern__box:after{bottom:0;border-radius:0 0 5px 5px;-webkit-transform:translate(-50%,50%);-ms-transform:translate(-50%,50%);transform:translate(-50%,50%)}.lantern__line{position:absolute;width:2px;height:12px;top:0;left:50%;-webkit-transform:translate(-50%,-100%);-ms-transform:translate(-50%,-100%);transform:translate(-50%,-100%);background:#dc8f03}.lantern__circle{width:80%;-webkit-box-sizing:border-box;box-sizing:border-box}.lantern__circle,.lantern__circle .lantern__ellipse{height:100%;margin:0 auto;border-radius:50%;border:2px solid #dc8f03}.lantern__circle .lantern__ellipse{width:50%}.lantern__circle .lantern__text{font-family:华文行楷,Microsoft YaHei,sans-serif;font-size:24.3px;color:#dc8f03;font-weight:700;line-height:66px;text-align:center}.lantern__tail{position:relative;width:4px;height:12px;margin:0 auto;animation:lantern-swing 4s ease-in-out infinite alternate-reverse;background:orange;border-radius:0 0 5px 5px}.lantern__tail .lantern__junction{position:absolute;top:0;left:50%;width:8px;height:8px;-webkit-transform:translate(-50%,8.4px);-ms-transform:translate(-50%,8.4px);transform:translate(-50%,8.4px);background:#e69603;border-radius:50%}.lantern__tail .lantern__rect{position:absolute;top:0;left:50%;-webkit-transform:translate(-50%,10.8px);-ms-transform:translate(-50%,10.8px);transform:translate(-50%,10.8px);width:8px;height:24px;background:orange;border-radius:5px 5px 0 5px}@-webkit-keyframes lantern-swing{0%{-webkit-transform:rotate(-8deg);transform:rotate(-8deg)}to{-webkit-transform:rotate(8deg);transform:rotate(8deg)}}@keyframes lantern-swing{0%{-webkit-transform:rotate(-8deg);transform:rotate(-8deg)}to{-webkit-transform:rotate(8deg);transform:rotate(8deg)}}@media (max-width:460px){.lantern__warpper{top:8px;left:30px}.lantern__warpper.lantern__secondary{left:calc(100% - 80px)}.lantern__box{width:50px;height:40px;-webkit-transform-origin:50% -40px;-ms-transform-origin:50% -40px;transform-origin:50% -40px;-webkit-box-shadow:-5px 5px 50px -1px #fa6c00;box-shadow:-5px 5px 50px -1px #fa6c00}.lantern__box:after,.lantern__box:before{height:4px;width:25px}.lantern__line{width:2px;height:8px}.lantern__circle .lantern__text{font-size:13.5px;line-height:38px}.lantern__tail{width:4px;height:8px}.lantern__tail .lantern__junction{width:8px;height:8px;-webkit-transform:translate(-50%,5.6px);-ms-transform:translate(-50%,5.6px);transform:translate(-50%,5.6px)}.lantern__tail .lantern__rect{-webkit-transform:translate(-50%,7.2px);-ms-transform:translate(-50%,7.2px);transform:translate(-50%,7.2px);width:8px;height:16px}}' + mode_css + styleInject(css_248z) + + var content = '
' + + function createElement() { + var div = document.createElement('div') + div.className = 'j-china-lantern' + div.innerHTML = content + document.body.appendChild(div) + } + + createElement() + +}))) \ No newline at end of file diff --git a/src/js/effects/snowflake.js b/src/js/effects/snowflake.js new file mode 100644 index 0000000..3b3c8b7 --- /dev/null +++ b/src/js/effects/snowflake.js @@ -0,0 +1,146 @@ +/* 控制下雪 */ +function snowFall(snow) { + /* 可配置属性 */ + snow = snow || {} + this.maxFlake = snow.maxFlake || 10 /* 最多片数 */ + this.flakeSize = snow.flakeSize || 10 /* 雪花形状 */ + this.fallSpeed = snow.fallSpeed || 1 /* 坠落速度 */ +} + +const mode = DreamConfig.effects_snowflake_mode + +/* 兼容写法 */ +let requestAnimationFrame = window.requestAnimationFrame || + window.mozRequestAnimationFrame || + window.webkitRequestAnimationFrame || + window.msRequestAnimationFrame || + window.oRequestAnimationFrame || + function(callback) { setTimeout(callback, 1000 / 60) } + +let cancelAnimationFrame = window.cancelAnimationFrame || + window.mozCancelAnimationFrame || + window.webkitCancelAnimationFrame || + window.msCancelAnimationFrame || + window.oCancelAnimationFrame + +/* 开始下雪 */ +snowFall.prototype.start = function(){ + /* 创建画布 */ + snowCanvas.apply(this) + /* 创建雪花形状 */ + createFlakes.apply(this) + /* 画雪 */ + drawSnow.apply(this) +} + +/* 创建画布 */ +function snowCanvas() { + /* 添加Dom结点 */ + var snowcanvas = document.createElement('canvas') + snowcanvas.id = 'snowfall' + snowcanvas.width = document.body.offsetWidth + snowcanvas.height = window.innerHeight + snowcanvas.setAttribute('class', `canvas_effects ${mode}`) + snowcanvas.setAttribute('style', 'z-index: 9999;') + document.getElementsByTagName('body')[0].appendChild(snowcanvas) + this.canvas = snowcanvas + this.ctx = snowcanvas.getContext('2d') + + /* 窗口大小改变的处理 */ + window.onresize = function() { + snowcanvas.width = document.body.offsetWidth + snowcanvas.height = window.innerHeight + } + +} + +/* 雪运动对象 */ +function flakeMove(canvasWidth, canvasHeight, flakeSize, fallSpeed) { + this.x = Math.floor(Math.random() * canvasWidth) /* x坐标 */ + this.y = Math.floor(Math.random() * canvasHeight) /* y坐标 */ + this.size = Math.random() * flakeSize + 2 /* 形状 */ + this.maxSize = flakeSize /* 最大形状 */ + this.speed = Math.random() * 1 + fallSpeed /* 坠落速度 */ + this.fallSpeed = fallSpeed /* 坠落速度 */ + this.velY = this.speed /* Y方向速度 */ + this.velX = 0 /* X方向速度 */ + this.stepSize = Math.random() / 30 /* 步长 */ + this.step = 0 /* 步数 */ +} + +flakeMove.prototype.update = function() { + var x = this.x, + y = this.y + /* 左右摆动(余弦) */ + this.velX *= 0.98 + if (this.velY <= this.speed) { + this.velY = this.speed + } + this.velX += Math.cos(this.step += .05) * this.stepSize + + this.y += this.velY + this.x += this.velX + /* 飞出边界的处理 */ + if (this.x >= canvas.width || this.x <= 0 || this.y >= canvas.height || this.y <= 0) { + this.reset(canvas.width, canvas.height) + } +} + +/* 飞出边界-放置最顶端继续坠落 */ +flakeMove.prototype.reset = function(width, height) { + this.x = Math.floor(Math.random() * width) + this.y = 0 + this.size = Math.random() * this.maxSize + 2 + this.speed = Math.random() * 1 + this.fallSpeed + this.velY = this.speed + this.velX = 0 +} + +// 渲染雪花-随机形状(此处可修改雪花颜色!!!) +flakeMove.prototype.render = function(ctx) { + var snowFlake = ctx.createRadialGradient(this.x, this.y, 0, this.x, this.y, this.size) + snowFlake.addColorStop(0, 'rgba(255, 255, 255, 0.9)') /* 此处是雪花颜色,默认是白色 */ + snowFlake.addColorStop(.5, 'rgba(255, 255, 255, 0.5)') /* 若要改为其他颜色,请自行查 */ + snowFlake.addColorStop(1, 'rgba(255, 255, 255, 0)') /* 找16进制的RGB 颜色代码。 */ + ctx.save() + ctx.fillStyle = snowFlake + ctx.beginPath() + ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2) + ctx.fill() + ctx.restore() +} + +/* 创建雪花-定义形状 */ +function createFlakes() { + var maxFlake = this.maxFlake, + flakes = this.flakes = [], + canvas = this.canvas + for (var i = 0; i < maxFlake; i++) { + flakes.push(new flakeMove(canvas.width, canvas.height, this.flakeSize, this.fallSpeed)) + } +} + +/* 画雪 */ +function drawSnow() { + const isNight = document.documentElement.classList.contains('night') + if (mode === 'all' || (mode === 'day' && !isNight) || (mode === 'night' && isNight)) { + var maxFlake = this.maxFlake, + flakes = this.flakes + ctx = this.ctx, canvas = this.canvas + /* 清空雪花 */ + ctx.clearRect(0, 0, canvas.width, canvas.height) + for (var e = 0; e < maxFlake; e++) { + flakes[e].update() + flakes[e].render(ctx) + } + } + that = this + /* 一帧一帧的画 */ + this.loop = requestAnimationFrame(function() { + drawSnow.apply(that) + }) +} + +/* 调用及控制方法 */ +var snow = new snowFall({maxFlake:150}) +snow.start() \ No newline at end of file diff --git a/template/common/config.ftl b/template/common/config.ftl index 0c45c09..029a52d 100644 --- a/template/common/config.ftl +++ b/template/common/config.ftl @@ -152,9 +152,15 @@ <#if settings.cursor_click?? && settings.cursor_click!='none'> DreamConfig["cursor_click"] = '${settings.cursor_click}'; + <#if settings.effects_lantern_mode?? && settings.effects_lantern_mode!='none'> + DreamConfig["effects_lantern_mode"] = '${settings.effects_lantern_mode}'; + <#if settings.effects_sakura_mode?? && settings.effects_sakura_mode!='none'> DreamConfig["effects_sakura_mode"] = '${settings.effects_sakura_mode}'; + <#if settings.effects_snowflake_mode?? && settings.effects_snowflake_mode!='none'> + DreamConfig["effects_snowflake_mode"] = '${settings.effects_snowflake_mode}'; + <#if settings.effects_universe_mode?? && settings.effects_universe_mode!='none'> DreamConfig["effects_universe_mode"] = '${settings.effects_universe_mode}';