From 49431c2470e7ada900e3198137548ad8a9a4b085 Mon Sep 17 00:00:00 2001 From: j m <1406993111@qq.com> Date: Thu, 19 Dec 2024 20:34:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=A9=E5=B1=95=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E5=8F=AF=E7=94=A8=E4=BA=8E=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E4=BE=A7=E8=BE=B9=E6=A0=8F=E6=92=AD=E6=94=BE=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/mew-custom.js | 7 ++++++- templates/assets/js/mew-custom.min.js | 2 +- theme.yaml | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/js/mew-custom.js b/src/js/mew-custom.js index 18b49a5..9dd7705 100644 --- a/src/js/mew-custom.js +++ b/src/js/mew-custom.js @@ -71,7 +71,10 @@ document.addEventListener('DOMContentLoaded', () => { theme: this.getAttribute('theme') || 'var(--theme)', loop: this.getAttribute('loop') || 'all', autoplay: this.hasAttribute('autoplay') && this.getAttribute('autoplay') !== 'false', - lrcType: 3, + lrcType: this.getAttribute('lrcType') || 3, + listFolded: this.getAttribute('listFolded') || false, + volume: this.getAttribute('volume') || 0.7, + listMaxHeight: this.getAttribute('listMaxHeight') || 450, } if (!('APlayer' in window)) { if (!MewMusic.prototype.load) { @@ -122,6 +125,8 @@ document.addEventListener('DOMContentLoaded', () => { cover: this.getAttribute('cover'), lrc: this.getAttribute('lrc') || (this.options.lrcType = undefined), }] + } else if (this.hasAttribute('music-list')) { + this.options.audio = JSON.parse(this.getAttribute('music-list')) } else { this.innerHTML = '未指定播放的音乐!' return resolve() diff --git a/templates/assets/js/mew-custom.min.js b/templates/assets/js/mew-custom.min.js index 034e263..5980de0 100644 --- a/templates/assets/js/mew-custom.min.js +++ b/templates/assets/js/mew-custom.min.js @@ -1,4 +1,4 @@ -(()=>{class i extends HTMLElement{constructor(){super(),this.hasAttribute("draw")||this.init()}drawComplete(){this.setAttribute("draw",!0)}}document.addEventListener("DOMContentLoaded",()=>{customElements.define("mew-hide",class extends i{init(){var t=$(this),i=t.closest(".main-content");this.options={target:i.attr("data-target"),id:i.attr("data-id")},this.options.target&&this.options.id&&((i=(i=localStorage.getItem(window.encrypt("mew-hide-"+this.options.target)))?JSON.parse(window.decrypt(i)):[]).includes(this.options.id)?(t.before(this.innerHTML),t.remove()):(i=0!==t.find("h1,h2,h3,h4,h5").length,this.setAttribute("hide",window.encrypt(this.innerHTML)),this.innerHTML="",i&&(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 i{init(){this.innerHTML=`${this.innerText||"默认标题"}`,this.drawComplete()}}),customElements.define("mew-music",class i extends HTMLElement{constructor(){super(),this.innerHTML="音乐播放器加载中...",this.options={container:this,theme:this.getAttribute("theme")||"var(--theme)",loop:this.getAttribute("loop")||"all",autoplay:this.hasAttribute("autoplay")&&"false"!==this.getAttribute("autoplay"),lrcType:3},"APlayer"in window?this.render():i.prototype.load?i.prototype.await.push(()=>this.render()):(i.prototype.load=!0,i.prototype.await=[],new Promise(t=>{$("head").append(''),Utils.cachedScript("https://unpkg.com/aplayer@1.10.1/dist/APlayer.min.js").done(()=>t()).fail(()=>t())}).then(()=>{this.render(),i.prototype.await&&i.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.listFolded=this.getAttribute("fold"),this.options.order=this.getAttribute("order"),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"))return this.innerHTML="未指定播放的音乐!",t();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)}]}this.aplayer=new APlayer(this.options),t()}).catch(t=>{}):this.innerHTML="未开启音乐播放器!"}disconnectedCallback(){this.aplayer&&this.aplayer.destroy()}}),customElements.define("mew-bilibili",class extends i{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 i{init(){var t=$(this).children("mew-tab-page");if(0===t.length)this.innerHTML="没有标签页!";else{let s="",o="",n=!1;t.each((t,i)=>{var e=i.getAttribute("title")||"默认标签",t=t+"-"+(new Date).getTime();!n&&i.hasAttribute("active")?(n=!0,s+=`
${e}
`,o+=`
${i.innerHTML}
`):(s+=`
${e}
`,o+=`
${i.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 i{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 i extends HTMLElement{constructor(){super(),this.hasAttribute("draw")||this.init()}drawComplete(){this.setAttribute("draw",!0)}}document.addEventListener("DOMContentLoaded",()=>{customElements.define("mew-hide",class extends i{init(){var t=$(this),i=t.closest(".main-content");this.options={target:i.attr("data-target"),id:i.attr("data-id")},this.options.target&&this.options.id&&((i=(i=localStorage.getItem(window.encrypt("mew-hide-"+this.options.target)))?JSON.parse(window.decrypt(i)):[]).includes(this.options.id)?(t.before(this.innerHTML),t.remove()):(i=0!==t.find("h1,h2,h3,h4,h5").length,this.setAttribute("hide",window.encrypt(this.innerHTML)),this.innerHTML="",i&&(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 i{init(){this.innerHTML=`${this.innerText||"默认标题"}`,this.drawComplete()}}),customElements.define("mew-music",class i extends HTMLElement{constructor(){super(),this.innerHTML="音乐播放器加载中...",this.options={container:this,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},"APlayer"in window?this.render():i.prototype.load?i.prototype.await.push(()=>this.render()):(i.prototype.load=!0,i.prototype.await=[],new Promise(t=>{$("head").append(''),Utils.cachedScript("https://unpkg.com/aplayer@1.10.1/dist/APlayer.min.js").done(()=>t()).fail(()=>t())}).then(()=>{this.render(),i.prototype.await&&i.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.listFolded=this.getAttribute("fold"),this.options.order=this.getAttribute("order"),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();this.options.audio=JSON.parse(this.getAttribute("music-list"))}this.aplayer=new APlayer(this.options),t()}).catch(t=>{}):this.innerHTML="未开启音乐播放器!"}disconnectedCallback(){this.aplayer&&this.aplayer.destroy()}}),customElements.define("mew-bilibili",class extends i{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 i{init(){var t=$(this).children("mew-tab-page");if(0===t.length)this.innerHTML="没有标签页!";else{let s="",o="",n=!1;t.each((t,i)=>{var e=i.getAttribute("title")||"默认标签",t=t+"-"+(new Date).getTime();!n&&i.hasAttribute("active")?(n=!0,s+=`
${e}
`,o+=`
${i.innerHTML}
`):(s+=`
${e}
`,o+=`
${i.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 i{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/theme.yaml b/theme.yaml index a0fed1b..dc2d2a4 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.beta5 + version: 1.3.3.beta6 # 最低支持的 Halo 版本 require: ">=2.20.0" # 许可