From 7274702b013447331f5aaf8572fcc0ec32f03eff Mon Sep 17 00:00:00 2001 From: mjsoftware <1406993111@qq.com> Date: Sat, 21 Dec 2024 11:01:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89ht?= =?UTF-8?q?ml=E5=86=85=E5=AE=B9=EF=BC=8C=E9=9F=B3=E4=B9=90=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E5=99=A8=E5=B1=9E=E6=80=A7=E5=A2=9E=E5=BC=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- settings.yaml | 7 +++++++ src/js/mew-custom.js | 5 ++++- templates/assets/js/mew-custom.min.js | 2 +- templates/common/layout.html | 1 + theme.yaml | 2 +- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/settings.yaml b/settings.yaml index 6e8f312..1e6cbd8 100644 --- a/settings.yaml +++ b/settings.yaml @@ -1644,3 +1644,10 @@ spec: label: "内嵌JS(body)" placeholder: 请输入 JS 代码内容 help: '填入JS代码,无需script标签,将插入body标签尾部。' + - $formkit: code + language: html + height: 45px + name: inline_body_html + label: "内嵌Html内容(body)" + placeholder: 请输入 Html 代码内容 + help: '填入Html代码,将插入body标签尾部,用于自定义显示一段Html内容,注意:Html内容默认会在页脚下方,请注意设置样式避免页脚出现样式问题。' diff --git a/src/js/mew-custom.js b/src/js/mew-custom.js index 8b04274..f4e2bb8 100644 --- a/src/js/mew-custom.js +++ b/src/js/mew-custom.js @@ -110,7 +110,10 @@ document.addEventListener('DOMContentLoaded', () => { } // eslint-disable-next-line no-async-promise-executor new Promise(async (resolve) => { - if (this.hasAttribute('song')) { + if (this.hasAttribute('meetingApi')) { + this.options.audio = await fetch(this.getAttribute('meetingApi')) + .then((response) => response.json()) + } else if (this.hasAttribute('song')) { this.options.audio = await fetch( 'https://api.i-meto.com/meting/api?server=netease&type=song&id=' + this.getAttribute('song') diff --git a/templates/assets/js/mew-custom.min.js b/templates/assets/js/mew-custom.min.js index 1bc323c..b7f6444 100644 --- a/templates/assets/js/mew-custom.min.js +++ b/templates/assets/js/mew-custom.min.js @@ -1,4 +1,4 @@ -(()=>{class e extends HTMLElement{constructor(){super(),this.hasAttribute("draw")||this.init()}drawComplete(){this.setAttribute("draw",!0)}}document.addEventListener("DOMContentLoaded",()=>{customElements.define("mew-hide",class extends e{init(){var t=$(this),e=t.closest(".main-content");this.options={target:e.attr("data-target"),id:e.attr("data-id")},this.options.target&&this.options.id&&((e=(e=localStorage.getItem(window.encrypt("mew-hide-"+this.options.target)))?JSON.parse(window.decrypt(e)):[]).includes(this.options.id)?(t.before(this.innerHTML),t.remove()):(e=0!==t.find("h1,h2,h3,h4,h5").length,this.setAttribute("hide",window.encrypt(this.innerHTML)),this.innerHTML="",e&&(this.setAttribute("toc",!0),commonContext.initTocAndNotice()),this.onclick=function(){var t=$(`halo-comment[id='${this.options.id}'][type='${this.options.target.substring(0,this.options.target.length-1)}']`);0===t.length||t.is(":hidden")||Utils.animateScroll(t[0],20,(window.innerHeight||document.documentElement.clientHeight)/4)})),this.drawComplete()}}),customElements.define("mew-subtitle",class extends e{init(){this.innerHTML=`${this.innerText||"默认标题"}`,this.drawComplete()}}),customElements.define("mew-music",class e extends HTMLElement{constructor(){super(),this.innerHTML="音乐播放器加载中...",this.options={container:this,fixed:this.hasAttribute("fixed")||!1,mutex:this.hasAttribute("mutex")||!0,theme:this.getAttribute("theme")||"var(--theme)",loop:this.getAttribute("loop")||"all",autoplay:this.hasAttribute("autoplay")&&"false"!==this.getAttribute("autoplay"),lrcType:this.getAttribute("lrcType")||3,listFolded:this.getAttribute("listFolded")||!1,volume:this.getAttribute("volume")||.7,listMaxHeight:this.getAttribute("listMaxHeight")||450,mini:this.getAttribute("mini")||!1,order:this.getAttribute("order")||"list",storageName:this.getAttribute("storageName")||"aplayer-setting"},"APlayer"in window?this.render():e.prototype.load?e.prototype.await.push(()=>this.render()):(e.prototype.load=!0,e.prototype.await=[],new Promise(t=>{$("head").append(''),Utils.cachedScript("/themes/theme-dream2-plus/assets/lib/aplayer@1.10.1/APlayer.min.js").done(()=>t()).fail(()=>t())}).then(()=>{this.render(),e.prototype.await&&e.prototype.await.forEach(t=>t())}))}render(){"APlayer"in window?new Promise(async t=>{if(this.hasAttribute("song"))this.options.audio=await fetch("https://api.i-meto.com/meting/api?server=netease&type=song&id="+this.getAttribute("song")).then(t=>t.json());else if(this.hasAttribute("playlist"))this.options.audio=await fetch("https://api.i-meto.com/meting/api?server=netease&type=playlist&id="+this.getAttribute("playlist")).then(t=>t.json());else if(this.hasAttribute("url"))this.options.audio=[{name:this.getAttribute("name")||"音乐",url:this.getAttribute("url"),artist:this.getAttribute("artist")||"未知歌手",cover:this.getAttribute("cover"),lrc:this.getAttribute("lrc")||(this.options.lrcType=void 0)}];else{if(!this.hasAttribute("music-list"))return this.innerHTML="未指定播放的音乐!",t();var e=JSON.parse(this.getAttribute("music-list"));e.forEach(t=>{t.lrc=t.lrc||"",t.name=t.name||"音乐",t.artist=t.artist||"未知歌手",t.cover=t.cover||"/themes/theme-dream2-plus/assets/img/music.webp"}),this.options.audio=e}this.aplayer=new APlayer(this.options),t()}).catch(t=>{}):this.innerHTML="未开启音乐播放器!"}getAPlayer(){return this.aplayer}disconnectedCallback(){this.aplayer&&this.aplayer.destroy()}}),customElements.define("mew-bilibili",class extends e{init(){this.options={bvid:this.getAttribute("bvid"),width:/^\d{1,3}%$/.test(this.getAttribute("width"))?this.getAttribute("width"):"100%"},this.options.bvid?(this.style.padding=`calc(${this.options.width} * 0.3) 0`,this.innerHTML=``):this.innerHTML="bvid未填写!",this.drawComplete()}}),customElements.define("mew-tabs",class extends e{init(){var t=$(this).children("mew-tab-page");if(0===t.length)this.innerHTML="没有标签页!";else{let s="",o="",n=!1;t.each((t,e)=>{var i=e.getAttribute("title")||"默认标签",t=t+"-"+(new Date).getTime();!n&&e.hasAttribute("active")?(n=!0,s+=`
${i}
`,o+=`
${e.innerHTML}
`):(s+=`
${i}
`,o+=`
${e.innerHTML}
`)}),this.innerHTML=`
${s}
${o}
`,n||$(this).find("div>div:first-child").addClass("active")}this.drawComplete()}connectedCallback(){$(this).find(".tabs-head").on("click","div:not(.active)",function(){var t=$(this).parent().parent();t.find(".active").removeClass("active"),$(this).addClass("active"),t.find($(this).attr("data-id")).addClass("active")})}}),customElements.define("mew-cloud",class extends e{init(){this.options={type:this.getAttribute("type")||"default",title:this.innerText||"资源文件分享",url:this.getAttribute("url"),password:this.getAttribute("password")};var t={default:"网络来源",360:"360云盘",bd:"百度网盘",wy:"微云",ali:"阿里云盘",github:"Github仓库",gitee:"Gitee仓库",lz:"蓝奏云网盘"};this.innerHTML=` +(()=>{class e extends HTMLElement{constructor(){super(),this.hasAttribute("draw")||this.init()}drawComplete(){this.setAttribute("draw",!0)}}document.addEventListener("DOMContentLoaded",()=>{customElements.define("mew-hide",class extends e{init(){var t=$(this),e=t.closest(".main-content");this.options={target:e.attr("data-target"),id:e.attr("data-id")},this.options.target&&this.options.id&&((e=(e=localStorage.getItem(window.encrypt("mew-hide-"+this.options.target)))?JSON.parse(window.decrypt(e)):[]).includes(this.options.id)?(t.before(this.innerHTML),t.remove()):(e=0!==t.find("h1,h2,h3,h4,h5").length,this.setAttribute("hide",window.encrypt(this.innerHTML)),this.innerHTML="",e&&(this.setAttribute("toc",!0),commonContext.initTocAndNotice()),this.onclick=function(){var t=$(`halo-comment[id='${this.options.id}'][type='${this.options.target.substring(0,this.options.target.length-1)}']`);0===t.length||t.is(":hidden")||Utils.animateScroll(t[0],20,(window.innerHeight||document.documentElement.clientHeight)/4)})),this.drawComplete()}}),customElements.define("mew-subtitle",class extends e{init(){this.innerHTML=`${this.innerText||"默认标题"}`,this.drawComplete()}}),customElements.define("mew-music",class e extends HTMLElement{constructor(){super(),this.innerHTML="音乐播放器加载中...",this.options={container:this,fixed:this.hasAttribute("fixed")||!1,mutex:this.hasAttribute("mutex")||!0,theme:this.getAttribute("theme")||"var(--theme)",loop:this.getAttribute("loop")||"all",autoplay:this.hasAttribute("autoplay")&&"false"!==this.getAttribute("autoplay"),lrcType:this.getAttribute("lrcType")||3,listFolded:this.getAttribute("listFolded")||!1,volume:this.getAttribute("volume")||.7,listMaxHeight:this.getAttribute("listMaxHeight")||"450px",mini:this.getAttribute("mini")||!1,order:this.getAttribute("order")||"list",storageName:this.getAttribute("storageName")||"aplayer-setting"},"APlayer"in window?this.render():e.prototype.load?e.prototype.await.push(()=>this.render()):(e.prototype.load=!0,e.prototype.await=[],new Promise(t=>{$("head").append(''),Utils.cachedScript("/themes/theme-dream2-plus/assets/lib/aplayer@1.10.1/APlayer.min.js").done(()=>t()).fail(()=>t())}).then(()=>{this.render(),e.prototype.await&&e.prototype.await.forEach(t=>t())}))}render(){"APlayer"in window?new Promise(async t=>{if(this.hasAttribute("meetingApi"))this.options.audio=await fetch(this.getAttribute("meetingApi")).then(t=>t.json());else if(this.hasAttribute("song"))this.options.audio=await fetch("https://api.i-meto.com/meting/api?server=netease&type=song&id="+this.getAttribute("song")).then(t=>t.json());else if(this.hasAttribute("playlist"))this.options.audio=await fetch("https://api.i-meto.com/meting/api?server=netease&type=playlist&id="+this.getAttribute("playlist")).then(t=>t.json());else if(this.hasAttribute("url"))this.options.audio=[{name:this.getAttribute("name")||"音乐",url:this.getAttribute("url"),artist:this.getAttribute("artist")||"未知歌手",cover:this.getAttribute("cover"),lrc:this.getAttribute("lrc")||(this.options.lrcType=void 0)}];else{if(!this.hasAttribute("music-list"))return this.innerHTML="未指定播放的音乐!",t();var e=JSON.parse(this.getAttribute("music-list"));e.forEach(t=>{t.lrc=t.lrc||"",t.name=t.name||"音乐",t.artist=t.artist||"未知歌手",t.cover=t.cover||"/themes/theme-dream2-plus/assets/img/music.webp"}),this.options.audio=e}this.aplayer=new APlayer(this.options),t()}).catch(t=>{}):this.innerHTML="未开启音乐播放器!"}getAPlayer(){return this.aplayer}disconnectedCallback(){this.aplayer&&this.aplayer.destroy()}}),customElements.define("mew-bilibili",class extends e{init(){this.options={bvid:this.getAttribute("bvid"),width:/^\d{1,3}%$/.test(this.getAttribute("width"))?this.getAttribute("width"):"100%"},this.options.bvid?(this.style.padding=`calc(${this.options.width} * 0.3) 0`,this.innerHTML=``):this.innerHTML="bvid未填写!",this.drawComplete()}}),customElements.define("mew-tabs",class extends e{init(){var t=$(this).children("mew-tab-page");if(0===t.length)this.innerHTML="没有标签页!";else{let s="",o="",n=!1;t.each((t,e)=>{var i=e.getAttribute("title")||"默认标签",t=t+"-"+(new Date).getTime();!n&&e.hasAttribute("active")?(n=!0,s+=`
${i}
`,o+=`
${e.innerHTML}
`):(s+=`
${i}
`,o+=`
${e.innerHTML}
`)}),this.innerHTML=`
${s}
${o}
`,n||$(this).find("div>div:first-child").addClass("active")}this.drawComplete()}connectedCallback(){$(this).find(".tabs-head").on("click","div:not(.active)",function(){var t=$(this).parent().parent();t.find(".active").removeClass("active"),$(this).addClass("active"),t.find($(this).attr("data-id")).addClass("active")})}}),customElements.define("mew-cloud",class extends e{init(){this.options={type:this.getAttribute("type")||"default",title:this.innerText||"资源文件分享",url:this.getAttribute("url"),password:this.getAttribute("password")};var t={default:"网络来源",360:"360云盘",bd:"百度网盘",wy:"微云",ali:"阿里云盘",github:"Github仓库",gitee:"Gitee仓库",lz:"蓝奏云网盘"};this.innerHTML=`
${this.options.title}
diff --git a/templates/common/layout.html b/templates/common/layout.html index 0ae491f..b146247 100644 --- a/templates/common/layout.html +++ b/templates/common/layout.html @@ -32,6 +32,7 @@ + diff --git a/theme.yaml b/theme.yaml index 7e9e65d..04a69db 100644 --- a/theme.yaml +++ b/theme.yaml @@ -30,7 +30,7 @@ spec: settingName: theme-dream2-plus-setting configMapName: theme-dream2-plus-configMap # 版本号 - version: 1.3.3.beta10 + version: 1.3.3.beta11 # 最低支持的 Halo 版本 require: ">=2.20.0" # 许可