• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

vue-music-webapp: vue版本的QQ音乐简易版

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

vue-music-webapp

开源软件地址:

https://gitee.com/LenGxinLove/vue-music-webapp

开源软件介绍:

Vue全家桶 简易版QQ音乐webApp

项目查看运行:

1. 克隆项目并安装依赖

$ git clone https://gitee.com/LenGxinLove/vue-music-webapp.git$ cd vue-music-webapp$ npm install

2. 运行api接口

$ cd ./server$ node app

3.预览项目:

$ npm run serve

功能:

  • 推荐
    • 专辑歌曲列表
    • 专辑详情
  • 排行榜
    • 排行榜详情
  • 歌手
    • 字母筛选
    • 歌手详情
  • 搜索功能
    • 热门搜索
    • 自定义搜索
  • 播放器
    • 迷你播放器
    • 歌曲列表
    • 歌曲播放模式
    • 上一首
    • 下一首
    • 暂停
    • 进度条
  • 换肤

功能演示:

1. 换肤

2. 歌手列表

3. 搜索

功能实现介绍:

1. 换肤功能

换肤是基于css自定义变量来实现的

css自定义变量拥有像less/sass那种定义变量并使用变量的能力,声明变量的时候,变量名前面要加两根连词线(--),在使用的时候只需要使用var()来访问即可

@import url('./variable.less');body {  --theme-color: @color-theme;  --theme-bg-color: @color-theme;  --bg-color: @background-color;  --shortcut-color: @background-shortcut-color;  --text-color: @text-color;}

如果要局部使用,只需要将变量定义在元素选择器内部即可。具体使用详见使用CSS变量

使用 css 自定义变量 的好处就是我们可以使用 js 来改变这个变量:

  • document.body.style.setProperty('--primary', '#31C27C') --> 设置变量
  • document.body.style.getPropertyValue('--primary') --> 获取变量
  • document.body.style.removeProperty('--primary') --> 删除变量
// 换肤document.body.style.setProperty('--theme-color', skin.name === '炫酷黑' ? '#B82525' : skin.color)document.body.style.setProperty('--theme-bg-color', skin.color)document.body.style.setProperty('--bg-color', skin.name === '炫酷黑' ? skin.color : '#fff')document.body.style.setProperty('--shortcut-color', skin.name === '炫酷黑' ? '#333' : '#f2f3f4')document.body.style.setProperty('--text-color', skin.name === '炫酷黑' ? '#FFF' : '#333')

2. better-scroll移动端scroll神器

<template>  <div ref='scroll' class="scroll-view">    <div>      <Loading :show="downLoading" />      <slot></slot>      <Loading :show="upLoading" />    </div>  </div></template>
<script>import BScroll from 'better-scroll'import Loading from 'baseUI/Loading'// import { debounce } from 'utils'export default {  name: 'Scroll',  components: {    Loading  },  props: {    probeType: {      type: Number,      default: 1    },    click: {      type: Boolean,      default: true    },    listenScroll: { // 监听滚动事件      type: Boolean,      default: false    },    pullUp: { // 开启上拉事件      type: Boolean,      default: false    },    pullDown: { // 开启下拉事件      type: Boolean,      default: false    },    bounceTop: { // 允许下拉      type: Boolean,      default: true    },    bounceBottom: { // 允许上拉      type: Boolean,      default: true    },    upLoading: { // 开启下拉loading      type: Boolean,      default: false    },    downLoading: { // 开启上拉loading      type: Boolean,      default: false    },    refreshDelay: {      type: Number,      default: 20    }  },  mounted () {    this._initScroll()  },  methods: {    _initScroll () {      // Options 参数      const { probeType, click, bounceTop, bounceBottom } = this.$props      // Events 事件      const { listenScroll, pullUp, pullDown } = this.$props      if (!this.$refs.scroll) return      this.bScroll = new BScroll(this.$refs.scroll, {        probeType: probeType,        click: click,        stopPropagation: true,        // 是否启用上下拉效果        bounce: {          top: bounceTop,          bottom: bounceBottom        }      })      // 监听滚动事件      if (listenScroll) {        this.bScroll.on('scroll', pos => {          this.$emit('scroll', pos)        })      }      // 触底事件      if (pullUp) {        this.bScroll.on('scrollEnd', () => {          if (this.bScroll.y <= (this.bScroll.maxScrollY + 50)) {            // debounce(() => {            //   this.$emit('pullUp')            // }, 200)            this.$emit('pullUp')          }        })      }      // 上拉事件      if (pullDown) {        this.bScroll.on('touchEnd', (pos) => {          if (pos.y > 50) {            // debounce(() => {            //   this.$emit('pullDown')            // }, 200)            this.$emit('pullDown')          }        })      }    },    refresh () {      this.bScroll && this.bScroll.refresh()    },    scrollTo () {      this.bScroll && this.bScroll.scrollTo.apply(this.bScroll, arguments)    },    scrollToElement () {      this.bScroll && this.bScroll.scrollToElement.apply(this.bScroll, arguments)    }  },  watch: {    data () {      setTimeout(() => {        this.refresh()      }, this.refreshDelay)    }  }}</script><style lang="less">  .scroll-view {    height: 100%;    overflow: hidden;  }</style>

3. Animate.css动画库引入使用

 yarn add animate.css

main.js引入

import animated from 'animate.css'Vue.use(animated)

页面使用示例:

<template>  <transition    enter-active-class="animated fadeIn"    leave-active-class="animated fadeOut"  >    <div class="loading" v-if="show">      <div></div>      <div></div>      <div></div>      <div></div>      <div></div>      <span>{{title}}</span>    </div>  </transition></template>

注意:不要忘记v-if,不然看不出效果的哦!

5. loading加载动画

<template>  <transition    enter-active-class="animated fadeIn"    leave-active-class="animated fadeOut"  >    <div class="loading" v-if="show">      <div></div>      <div></div>      <div></div>      <div></div>      <div></div>      <span>{{title}}</span>    </div>  </transition></template><script>export default {  name: 'Loading',  props: {    title: {      type: String,      default: '拼命加载中...'    },    show: {      type: Boolean,      default: false    }  }}</script><style lang="less">@import "~assets/style/variable";.loading {  height: 10px;  width: 120px;  margin: auto;  text-align: center;  font-size: 10px;  padding: 10px 0;  > div {    display: inline-block;    background-color: var(--theme-bg-color);    height: 100%;    width: 2px;    margin-right: 4px;    animation: Dance 1s infinite;    &:nth-child(2) {      animation-delay: -0.4s;    }    &:nth-child(3) {      animation-delay: -0.6s;    }    &:nth-child(4) {      animation-delay: -0.5s;    }    &:nth-child(5) {      animation-delay: -0.2s;    }  }}@keyframes Dance {  0%,  40%,  100% {    transform: scaleY(0.4);    transform-origin: center 100%;  }  20% {    transform: scaleY(1.2);  }}</style>

6. 歌词滚动

使用的是lyric-parser插件,

  • 插件Api
  • 播放歌词 play()
  • 暂停歌词 stop()
  • 歌词跳转 seek(startTime)
  • 切换歌词播放/暂停状态 togglePlay()
import Lyric from 'lyric-parser'<script>export default {  data () {    return {      currentLyric: null, // 歌词      currentLineNum: 0 // 词行    }  },  methods: {    // 获取歌词    getLyric () {      api.getLyric().then(lyric => {        ...        this.currentLyric = new Lyric(lyric, this.handleLyric)        ...      })    },    // Lyric插件的回调    handleLyric ({ lineNum, txt }) {      console.log('歌词', lineNum, txt)      this.currentLineNum = lineNum      if (lineNum > 5) {        let lineEl = this.$refs.lyricLine[lineNum - 5]        this.$refs.lyricList.scrollToElement(lineEl, 1000) // 滚动到元素      } else {        this.$refs.lyricList.scrollTo(0, 0, 1000) // 滚动到顶部      }    }  }}</script>

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap