Skip to content

网页音乐播放器

添加网页音乐播放器

image-20250308073343552

版权

自己测试。

环境

2025年4月3日解决。

配置环境:

Youbg Kbt》大佬开源的《vitepress-theme-teek》一个博客项目(知识库+博客 二合一),它是一个轻量、简易的VitePress主题框架,非常简约唯美,且也在持续迭代更新,感谢大佬开源的这款优秀产品,大佬威武。💖💖💖

效果

配置

警告

官方给的代码加在项目的配置文件里,我测试本地是生效的,但在线是不生效的,因此这里我将代码加在打好包的index.html文件里。

(1)打开网站音乐播放器官网

点击免费注册:

image-20250308073635744

一步步点击到获取代码:(拷贝这2行代码)

image-20250308074516224

(2)将这2行代码添加到自己打好包的index.html文件如下位置:

docs\.vuepress\dist\index.html

image-20250308074449217

css
    <script type="text/javascript" src="https://myhkw.cn/player/js/jquery.min.js"></script>
    <script type="text/javascript" id="myhk" src="https://myhkw.cn/api/player/1xxxxx0" key="17xxxxxxx20" m="1" lr="r"></script>

这里唯一麻烦的是,每次打包后都要手动添加代码,这里我直接用sed命令再每次打包后自动插入这2行代码:

编辑shell\vdoing.sh文件:

bash
……
#构建
cd /d/vuepress-theme-vdoing-one-private
npm run build:win
echo "----------------------------追加音乐播放器代码前--------------------------------"
tail -5 /d/vuepress-theme-vdoing-one-private/docs/.vuepress/dist/index.html
sed -i '/<\/body>/i\    <script type="text/javascript" src="https://myhkw.cn/player/js/jquery.min.js"></script>\n    <script type="text/javascript" id="myhk" src="https://myhkw.cn/api/player/你的私有代码" key="你的私有代码" m="1" lr="r"></script>' /d/vuepress-theme-vdoing-one-private/docs/.vuepress/dist/index.html
echo "----------------------------追加音乐播放器代码后--------------------------------"
tail -5 /d/vuepress-theme-vdoing-one-private/docs/.vuepress/dist/index.html

……

image-20250308080931783

(3)一键提交代码测试,观察效果

image-20250308081049075

最近更新