From bae28fac3534b3d09c70f372475e33f0a07f4ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Fri, 4 Jan 2019 19:28:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90ktv=E6=AD=8C=E8=AF=8D?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- css/app.css | 2 +- css/app.scss | 7 ++- index.html | 4 +- js/app.js | 27 +++++++++- lib/lyrics/index.js | 127 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 159 insertions(+), 8 deletions(-) diff --git a/css/app.css b/css/app.css index fb5b7a5..538df34 100644 --- a/css/app.css +++ b/css/app.css @@ -1 +1 @@ -@font-face{font-family:"sonist font";src:url("data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAysAAsAAAAAFOAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFY9ikkYY21hcAAAAYAAAACpAAACRLbi0KRnbHlmAAACLAAACAwAAA0QU/XrjmhlYWQAAAo4AAAALwAAADYTt0/UaGhlYQAACmgAAAAcAAAAJAfeA5FobXR4AAAKhAAAAA8AAABAQAAAAGxvY2EAAAqUAAAAIgAAACIcSBmSbWF4cAAACrgAAAAfAAAAIAElAK5uYW1lAAAK2AAAAVAAAAKRbYZNvnBvc3QAAAwoAAAAgwAAAL22eIcreJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2BkYWCcwMDKwMHUyXSGgYGhH0IzvmYwYuRgYGBiYGVmwAoC0lxTGByeizxXY27438AQw9zA0AAUZgTJAQDhxQwfeJztkcsRwkAMQ7UkhF8gFyCTQ/iTE7VQECeKoxeVEeQVZWDP2/Has5+RAEwBFOIhSiC9kRDxUjflfoFl7p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McjXoUDXOONE7zqBasHfAh7aOBT+AyX+BKuUP8RrpJ/hWtoeIFwnXwr7GPkPQkHuPPe/Z7VY6enarJRSWTy2OTOL0yeFE5teahnq3RsD5QDHGlbJCZX7bB1oA50ru1+ZrGedZyLVWxNpvrs6jQ1amnNQkcunDu37DabsehhZDIesQcLjTEc1ymvdYIN1wQRDHLE5eroK0pKuDv29/qQqRlWSDnBnvD8r46Y3CaSslZoI0TrhHdAb176j89ZYM3/d6g6urcJy0xG6ktW82wpWWFZ9hZUIuoh5mVqiS6afOMjf1jeQPYH10p3s3icbYxbDoIwFAV7Cq0WUHEhLKqRG23sA/sg6upFDX45X5OTyWGcfWnYf3pwVKghILHBFgoNWnTYYY8DehxZpa1VdCvGmidFcSEds3AlmZOarH4M1qTM3VxH7a8yGX+mKBcfgxNRjyZ8NkttCn4pB0/3vPoUae5W1yX9ovcxYy/tJyzCAA==") format("woff")}[class^="s-icon-"],[class*=" s-icon-"]{display:inline-block;font-family:"sonist font" !important;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.s-icon-all:before{content:"\e714"}.s-icon-eq:before{content:"\e715"}.s-icon-heart:before{content:"\e716"}.s-icon-music:before{content:"\e717"}.s-icon-play-list:before{content:"\e719"}.s-icon-mv:before{content:"\e71d"}.s-icon-rank:before{content:"\e71e"}.s-icon-singer:before{content:"\e71f"}.s-icon-random:before{content:"\e720"}.s-icon-radio:before{content:"\e721"}.s-icon-single:before{content:"\e722"}.s-icon-next:before{content:"\e723"}.s-icon-prev:before{content:"\e724"}.s-icon-pause:before{content:"\e725"}.s-icon-play:before{content:"\e726"}.do-fn-drag{-webkit-app-region:drag;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.do-fn-nodrag{-webkit-app-region:no-drag}html{font-size:62.5%}body{position:fixed;left:0;top:0;display:flex;width:100%;height:100%;line-height:1.5;background:#fff;font-size:1.4rem;color:#62778d;background-size:cover;background-repeat:no-repeat}table{overflow:auto;display:table;width:100%;line-height:2.5rem}table thead tr{height:4.5rem;border-bottom:0.1rem solid rgba(200,200,200,0.15)}table thead th{padding:1rem .8rem;border:0}table tbody tr{height:auto;transition:background .3s ease-in-out}table tbody tr:hover{background:rgba(63,194,168,0.08)}table tbody td{padding:.9rem .8rem}::-webkit-scrollbar{width:8px;height:8px;background:none}::-webkit-scrollbar:hover{background:#f3f5fb}::-webkit-scrollbar-button{display:none}::-webkit-scrollbar-thumb{background:#dae1e9}::-webkit-scrollbar-thumb:hover{background:#3fc2a7}.do-mod-app{position:relative;display:flex;flex-flow:column wrap;width:100%;height:100%;background:#fff}.do-mod-app .title-bar{position:relative;z-index:9;display:flex;flex:0 5rem}.do-mod-app .title-bar .btn-box{position:absolute;left:1.2rem;top:0;width:auto;height:3rem;padding:.9rem 0}.do-mod-app .title-bar .btn-box .item{display:inline-block;width:1.2rem;height:1.2rem;margin:0 .2rem;background:url(/images/btn-grey.svg) no-repeat;background-size:cover}.do-mod-app .title-bar .btn-box.focus .quit{background-image:url(/images/btn-close.svg)}.do-mod-app .title-bar .btn-box.focus .min{background-image:url(/images/btn-mini.svg)}.do-mod-app .title-bar .btn-box.focus .max{background-image:url(/images/btn-maxi.svg)}.do-mod-app .title-bar .btn-box:hover .quit{background-image:url(/images/btn-close_a.svg)}.do-mod-app .title-bar .btn-box:hover .min{background-image:url(/images/btn-mini_a.svg)}.do-mod-app .title-bar .btn-box:hover .max{background-image:url(/images/btn-maxi_a.svg)}.do-mod-app .title-bar .btn-box-win{position:absolute;right:1.2rem;top:0;width:auto;height:4rem;padding:.9rem 0;line-height:1.8rem}.do-mod-app .title-bar .btn-box-win .item,.do-mod-app .title-bar .btn-box-win .opt{position:relative;display:inline-block;width:2.2rem;height:2.2rem;margin:0 .2rem;padding:.2rem;font-size:1.6rem}.do-mod-app .title-bar .btn-box-win .item:hover{-webkit-transform:scale(1.1);transform:scale(1.1)}.do-mod-app .title-bar .btn-box-win .opt i{font-size:1.8rem}.do-mod-app .title-bar .btn-box-win .opt-list{position:absolute;z-index:100;right:0;top:2.2rem;width:13rem;height:auto;padding:.8rem 0;background:#fff;box-shadow:0 0.5rem 2rem rgba(0,0,0,0.1);font-size:1.4rem}.do-mod-app .title-bar .btn-box-win .opt-list span{display:flex;align-items:center;height:3rem;padding:0 2rem;line-height:3rem}.do-mod-app .title-bar .btn-box-win .opt-list span i{padding-right:.8rem}.do-mod-app .title-bar .btn-box-win .opt-list span.pipe{height:.1rem;margin:.5rem 0;border-bottom:0.1rem solid #f3f5fb}.do-mod-app .title-bar .btn-box-win .opt-list span:hover{background:#f3f5fb}.do-mod-app .title-bar .holder{flex:0 22rem;height:100%;background:#f3f5fb}.do-mod-app .title-bar .tools{flex:1;padding:1rem}.do-mod-app .title-bar .tools .search{position:relative;display:inline-block;line-height:3rem}.do-mod-app .title-bar .tools .icon{position:absolute;right:0;top:0;width:2.6rem;height:3rem}.do-mod-app .title-bar .tools input{width:20rem;padding:0 1.3rem;border-radius:1.5rem}.do-mod-app .main-body{flex:1;display:flex}.do-mod-app .main-body .sidebar{flex:0 22rem;position:relative;height:100%;background:#f3f5fb}.do-mod-app .main-body .sidebar .user-box{width:18rem;height:16.5rem;margin:0 2rem;text-align:center}.do-mod-app .main-body .sidebar .user-box .avatar{overflow:hidden;width:12rem;height:12rem;margin:0 3rem;border:.6rem solid #fff;border-radius:50%;box-shadow:0 0.5rem 1.5rem rgba(0,0,0,0.15)}.do-mod-app .main-body .sidebar .user-box img{width:100%;height:100%}.do-mod-app .main-body .sidebar .user-box .uname{line-height:2;font-weight:normal}.do-mod-app .main-body .sidebar .music-box{width:100%;height:auto;padding:0 1.5rem}.do-mod-app .main-body .sidebar .music-box dt.title{line-height:4rem;color:#98acae}.do-mod-app .main-body .sidebar .music-box dd.item{height:3rem;margin:.3rem 0;padding:0 .8rem;line-height:3rem;color:#748182}.do-mod-app .main-body .sidebar .music-box dd.item .icon{float:left;width:3rem;height:3rem;padding:0 .5rem;font-size:2.4rem}.do-mod-app .main-body .sidebar .music-box dd.item:hover{padding-left:.9rem;color:#3fc2a7}.do-mod-app .main-body .sidebar .music-box dd.item.active{border-radius:.3rem;background:#3fc2a7;color:#fff}.do-mod-app .main-body .sidebar .music-box dd.item.disabled{opacity:.25}.do-mod-app .main-body .module{position:relative;flex:1;display:flex;flex-flow:column wrap}.do-mod-app .contrl-bar{position:relative;z-index:99;display:flex;flex:0 8rem;background:#f3f5fb}.do-mod-app .contrl-bar .play-box{flex:0 22rem;display:flex;justify-content:center;align-items:center;height:8rem;padding:1rem 2rem;text-align:center}.do-mod-app .contrl-bar .play-box .item{flex:0 5rem;margin:0 .5rem;line-height:1;font-size:4.2rem;color:#19b491;transition:all .2s ease-in-out}.do-mod-app .contrl-bar .play-box .item:hover{color:#ffb618}.do-mod-app .contrl-bar .play-box .item:active{color:#3fc2a7;-webkit-transform:scale(1.1);transform:scale(1.1)}.do-mod-app .contrl-bar .play-box .play{font-size:5rem}.do-mod-app .contrl-bar .stat-box{position:relative;flex:1;display:flex;justify-content:center;align-items:center}.do-mod-app .contrl-bar .stat-box .song-stat{flex:1;height:8rem;margin:0 2rem 0 0}.do-mod-app .contrl-bar .stat-box .song-stat canvas{display:flex;width:100%;height:100%}.do-mod-app .contrl-bar .stat-box .ctrl{position:relative;flex:0 1 3.5rem;height:3rem;line-height:3rem;text-align:center;color:#19b491;font-size:2rem}.do-mod-app .contrl-bar .stat-box .ctrl:hover{color:#3fc2a7}.do-mod-app .contrl-bar .stat-box .ctrl:active{color:#16967a}.do-mod-app .contrl-bar .stat-box .ctrl.lrc{margin-right:2rem;font-size:1.6rem}.do-mod-app .contrl-bar .stat-box .ctrl .volume-ctrl{display:none;flex-direction:column;justify-content:flex-end;position:absolute;left:.5rem;bottom:3rem;width:2.4rem;height:12rem;padding:1rem .8rem;background:#fff;border-radius:.3rem;box-shadow:0 0 1rem rgba(0,0,0,0.1)}.do-mod-app .contrl-bar .stat-box .ctrl .volume-ctrl em{flex:0 0;border-radius:.5rem;background:#3fc2a7}.do-mod-app .contrl-bar .stat-box .ctrl.volume:hover .volume-ctrl{display:flex}.do-mod-app.blur{background:rgba(255,255,255,0.85);-webkit-backdrop-filter:blur(1rem);backdrop-filter:blur(1rem)}.do-mod-app.blur .title-bar .holder{background:rgba(255,255,255,0.3)}.do-mod-app.blur .title-bar .tools input{background:rgba(255,255,255,0.8)}.do-mod-app.blur .main-body .sidebar{background:rgba(255,255,255,0.3)}.do-mod-app.blur .contrl-bar{background:rgba(255,255,255,0.35)}.do-mod-app.ktv .contrl-bar{background:rgba(233,233,233,0.1)}.do-mod-app.ktv .contrl-bar .play-box .item,.do-mod-app.ktv .contrl-bar .stat-box .ctrl{color:#fff}.do-mod-app .ktv-box{overflow:hidden;position:absolute;z-index:80;left:0;top:0;width:100%;height:100%;background-color:#425064;background-size:cover;background-repeat:no-repeat;color:#fff}.do-mod-app .ktv-box .inner-content{display:flex;flex-flow:column wrap;width:100%;height:100%;padding-bottom:8rem;background:rgba(29,35,44,0.767);-webkit-backdrop-filter:blur(1rem);backdrop-filter:blur(1rem)}.do-mod-app .ktv-box .inner-content .info{flex:1;display:flex;justify-content:center;align-items:center;padding:0 10rem;line-height:2}.do-mod-app .ktv-box .inner-content .info img{width:30rem;height:30rem;border:0.5rem solid rgba(255,255,255,0.5);border-radius:50%}.do-mod-app .ktv-box .inner-content .info .summary{flex:1;padding:0 5rem}.do-mod-app .ktv-box .inner-content .info h3{line-height:3;font-size:1.8rem}.do-mod-app .ktv-box .inner-content .lrc-box{flex:0 10rem;display:flex;flex-flow:column wrap;padding:0 5rem;line-height:5rem;color:#fff;font-size:3rem}.do-mod-app .ktv-box .inner-content .lrc-box section{flex:1;display:flex}.do-mod-app .ktv-box .inner-content .lrc-box section.left{justify-content:flex-start}.do-mod-app .ktv-box .inner-content .lrc-box section.left span{background:linear-gradient(to right, #ff0 25%, #fff 25%);-webkit-background-clip:text;background-clip:text;color:transparent}.do-mod-app .ktv-box .inner-content .lrc-box section.right{justify-content:flex-end}.do-mod-contextmenu{width:145px;height:auto;padding:8px 0;line-height:35px;font-size:1.3rem}.do-mod-contextmenu li{overflow:hidden;width:100%;height:35px;padding:0 10px;transition:background .2s ease-in-out;cursor:default}.do-mod-contextmenu li:hover{background:#f3f5fb}.do-mod-contextmenu li i{padding:0 3px;font-size:1.6rem;vertical-align:bottom}.do-layer .layer-box.do-mod-contextmenu__fixed{padding:0}@-webkit-keyframes play{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes play{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}} +@font-face{font-family:"sonist font";src:url("data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAysAAsAAAAAFOAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAARAAAAFY9ikkYY21hcAAAAYAAAACpAAACRLbi0KRnbHlmAAACLAAACAwAAA0QU/XrjmhlYWQAAAo4AAAALwAAADYTt0/UaGhlYQAACmgAAAAcAAAAJAfeA5FobXR4AAAKhAAAAA8AAABAQAAAAGxvY2EAAAqUAAAAIgAAACIcSBmSbWF4cAAACrgAAAAfAAAAIAElAK5uYW1lAAAK2AAAAVAAAAKRbYZNvnBvc3QAAAwoAAAAgwAAAL22eIcreJxjYGRgYOBikGPQYWB0cfMJYeBgYGGAAJAMY05meiJQDMoDyrGAaQ4gZoOIAgCKIwNPAHicY2BkYWCcwMDKwMHUyXSGgYGhH0IzvmYwYuRgYGBiYGVmwAoC0lxTGByeizxXY27438AQw9zA0AAUZgTJAQDhxQwfeJztkcsRwkAMQ7UkhF8gFyCTQ/iTE7VQECeKoxeVEeQVZWDP2/Has5+RAEwBFOIhSiC9kRDxUjflfoFl7pd4aj9XTgC27DiMo6qtqj6qHEnzjTKqic6WeqHCTN2F7lmhxlrTRuMK/6jz+vntmlDThPbcmaz33oRXbE34xc6Ej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TOL0yeFE5teahnq3RsD5QDHGlbJCZX7bB1oA50ru1+ZrGedZyLVWxNpvrs6jQ1amnNQkcunDu37DabsehhZDIesQcLjTEc1ymvdYIN1wQRDHLE5eroK0pKuDv29/qQqRlWSDnBnvD8r46Y3CaSslZoI0TrhHdAb176j89ZYM3/d6g6urcJy0xG6ktW82wpWWFZ9hZUIuoh5mVqiS6afOMjf1jeQPYH10p3s3icbYxbDoIwFAV7Cq0WUHEhLKqRG23sA/sg6upFDX45X5OTyWGcfWnYf3pwVKghILHBFgoNWnTYYY8DehxZpa1VdCvGmidFcSEds3AlmZOarH4M1qTM3VxH7a8yGX+mKBcfgxNRjyZ8NkttCn4pB0/3vPoUae5W1yX9ovcxYy/tJyzCAA==") format("woff")}[class^="s-icon-"],[class*=" s-icon-"]{display:inline-block;font-family:"sonist font" !important;font-style:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.s-icon-all:before{content:"\e714"}.s-icon-eq:before{content:"\e715"}.s-icon-heart:before{content:"\e716"}.s-icon-music:before{content:"\e717"}.s-icon-play-list:before{content:"\e719"}.s-icon-mv:before{content:"\e71d"}.s-icon-rank:before{content:"\e71e"}.s-icon-singer:before{content:"\e71f"}.s-icon-random:before{content:"\e720"}.s-icon-radio:before{content:"\e721"}.s-icon-single:before{content:"\e722"}.s-icon-next:before{content:"\e723"}.s-icon-prev:before{content:"\e724"}.s-icon-pause:before{content:"\e725"}.s-icon-play:before{content:"\e726"}.do-fn-drag{-webkit-app-region:drag;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.do-fn-nodrag{-webkit-app-region:no-drag}html{font-size:62.5%}body{position:fixed;left:0;top:0;display:flex;width:100%;height:100%;line-height:1.5;background:#fff;font-size:1.4rem;color:#62778d;background-size:cover;background-repeat:no-repeat}table{overflow:auto;display:table;width:100%;line-height:2.5rem}table thead tr{height:4.5rem;border-bottom:0.1rem solid rgba(200,200,200,0.15)}table thead th{padding:1rem .8rem;border:0}table tbody tr{height:auto;transition:background .3s ease-in-out}table tbody tr:hover{background:rgba(63,194,168,0.08)}table tbody td{padding:.9rem .8rem}::-webkit-scrollbar{width:8px;height:8px;background:none}::-webkit-scrollbar:hover{background:#f3f5fb}::-webkit-scrollbar-button{display:none}::-webkit-scrollbar-thumb{background:#dae1e9}::-webkit-scrollbar-thumb:hover{background:#3fc2a7}.do-mod-app{position:relative;display:flex;flex-flow:column wrap;width:100%;height:100%;background:#fff}.do-mod-app .title-bar{position:relative;z-index:9;display:flex;flex:0 5rem}.do-mod-app .title-bar .btn-box{position:absolute;left:1.2rem;top:0;width:auto;height:3rem;padding:.9rem 0}.do-mod-app .title-bar .btn-box .item{display:inline-block;width:1.2rem;height:1.2rem;margin:0 .2rem;background:url(/images/btn-grey.svg) no-repeat;background-size:cover}.do-mod-app .title-bar .btn-box.focus .quit{background-image:url(/images/btn-close.svg)}.do-mod-app .title-bar .btn-box.focus .min{background-image:url(/images/btn-mini.svg)}.do-mod-app .title-bar .btn-box.focus .max{background-image:url(/images/btn-maxi.svg)}.do-mod-app .title-bar .btn-box:hover .quit{background-image:url(/images/btn-close_a.svg)}.do-mod-app .title-bar .btn-box:hover .min{background-image:url(/images/btn-mini_a.svg)}.do-mod-app .title-bar .btn-box:hover .max{background-image:url(/images/btn-maxi_a.svg)}.do-mod-app .title-bar .btn-box-win{position:absolute;right:1.2rem;top:0;width:auto;height:4rem;padding:.9rem 0;line-height:1.8rem}.do-mod-app .title-bar .btn-box-win .item,.do-mod-app .title-bar .btn-box-win .opt{position:relative;display:inline-block;width:2.2rem;height:2.2rem;margin:0 .2rem;padding:.2rem;font-size:1.6rem}.do-mod-app .title-bar .btn-box-win .item:hover{-webkit-transform:scale(1.1);transform:scale(1.1)}.do-mod-app .title-bar .btn-box-win .opt i{font-size:1.8rem}.do-mod-app .title-bar .btn-box-win .opt-list{position:absolute;z-index:100;right:0;top:2.2rem;width:13rem;height:auto;padding:.8rem 0;background:#fff;box-shadow:0 0.5rem 2rem rgba(0,0,0,0.1);font-size:1.4rem}.do-mod-app .title-bar .btn-box-win .opt-list span{display:flex;align-items:center;height:3rem;padding:0 2rem;line-height:3rem}.do-mod-app .title-bar .btn-box-win .opt-list span i{padding-right:.8rem}.do-mod-app .title-bar .btn-box-win .opt-list span.pipe{height:.1rem;margin:.5rem 0;border-bottom:0.1rem solid #f3f5fb}.do-mod-app .title-bar .btn-box-win .opt-list span:hover{background:#f3f5fb}.do-mod-app .title-bar .holder{flex:0 22rem;height:100%;background:#f3f5fb}.do-mod-app .title-bar .tools{flex:1;padding:1rem}.do-mod-app .title-bar .tools .search{position:relative;display:inline-block;line-height:3rem}.do-mod-app .title-bar .tools .icon{position:absolute;right:0;top:0;width:2.6rem;height:3rem}.do-mod-app .title-bar .tools input{width:20rem;padding:0 1.3rem;border-radius:1.5rem}.do-mod-app .main-body{flex:1;display:flex}.do-mod-app .main-body .sidebar{flex:0 22rem;position:relative;height:100%;background:#f3f5fb}.do-mod-app .main-body .sidebar .user-box{width:18rem;height:16.5rem;margin:0 2rem;text-align:center}.do-mod-app .main-body .sidebar .user-box .avatar{overflow:hidden;width:12rem;height:12rem;margin:0 3rem;border:.6rem solid #fff;border-radius:50%;box-shadow:0 0.5rem 1.5rem rgba(0,0,0,0.15)}.do-mod-app .main-body .sidebar .user-box img{width:100%;height:100%}.do-mod-app .main-body .sidebar .user-box .uname{line-height:2;font-weight:normal}.do-mod-app .main-body .sidebar .music-box{width:100%;height:auto;padding:0 1.5rem}.do-mod-app .main-body .sidebar .music-box dt.title{line-height:4rem;color:#98acae}.do-mod-app .main-body .sidebar .music-box dd.item{height:3rem;margin:.3rem 0;padding:0 .8rem;line-height:3rem;color:#748182}.do-mod-app .main-body .sidebar .music-box dd.item .icon{float:left;width:3rem;height:3rem;padding:0 .5rem;font-size:2.4rem}.do-mod-app .main-body .sidebar .music-box dd.item:hover{padding-left:.9rem;color:#3fc2a7}.do-mod-app .main-body .sidebar .music-box dd.item.active{border-radius:.3rem;background:#3fc2a7;color:#fff}.do-mod-app .main-body .sidebar .music-box dd.item.disabled{opacity:.25}.do-mod-app .main-body .module{position:relative;flex:1;display:flex;flex-flow:column wrap}.do-mod-app .contrl-bar{position:relative;z-index:99;display:flex;flex:0 8rem;background:#f3f5fb}.do-mod-app .contrl-bar .play-box{flex:0 22rem;display:flex;justify-content:center;align-items:center;height:8rem;padding:1rem 2rem;text-align:center}.do-mod-app .contrl-bar .play-box .item{flex:0 5rem;margin:0 .5rem;line-height:1;font-size:4.2rem;color:#19b491;transition:all .2s ease-in-out}.do-mod-app .contrl-bar .play-box .item:hover{color:#ffb618}.do-mod-app .contrl-bar .play-box .item:active{color:#3fc2a7;-webkit-transform:scale(1.1);transform:scale(1.1)}.do-mod-app .contrl-bar .play-box .play{font-size:5rem}.do-mod-app .contrl-bar .stat-box{position:relative;flex:1;display:flex;justify-content:center;align-items:center}.do-mod-app .contrl-bar .stat-box .song-stat{flex:1;height:8rem;margin:0 2rem 0 0}.do-mod-app .contrl-bar .stat-box .song-stat canvas{display:flex;width:100%;height:100%}.do-mod-app .contrl-bar .stat-box .ctrl{position:relative;flex:0 1 3.5rem;height:3rem;line-height:3rem;text-align:center;color:#19b491;font-size:2rem}.do-mod-app .contrl-bar .stat-box .ctrl:hover{color:#3fc2a7}.do-mod-app .contrl-bar .stat-box .ctrl:active{color:#16967a}.do-mod-app .contrl-bar .stat-box .ctrl.lrc{margin-right:2rem;font-size:1.6rem}.do-mod-app .contrl-bar .stat-box .ctrl .volume-ctrl{display:none;flex-direction:column;justify-content:flex-end;position:absolute;left:.5rem;bottom:3rem;width:2.4rem;height:12rem;padding:1rem .8rem;background:#fff;border-radius:.3rem;box-shadow:0 0 1rem rgba(0,0,0,0.1)}.do-mod-app .contrl-bar .stat-box .ctrl .volume-ctrl em{flex:0 0;border-radius:.5rem;background:#3fc2a7}.do-mod-app .contrl-bar .stat-box .ctrl.volume:hover .volume-ctrl{display:flex}.do-mod-app.blur{background:rgba(255,255,255,0.85);-webkit-backdrop-filter:blur(1rem);backdrop-filter:blur(1rem)}.do-mod-app.blur .title-bar .holder{background:rgba(255,255,255,0.3)}.do-mod-app.blur .title-bar .tools input{background:rgba(255,255,255,0.8)}.do-mod-app.blur .main-body .sidebar{background:rgba(255,255,255,0.3)}.do-mod-app.blur .contrl-bar{background:rgba(255,255,255,0.35)}.do-mod-app.ktv .contrl-bar{background:rgba(233,233,233,0.1)}.do-mod-app.ktv .contrl-bar .play-box .item,.do-mod-app.ktv .contrl-bar .stat-box .ctrl{color:#fff}.do-mod-app .ktv-box{overflow:hidden;position:absolute;z-index:80;left:0;top:0;width:100%;height:100%;background-color:#425064;background-size:cover;background-repeat:no-repeat;color:#fff}.do-mod-app .ktv-box .inner-content{display:flex;flex-flow:column wrap;width:100%;height:100%;padding-bottom:8rem;background:rgba(29,35,44,0.767);-webkit-backdrop-filter:blur(1rem);backdrop-filter:blur(1rem)}.do-mod-app .ktv-box .inner-content .info{flex:1;display:flex;justify-content:center;align-items:center;padding:0 10rem;line-height:2}.do-mod-app .ktv-box .inner-content .info img{width:30rem;height:30rem;border:0.5rem solid rgba(255,255,255,0.5);border-radius:50%}.do-mod-app .ktv-box .inner-content .info .summary{flex:1;padding:0 5rem}.do-mod-app .ktv-box .inner-content .info h3{line-height:3;font-size:1.8rem}.do-mod-app .ktv-box .inner-content .lrc-box{flex:0 10rem;display:flex;flex-flow:column wrap;padding:0 5rem;line-height:5rem;color:#fff;font-size:3rem}.do-mod-app .ktv-box .inner-content .lrc-box section{flex:1;display:flex}.do-mod-app .ktv-box .inner-content .lrc-box section.left{justify-content:flex-start}.do-mod-app .ktv-box .inner-content .lrc-box section.right{justify-content:flex-end}.do-mod-app .ktv-box .inner-content .lrc-box section span{-webkit-background-clip:text !important;background-clip:text !important;color:transparent}.do-mod-contextmenu{width:145px;height:auto;padding:8px 0;line-height:35px;font-size:1.3rem}.do-mod-contextmenu li{overflow:hidden;width:100%;height:35px;padding:0 10px;transition:background .2s ease-in-out;cursor:default}.do-mod-contextmenu li:hover{background:#f3f5fb}.do-mod-contextmenu li i{padding:0 3px;font-size:1.6rem;vertical-align:bottom}.do-layer .layer-box.do-mod-contextmenu__fixed{padding:0}@-webkit-keyframes play{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes play{from{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(360deg);transform:rotate(360deg)}} diff --git a/css/app.scss b/css/app.scss index f6b434c..0d6baf6 100644 --- a/css/app.scss +++ b/css/app.scss @@ -223,11 +223,10 @@ table {overflow:auto;display:table;width:100%;line-height:2.5rem; section {flex:1;display:flex; - &.left {justify-content:flex-start; - - span {background: linear-gradient(to right, #ff0 25%, #fff 25%);;background-clip:text;color:transparent;} - } + &.left {justify-content:flex-start;} &.right {justify-content:flex-end} + + span {background-clip:text!important;color:transparent;} } } diff --git a/index.html b/index.html index 2c06637..d6a040f 100644 --- a/index.html +++ b/index.html @@ -124,10 +124,10 @@
- 我有句话悄悄想对你说 +
- 想着你成为我一种坏习惯 +
diff --git a/js/app.js b/js/app.js index 7a9f7c9..763a3cb 100644 --- a/js/app.js +++ b/js/app.js @@ -8,6 +8,7 @@ import '/lib/anot.next.js' import layer from '/lib/layer/index.js' import store from '/lib/store/index.js' import AudioPlayer from '/lib/audio/index.js' +import Lyrics from '/lib/lyrics/index.js' import Api from '/js/api.js' @@ -54,6 +55,7 @@ window.LS = store.collection('local') window.TS = store.collection('temp') // 音乐播放器 window.SONIST = new AudioPlayer() +window.LYRICS = new Lyrics() let appInit = fs.cat(APP_INI_PATH) @@ -80,6 +82,11 @@ Anot({ album: '', time: 0, duration: 0 + }, + ctrlLrc: '暂无歌词...', + lrc: { + l: { bg: '', txt: '' }, + r: { bg: '', txt: '' } } }, skip: [], @@ -136,6 +143,7 @@ Anot({ let pp = (ax - 124) / (aw - 124) this.curr.time = pp * this.curr.duration SONIST.seek(this.curr.time) + LYRICS.seek(this.curr.time) if (!this.isPlaying) { this.draw() } @@ -150,12 +158,23 @@ Anot({ SONIST.on('play', time => { this.curr.time = time + LYRICS.update(time) }) SONIST.on('end', time => { this.nextSong(1) }) + // 控制条的单行歌词 + LYRICS.on('ctrl-lrc', lrc => { + this.ctrlLrc = lrc + }) + + // ktv模式的歌词 + LYRICS.on('ktv-lrc', lrc => { + this.lrc = lrc + }) + this.activeModule(this.mod) remote.app.on('browser-window-focus', _ => { @@ -239,6 +258,7 @@ Anot({ let wl = this.__HEIGHT__ + 180 // 文字的坐标X let { time, duration, title, artist } = this.curr + let lrc = this.ctrlLrc let pp = time / duration // 进度百分比 time = Anot.filters.time(time) duration = Anot.filters.time(duration) @@ -282,7 +302,7 @@ Anot({ // 歌词 this.__CTX__.fillStyle = COLORS[this.ktvMode].lrc this.__CTX__.font = '48px' + FONTS_NAME - this.__CTX__.fillText(`暂无歌词...`, wl, 180) + this.__CTX__.fillText(lrc, wl, 180) // 进度条 this.__CTX__.fillStyle = COLORS[this.ktvMode].bar1 @@ -361,9 +381,11 @@ Anot({ // 此时仅更新播放控制条的信息即可 if (song) { song.time = 0 + this.ctrlLrc = '暂无歌词...' this.updateCurr(song) this.isPlaying = true this.draw(true) + LYRICS.__init__(song.lyrics) } else { if (SONIST.stat === 'ready') { let played = this.isPlaying @@ -379,9 +401,12 @@ Anot({ let lastPlay = Anot.ls('last-play') || 0 SONIST.play(lastPlay).then(it => { it.time = 0 + this.ctrlLrc = '暂无歌词...' this.updateCurr(it) this.draw(true) // this.ktvMode = 1 + + LYRICS.__init__(it.lyrics) }) } } diff --git a/lib/lyrics/index.js b/lib/lyrics/index.js index e69de29..4c8966b 100644 --- a/lib/lyrics/index.js +++ b/lib/lyrics/index.js @@ -0,0 +1,127 @@ +/** + * 歌词模块 + * @author yutent + * @date 2019/01/04 16:25:25 + */ + +'use strict' + +const log = console.log +const fs = require('iofs') +const { EventEmitter } = require('events') +const util = require('util') + +class Lyrics { + __init__(lrcFile) { + this.lib = [] + this.curr = [] + this.lrc = { + l: { bg: '', txt: '' }, + r: { bg: '', txt: '' } + } + + if (!lrcFile || !fs.exists(lrcFile)) { + return false + } + + let lrc = fs + .cat(lrcFile) + .toString('utf8') + .split('\n') + + this.lib = lrc + .map(it => { + if (it) { + let matches = it.match(/^\[([0-9\.\:]+)\](.+)/) + let time = matches[1] + let txt = matches[2] + time = time.split(/[:\.]/).map(t => +t) + let start = time[0] * 60 + time[1] + time[2] / 100 + return { start, txt } + } + return + }) + .filter(it => it) + + for (let i = 0, it; (it = this.lib[i++]); ) { + if (this.lib[i]) { + it.duration = +(this.lib[i].start - it.start).toFixed(2) + it.end = this.lib[i].start + } else { + it.duration = 3 + it.end = it.start + 3 + } + } + this.tmpLib = this.lib.concat() + + return this.lib.length > 0 + } + + seek(time) { + this.tmpLib = [] + for (let it of this.lib) { + if (it.start > time) { + this.tmpLib.push(it) + } + } + } + + update(time) { + if (!this.curr.length && this.tmpLib.length) { + this.curr = this.tmpLib.splice(0, 2) + } + let stat = 0 + + // 当前时间小于第1句的结束时间 + if (time <= this.curr[0].end) { + // 如果第2句比第1句的时间要小,需要补新 + if (this.curr[1].start < this.curr[0].start && time > this.curr[1].end) { + if (this.tmpLib.length) { + this.curr[1] = this.tmpLib.shift() + } + } + } else { + if (time < this.curr[1].end) { + // 如果第1句比第2句的时间要小,需要补新 + if (this.curr[0].start < this.curr[1].start) { + if (this.tmpLib.length) { + this.curr[0] = this.tmpLib.shift() + } + } + } else { + if (this.tmpLib.length) { + this.curr = this.tmpLib.splice(0, 2) + } + } + } + + stat = (this.curr[0].start < this.curr[1].start) ^ 1 + + this.lrc.l.txt = this.curr[0].txt + this.lrc.r.txt = this.curr[1].txt + + if (stat === 0) { + let pp = ( + ((time - this.curr[0].start) / this.curr[0].duration) * + 100 + ).toFixed(2) + this.lrc.l.bg = `linear-gradient(to right, #ff5061 ${pp}%, #fff ${pp}%)` + this.lrc.r.bg = '#fff' + this.emit('ctrl-lrc', this.lrc.l.txt) + } else { + let pp = ( + ((time - this.curr[1].start) / this.curr[1].duration) * + 100 + ).toFixed(2) + this.lrc.l.bg = '#fff' + this.lrc.r.bg = `linear-gradient(to right, #ff5061 ${pp}%, #fff ${pp}%)` + this.emit('ctrl-lrc', this.lrc.r.txt) + } + + this.emit('ktv-lrc', this.lrc) + } +} + +util.inherits(Lyrics, EventEmitter) + +export default Lyrics