Skip to content

Commit

Permalink
排行榜详情&windows托盘修复
Browse files Browse the repository at this point in the history
  • Loading branch information
sunzongzheng committed Dec 20, 2017
1 parent 3b26c8b commit 1590cda
Show file tree
Hide file tree
Showing 12 changed files with 384 additions and 170 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
- 歌曲[Api](https://github.com/sunzongzheng/musicAPI)涵盖网易云、QQ音乐、虾米
- 界面仿QQ音乐
- Mac > Windows > Linux都会逐步适配,移动端在计划中
- 登录、收藏、播放的流程基本没问题,可作为日用上班挂后台听歌程序
- 精力有限,需求不饱和都会逐步完善,有兴趣可赏个star静等完善与bug修复,期望的功能也可提issues
- [下载页](https://github.com/sunzongzheng/music/releases)
# 已完成
- QQ登录
- 云歌单
- 全屏歌词
- 状态栏歌词/播放控制
- Mac状态栏歌词/播放控制
![](demo/img1.png)
![](demo/img2.png)
# 已知Bug
- [ ] 部分网易云歌源只能播放55s
- [ ] 部分歌曲播放几秒后会自动换下一首,但歌曲信息未更新
- [x] 部分网易云歌源只能播放55s
- [x] 部分歌曲播放几秒后会自动换下一首,但歌曲信息未更新
# 计划
- [ ] 重构Api
- [x] 重构Api
- [ ] 移动端
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "player",
"version": "1.0.23",
"version": "1.0.25",
"author": "sunzongzheng <[email protected]>",
"description": "An electron-vue project",
"license": "CC0-1.0",
Expand Down
3 changes: 2 additions & 1 deletion src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ if (process.env.NODE_ENV !== 'development') {
}

let mainWindow
let appTray // 声明在外层 保证不会被垃圾回收 解决windows托盘图标会消失的问题
const winURL = process.env.NODE_ENV === 'development'
? `http://localhost:9080`
: `file://${__dirname}/index.html`

function initialTray(mainWindow) {
var trayIconPath = __static + '/images/logo_32.png'
let appTray = new Tray(trayIconPath)
appTray = new Tray(trayIconPath)

function toggleVisiable() {
var isVisible = mainWindow.isVisible()
Expand Down
1 change: 1 addition & 0 deletions src/main/ipcEvent/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default {
maximizable: false,
minimizable: false
})
this.loginWindow.setMenu(null) // 去掉windows linux下的Menu
this.initEvent()
},
// 初始化 事件
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ Vue.win = Vue.prototype.$win = remote.getGlobal('win')

Vue.store = Vue.prototype.$store = store

Vue.router = router

Vue.config.productionTip = false

Vue.ipc = Vue.prototype.$ipc = ipcRenderer
Expand Down
17 changes: 16 additions & 1 deletion src/renderer/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,22 @@ export default new Router({
{
path: '/rank',
name: 'rank',
component: require('@/view/rank/index.vue')
component: require('@/view/rank/index.vue'),
redirect: {
name: 'rank.main'
},
children: [
{
path: 'main',
name: 'rank.main',
component: require('@/view/rank/main/index.vue')
},
{
path: 'detail',
name: 'rank.detail',
component: require('@/view/rank/detail/index.vue')
}
]
}
]
}
Expand Down
14 changes: 14 additions & 0 deletions src/renderer/store/modules/rank.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Vue from 'vue'

export default {
namespaced: true,
state: {
info: null
},
mutations: {
update(state, val) {
for (let i in val)
state[i] = val[i]
}
}
}
26 changes: 26 additions & 0 deletions src/renderer/view/rank/detail/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { mapState, mapActions } from 'vuex'
import Vue from 'vue'

export default {
computed: {
...mapState('rank', ['info'])
},
methods: {
...mapActions('api', ['play']),
doPlay(item) {
this.$store.commit('c_playlist/update', this.info.list.map(item => {
item.source = 'netease'
return item
}))
this.play(item)
}
},
beforeRouteEnter(to, from, next) {
console.log(Vue.store.state.rank.info)
if (Vue.store.state.rank.info) {
next()
} else {
Vue.router.push({name: 'rank.main'})
}
}
}
135 changes: 135 additions & 0 deletions src/renderer/view/rank/detail/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<template>
<div :class="s.app">
<div :class="s.top">
<img :src="info.cover"/>
<div :class="s.right">
<span :class="s.name">{{info.name}}</span>
<p style="font-size: 12px">{{info.description}}</p>
<a :class="s.play" @click="doPlay(info.list[0])">立即播放</a>
<span :class="s.total">累计播放:{{info.playCount}}</span>
</div>
</div>
<el-table :data="info.list"
:class="s.table"
:row-class-name="s.row"
>
<el-table-column label="歌曲" :width="220">
<template scope="scope">
<div :class="s.nameItem">
<div :class="s.songName" :title="scope.row.name">{{scope.row.name}}</div>
<div :class="s.songControl">
<Icon type="item-play" @click.native="doPlay(scope.row)"></Icon>
<add-to-playlist :info="scope.row"></add-to-playlist>
</div>
</div>
</template>
</el-table-column>
<el-table-column label="歌手">
<template scope="scope">
{{scope.row.artists[0].name}}
</template>
</el-table-column>
<el-table-column prop="album.name" label="专辑">
<template scope="scope">
<span :class="s.album">{{scope.row.album.name}}</span>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script src="./index.js"></script>
<style lang="scss" module="s">
.app {
.top {
display: flex;
background-color: #FAFAFA;
padding: 26px;
$imgWidth: 135px;
& > img {
width: $imgWidth;
height: $imgWidth;
}
.right {
display: flex;
flex-direction: column;
padding-left: 16px;
width: calc(100% - #{$imgWidth});
position: relative;
.name {
font-size: 22px;
font-weight: bold;
}
.play {
position: absolute;
bottom: 2px;
left: 16px;
cursor: pointer;
display: flex;
width: 100px;
height: 22px;
justify-content: center;
align-items: center;
border-radius: 4px;
font-size: 14px;
background-color: #67C23A;
color: white;
transition: all .2s;
&:hover {
transition: all .2s;
opacity: .8;
}
}
.total {
position: absolute;
bottom: 0;
right: 0;
font-size: 12px;
color: gray;
}
}
}
.table {
width: 100%;
padding: 0 24px;
overflow-x: hidden;
.row {
&:hover {
.songControl {
display: inline-flex;
align-items: center;
}
}
}
.nameItem {
display: flex;
.songName {
width: 160px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding-left: 4px;
}
.songControl {
display: none;
width: 60px;
svg {
margin-left: 6px;
cursor: pointer;
}
}
}
.album {
display: block;
width: 200px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
:global {
.el-table__body-wrapper {
overflow-x: hidden;
}
}
}
}
</style>
Loading

0 comments on commit 1590cda

Please sign in to comment.