音乐榜单

Vela 主题设置 · 分区:播放配置 · 上级分区:base · 选项 ID:music_top_radio · 类型:submessage

依赖:仅当 'music_id_switch', '!=', '', '' 满足时才显示/生效。

音乐榜单

功能简介

每周二0:20每个歌榜更新100首音乐,vip歌曲自动跳过

适用场景

  • 当你希望「每周二0:20每个歌榜更新100首音乐,vip歌曲自动跳过」生效时,开启本设置即可,无需改动主题文件。
  • 适用于需要在不写代码的前提下,快速为站点追加「音乐榜单」相关表现的场景。
  • 若同一页面存在多个相似美化项,建议只开启其一,避免视觉冲突。

代码实现

📂 文件创建清单

文件 是否需新建 完整存放路径 / 所属文件夹
sections.php 否(已存在) /zibll_child/includes/acg/sections.php —— 「播放配置」分区的 fields 数组
本设置项 music_top_radio 作为 sections.phpfields 数组的一项,无需单独建文件

无需新建任何 PHP / JS / CSS 文件。本设置是 Vela 主题设置页的一个开关,字段已写在 /zibll_child/includes/acg/sections.php(相对路径 zibll_child/includes/acg/sections.php)的「播放配置」分区(上级分区:base)。开启后,前端通过 vela_get_option('music_top_radio') 读取开关状态,由 includes/acg/ 模块输出对应样式类或加载美化资源。

📁 本段代码存放文件

以下 CSF 字段定义 需放在 /zibll_child/includes/acg/sections.phpzibll_child/includes/acg/sections.php)的「播放配置」分区的 fields 数组中(该项已存在,无需重复添加;若你要新增同类设置,照此格式在对应分区追加即可)。

开关注册代码(CSF 字段定义)

array(
        array(
            'type'    => 'submessage',
            'style'   => 'warning',
            'content' => '<h3 style="color:#fd4c73;">配置说明</h3>
           <p>三种播放模式只生效一种,未避免不懂的大傻子乱搞,设置了不同的权级</p>
           <p>本地音乐 > 自定义歌单 > 音乐榜单</p>
           <p>本地音乐权重最高,如果你开启了本地音乐未进行配置,则播放器不会播放任何音乐</p>',
           'style' => 'warning',
           'type' => 'submessage',
        ),
        array(
            'id'      => 'music_top_radio',
            'default' => 'data-songChart="热歌榜"',
            'type'    => 'radio',
            'title'   => '音乐榜单',
            'desc'   => '每周二0:20每个歌榜更新100首音乐,vip歌曲自动跳过',
            'inline'  => true,
            'options' => array(
                'data-songChart="热歌榜"'   => '热歌榜',
                'data-songChart="新歌榜"'  => '新歌榜',
                'data-songChart="飙升榜"' => '飙升榜',
                'data-songChart="原创榜"' => '原创榜',
            ),
        ),
        array(
            'id'    => 'music_id_switch',
            'type'  => 'switcher',
            'title' => '自定义歌单',
            'desc' => '自定义歌单权重大于音乐榜单',
            'default'  => false,
        ),
        array(
            'dependency'  => array('music_id_switch', '!=', '', ''),
            'id'    => 'music_id',
            'type'  => 'text',
            'title' => ' ',
            'subtitle' => '歌单ID',
            'desc' => '访问网页版网易云,打开你的歌单,链接后面的数字就是歌单ID',
            'default'  => '2192163086',
        ),
        array(
            'id'    => 'music_local',
            'type'  => 'switcher',
            'title' => '使用本地音乐',
            'subtitle' => '无法显示歌词',
            'desc' => '本地音乐json文件路径,在插件目录下有演示内容或<a href="/wp-content/themes/zibll_child/includes/acg/assets/playlistData.json" download>下载 playlistData.json</a>后自行上传',
            'default'  => false,
        ),
        array(
            'dependency'  => array('music_local', '!=', '', ''),
            'id'    => 'music_local_url',
            'type'  => 'text',
            'title' => '文件路径',
            'desc' => '再此处填写你的<code>playlistData.json</code>文件链接,请确保链接可以访问',
            'default'  => '/wp-content/themes/zibll_child/includes/acg/assets/playlistData.json',
        ),
    )

使用示例

  1. 后台 外观 → Vela主题设置 → 播放配置,找到「音乐榜单」开关并打开,保存设置。
  2. 回到前台对应页面,即可看到效果(部分项仅 PC 端或仅子比主题生效,详见说明)。
  3. 在主题或插件代码中读取该设置:
$on = vela_get_option('music_top_radio', false);
if ($on) {
    // 开关已开启,自定义逻辑
}
© 版权声明
THE END
喜欢就支持一下吧
点赞5 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容