ShowLyrics.vue 3.2 KB
Newer Older
Z
Zachary 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
<template>
  <div
    class="js_search_tab_cont search_tab_cont"
    id="lyric_box"
    style="display: block"
  >
    <div class="mod_lyric_list">
      <ul class="lyric_list__list">
        <li class="lyric_list__item" v-for="lyric in lyrics" :key="lyric.id">
          <h3 class="lyric_list__tit">
            <a title="">{{ lyric.name }}</a>

            <a class="singer_name" :title="lyric.artistsText">{{
              lyric.artistsText
            }}</a>
          </h3>
          <h4 class="lyric_list__album">
            <a class="album_name" :title="lyric.albumName">{{
              lyric.albumName
            }}</a>
          </h4>
          <div class="lyric_list__cont" :class="lyric.class">
            <div v-html="processLyric(lyric.lyrics)"></div>
          </div>
          <div class="lyric_list__toolbar">
            <button class="mod_btn js_clip" @click="moreLyric(lyric)">
              <i class="mod_btn__icon_more"></i>
              {{ lyric.class ? "收起" : "展开" }}
            </button>
            <button
              class="mod_btn js_lyric_copy"
              :copy-content="lyric.lyrics"
              @click="copyLyric(lyric.lyrics)"
            >
              <i class="mod_btn__icon_copy"></i>复制歌词
            </button>
          </div>
        </li>
      </ul>
    </div>
    <black-tip :ifShow="ifShowTip" :tip="'复制成功'" />
  </div>
</template>

<script>
import BlackTip from "components/common/BlackTip";
import { copyText } from "common/utils";

export default {
  data() {
    return {
      ifShowTip: false,
    };
  },
  props: {
    lyrics: {
      type: Array,
      default: [],
    },
  },
  methods: {
    moreLyric(l) {
      l.class = l.class ? "" : "lyric_list__cont--max";
    },
    processLyric(lyrics) {
      return lyrics.join("<br/>");
    },
    copyLyric(lyrics) {
      let lyricText = lyrics.join(" ");
      copyText(lyricText);
      this.showTip("复制成功");
    },
    showTip(tip) {
      this.tip = tip;
      this.ifShowTip = true;
      if (this.tipTimer) clearTimeout(this.tipTimer);
      setTimeout(() => {
        this.ifShowTip = false;
      }, 1000);
    },
  },
  components: {
    BlackTip,
  },
};
</script>

<style scoped>
ul {
  margin: 0;
  padding: 0;
}
.mod_btn {
  border: 1px solid #c9c9c9;
  color: #000;
}
.mod_btn,
.mod_btn_green {
  background-color: #fff;
  border-radius: 2px;
  font-size: 14px;
  margin-right: 6px;
  padding: 0 23px;
  height: 38px;
  line-height: 38px;
  display: inline-block;
  white-space: nowrap;
  box-sizing: border-box;
  overflow: hidden;
}
.mod_btn__icon_new {
  width: 16px;
  height: 16px;
  background-position: 0 -180px;
}
.mod_btn__icon_copy {
  width: 16px;
  height: 14px;
  background-position: -40px -100px;
  vertical-align: -2px;
}
.mod_lyric_list {
  margin-top: -20px;
}
.lyric_list__item {
  position: relative;
  font-size: 14px;
  line-height: 28px;
  padding: 20px 0 20px;
  border-bottom: 1px solid #f7f7f7;
}
.lyric_list__album,
.lyric_list__tit {
  font-weight: 400;
}
.lyric_list__cont {
  height: 196px;
  overflow: hidden;
  color: #999;
}
.lyric_list__cont--max {
  height: initial;
}
.lyric_list__toolbar {
  margin-top: 10px;
}
</style>