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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | const song = { state: { isPlay: false, // 播放状态 playButtonUrl: '#icon-bofang', // 播放状态的图标 id: null, // 音乐ID url: '', // 歌曲URL duration: 0, // 音乐时长 curTime: 0, // 当前音乐的播放位置 changeTime: 0, // 指定播放时刻 title: '', // 歌名 artist: '', // 歌手名 picUrl: '', // 歌曲图片 autoNext: true, // 用于触发自动播放下一首 lyric: [], // 未处理的歌词数据 listOfSongs: [], // 当前歌单列表 tempList: {}, // 单个歌单信息 listIndex: null, // 当前歌曲在歌曲列表的位置 voiceSize: 0 // 音量大小 }, getters: { isPlay: state => state.isPlay, playButtonUrl: state => { let playButtonUrl = state.playButtonUrl if (!playButtonUrl) { playButtonUrl = JSON.parse(window.sessionStorage.getItem('playButtonUrl') || null) } return playButtonUrl }, id: state => { let id = state.id if (!id) { id = JSON.parse(window.sessionStorage.getItem('id') || null) } return id }, url: state => { let url = state.url if (!url) { url = JSON.parse(window.sessionStorage.getItem('url') || null) } return url }, duration: state => { let duration = state.duration if (!duration) { duration = JSON.parse(window.sessionStorage.getItem('duration') || null) } return duration }, curTime: state => { let curTime = state.curTime if (!curTime) { curTime = JSON.parse(window.sessionStorage.getItem('curTime') || null) } return curTime }, changeTime: state => { let changeTime = state.changeTime if (!changeTime) { changeTime = JSON.parse(window.sessionStorage.getItem('changeTime') || null) } return changeTime }, title: state => { let title = state.title if (!title) { title = JSON.parse(window.sessionStorage.getItem('title') || null) } return title }, artist: state => { let artist = state.artist if (!artist) { artist = JSON.parse(window.sessionStorage.getItem('artist') || null) } return artist }, picUrl: state => { let picUrl = state.picUrl if (!picUrl) { picUrl = JSON.parse(window.sessionStorage.getItem('picUrl')) || 'http://172.29.4.184:8080/img/tubiao.jpg' } return picUrl }, autoNext: state => { let autoNext = state.autoNext if (!autoNext) { autoNext = JSON.parse(window.sessionStorage.getItem('autoNext') || null) } return autoNext }, lyric: state => { let lyric = state.lyric if (lyric.length === 0) { lyric = JSON.parse(window.sessionStorage.getItem('lyric') || null) } return lyric }, tempList: state => { let tempList = state.tempList if (JSON.stringify(tempList) === '{}') { tempList = JSON.parse(window.sessionStorage.getItem('tempList') || null) } return tempList }, listOfSongs: state => { let listOfSongs = state.listOfSongs if (!listOfSongs.length) { listOfSongs = JSON.parse(window.sessionStorage.getItem('listOfSongs') || null) } return listOfSongs }, listIndex: state => { let listIndex = state.listIndex if (!listIndex) { listIndex = JSON.parse(window.sessionStorage.getItem('listIndex') || null) } return listIndex }, voiceSize: state => { let voiceSize = state.voiceSize if (!voiceSize) { voiceSize = JSON.parse(window.sessionStorage.getItem('voiceSize') || null) } return voiceSize } }, mutations: { setIsPlay: (state, isPlay) => { state.isPlay = isPlay window.sessionStorage.setItem('isPlay', JSON.stringify(isPlay)) }, setPlayButtonUrl: (state, playButtonUrl) => { state.playButtonUrl = playButtonUrl window.sessionStorage.setItem('playButtonUrl', JSON.stringify(playButtonUrl)) }, setId: (state, id) => { state.id = id window.sessionStorage.setItem('id', JSON.stringify(id)) }, setUrl: (state, url) => { state.url = url window.sessionStorage.setItem('url', JSON.stringify(url)) }, setDuration: (state, duration) => { state.duration = duration window.sessionStorage.setItem('duration', JSON.stringify(duration)) }, setCurTime: (state, curTime) => { state.curTime = curTime window.sessionStorage.setItem('curTime', JSON.stringify(curTime)) }, setChangeTime: (state, changeTime) => { state.changeTime = changeTime window.sessionStorage.setItem('changeTime', JSON.stringify(changeTime)) }, setTitle: (state, title) => { state.title = title window.sessionStorage.setItem('title', JSON.stringify(title)) }, setArtist: (state, artist) => { state.artist = artist window.sessionStorage.setItem('artist', JSON.stringify(artist)) }, setpicUrl: (state, picUrl) => { state.picUrl = picUrl window.sessionStorage.setItem('picUrl', JSON.stringify(picUrl)) }, setAutoNext: (state, autoNext) => { state.autoNext = autoNext window.sessionStorage.setItem('autoNext', JSON.stringify(autoNext)) }, setLyric: (state, lyric) => { state.lyric = lyric window.sessionStorage.setItem('lyric', JSON.stringify(lyric)) }, setTempList: (state, tempList) => { state.tempList = tempList window.sessionStorage.setItem('tempList', JSON.stringify(tempList)) }, setListOfSongs: (state, listOfSongs) => { state.listOfSongs = listOfSongs window.sessionStorage.setItem('listOfSongs', JSON.stringify(listOfSongs)) }, setListIndex: (state, listIndex) => { state.listIndex = listIndex window.sessionStorage.setItem('listIndex', JSON.stringify(listIndex)) }, setVoiceSize: (state, voiceSize) => { state.voiceSize = voiceSize window.sessionStorage.setItem('voiceSize', JSON.stringify(voiceSize)) } }, actions: {} } export default song |