扩展<mew-music>组件,可用于自定义侧边栏播放器

This commit is contained in:
j m 2024-12-20 05:46:33 +08:00
parent 9a42b9b771
commit ae2b6a36ab
6 changed files with 24 additions and 14 deletions

6
package-lock.json generated
View File

@ -2818,9 +2818,9 @@
} }
}, },
"node_modules/caniuse-lite": { "node_modules/caniuse-lite": {
"version": "1.0.30001597", "version": "1.0.30001690",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001597.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001690.tgz",
"integrity": "sha512-7LjJvmQU6Sj7bL0j5b5WY/3n7utXUJvAe1lxhsHDbLmwX9mdL86Yjtr+5SRCyf8qME4M7pU2hswj0FpyBVCv9w==", "integrity": "sha512-5ExiE3qQN6oF8Clf8ifIDcMRCRE/dMGcETG/XGMD8/XiXm6HXQgQTh1yZYLXXpSOsEUlJm1Xr7kGULZTuGtP/w==",
"dev": true, "dev": true,
"funding": [ "funding": [
{ {

View File

@ -68,6 +68,8 @@ document.addEventListener('DOMContentLoaded', () => {
this.innerHTML = '音乐播放器加载中...' this.innerHTML = '音乐播放器加载中...'
this.options = { this.options = {
container: this, container: this,
fixed: this.hasAttribute('fixed') || false,
mutex: this.hasAttribute('mutex') || true,
theme: this.getAttribute('theme') || 'var(--theme)', theme: this.getAttribute('theme') || 'var(--theme)',
loop: this.getAttribute('loop') || 'all', loop: this.getAttribute('loop') || 'all',
autoplay: this.hasAttribute('autoplay') && this.getAttribute('autoplay') !== 'false', autoplay: this.hasAttribute('autoplay') && this.getAttribute('autoplay') !== 'false',
@ -77,6 +79,7 @@ document.addEventListener('DOMContentLoaded', () => {
listMaxHeight: this.getAttribute('listMaxHeight') || 450, listMaxHeight: this.getAttribute('listMaxHeight') || 450,
mimi: this.getAttribute('mimi') || false, mimi: this.getAttribute('mimi') || false,
order: this.getAttribute('order') || 'list', order: this.getAttribute('order') || 'list',
storageName: this.getAttribute('storageName') || 'aplayer-setting',
} }
if (!('APlayer' in window)) { if (!('APlayer' in window)) {
if (!MewMusic.prototype.load) { if (!MewMusic.prototype.load) {
@ -84,8 +87,8 @@ document.addEventListener('DOMContentLoaded', () => {
MewMusic.prototype.await = [] MewMusic.prototype.await = []
new Promise((resolve) => { new Promise((resolve) => {
const $head = $('head') const $head = $('head')
$head.append('<link rel="stylesheet" href="https://unpkg.com/aplayer@1.10.1/dist/APlayer.min.css">') $head.append('<link rel="stylesheet" href="/themes/theme-dream2-plus/assets/lib/aplayer@1.10.1/APlayer.min.css">')
Utils.cachedScript('https://unpkg.com/aplayer@1.10.1/dist/APlayer.min.js') Utils.cachedScript('/themes/theme-dream2-plus/assets/lib/aplayer@1.10.1/APlayer.min.js')
.done(() => resolve()) .done(() => resolve())
.fail(() => resolve()) .fail(() => resolve())
}).then(() => { }).then(() => {
@ -128,7 +131,14 @@ document.addEventListener('DOMContentLoaded', () => {
lrc: this.getAttribute('lrc') || (this.options.lrcType = undefined), lrc: this.getAttribute('lrc') || (this.options.lrcType = undefined),
}] }]
} else if (this.hasAttribute('music-list')) { } else if (this.hasAttribute('music-list')) {
this.options.audio = JSON.parse(this.getAttribute('music-list')) var musicList = JSON.parse(this.getAttribute('music-list'))
musicList.forEach((item) => {
item.lrc = item.lrc || ''
item.name = item.name || '音乐'
item.artist = item.artist || '未知歌手'
item.cover = item.cover || '/themes/theme-dream2-plus/assets/img/music.webp'
})
this.options.audio = musicList
} else { } else {
this.innerHTML = '未指定播放的音乐!' this.innerHTML = '未指定播放的音乐!'
return resolve() return resolve()
@ -425,7 +435,7 @@ document.addEventListener('DOMContentLoaded', () => {
MewPhotos.prototype.load = true MewPhotos.prototype.load = true
MewPhotos.prototype.await = [] MewPhotos.prototype.await = []
new Promise((resolve) => { new Promise((resolve) => {
Utils.cachedScript('https://unpkg.com/justifiedGallery@3.8.1/dist/js/jquery.justifiedGallery.min.js') Utils.cachedScript('/themes/theme-dream2-plus/assets/lib/justifiedGallery@3.8.1/dist/js/jquery.justifiedGallery.min.js')
.done(() => resolve()) .done(() => resolve())
.fail(() => resolve()) .fail(() => resolve())
}).then(() => { }).then(() => {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -30,7 +30,7 @@ spec:
settingName: theme-dream2-plus-setting settingName: theme-dream2-plus-setting
configMapName: theme-dream2-plus-configMap configMapName: theme-dream2-plus-configMap
# 版本号 # 版本号
version: 1.3.3.beta6 version: 1.3.3.beta7
# 最低支持的 Halo 版本 # 最低支持的 Halo 版本
require: ">=2.20.0" require: ">=2.20.0"
# 许可 # 许可