Skip to content

Commit

Permalink
发吧V2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fengT-T committed Aug 13, 2018
1 parent 1a82e0e commit f7fad09
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 37 deletions.
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"scripts": {
"build": "node .electron-vue/build.js && electron-builder",
"build:dir": "node .electron-vue/build.js && electron-builder --dir",
"build:linux": "node .electron-vue/build.js && electron-builder -l dir deb AppImage pacman",
"build:mac": "node .electron-vue/build.js && electron-builder -m",
"build:win": "node .electron-vue/build.js && electron-builder -w",
"build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js",
"build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",
"dev": "node .electron-vue/dev-runner.js",
Expand Down Expand Up @@ -55,7 +58,14 @@
},
"linux": {
"icon": "build/icons",
"category": "AudioVideo;Player;Music;"
"category": "AudioVideo;Audio;Player;Music;"
},
"pacman": {
"depends": ["gconf", "libnotify", "nss", "libxss", "libappindicator-gtk3", "libxtst"]
},
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true
}
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function createWindow () {
* Initial window options
*/
mainWindow = new BrowserWindow({
height: 610,
height: 630, // 尤其是 有着1T 显存的 gt630 战术核显卡,只要一发就能摧毁一个航母战斗群。
useContentSize: true,
width: 1020,
autoHideMenuBar: false,
Expand Down
9 changes: 6 additions & 3 deletions src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ export default {

<style>
a:hover,a:active,a:visited,a:focus {
outline: none;
box-shadow: none;
text-decoration: none;
outline: none !important;
box-shadow: none !important;
text-decoration: none !important;
}
.tab {
border-bottom: none !important;
}
#app {
user-select: none;
Expand Down
6 changes: 4 additions & 2 deletions src/renderer/components/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<button class="btn btn-block" v-show="!isEnd" :class="{'loading': loading}"
@click="!isEnd && search(page + 1)">更多</button>
<div class="divider text-center" data-content="没有了" v-show="isEnd" ></div>
<div class="divider text-center" data-content="没有了" v-show="isEnd && songList.length" ></div>
</div>
</template>
<script>
Expand Down Expand Up @@ -70,5 +70,7 @@ export default {
position: relative;
top: 20px;
}
.btn-block {
margin-bottom: 30px;
}
</style>
69 changes: 44 additions & 25 deletions src/renderer/components/SingerList.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,49 @@
<template>
<div class="singer-list">
<div class="singer-type-list">
<div class="singer-country">

<div class="singer-type-item">
<button class="btn btn-link"
@click="selectCountry = code, getTheSingeList(1)"
v-for="(code, country) in singertypeList"
:key="code"
:disabled="code !== selectCountry && loading"
:class="{'active': code === selectCountry, 'loading': code === selectCountry && loading}" >
{{country}}
@click="selectTag.index = tag.id, getTheSingeList(1)"
v-for="tag in tagList.index"
:key="tag.id"
:disabled="tag.id !== selectTag.index && loading"
:class="{'active': tag.id === selectTag.index, 'loading': tag.id === selectTag.index && loading}" >
{{tag.name}}
</button>
</div>

<div class="singer-type-item d-inline-block">
<button class="btn btn-link"
@click="selectTag.area = tag.id, getTheSingeList(1)"
v-for="tag in tagList.area"
:key="tag.id"
:disabled="tag.id !== selectTag.area && loading"
:class="{'active': tag.id === selectTag.area, 'loading': tag.id === selectTag.area && loading}">
{{tag.name}}
</button>
</div>
<div class="singer-firstname">

<div class="singer-type-item d-inline-block">
<button class="btn btn-link"
@click="selectName = code, getTheSingeList(1)"
v-for="(code, name) in singerNameList"
:key="code"
:disabled="code !== selectName && loading"
:class="{'active': code === selectName, 'loading': code === selectName && loading}">
{{name}}
@click="selectTag.sex = tag.id, getTheSingeList(1)"
v-for="tag in tagList.sex"
:key="tag.id"
:disabled="tag.id !== selectTag.sex && loading"
:class="{'active': tag.id === selectTag.sex, 'loading': tag.id === selectTag.sex && loading}">
{{tag.name}}
</button>
</div>

<div class="singer-type-item">
<button class="btn btn-link"
@click="selectTag.genre = tag.id, getTheSingeList(1)"
v-for="tag in tagList.genre"
:key="tag.id"
:disabled="tag.id !== selectTag.genre && loading"
:class="{'active': tag.id === selectTag.genre, 'loading': tag.id === selectTag.genre && loading}">
{{tag.name}}
</button>
</div>
</div>

Expand All @@ -48,8 +68,8 @@
</template>
<script>
import singerAvatar from './SingerAvatar'
import { singertypeList, singerNameList } from './common/SingerList.js'
import {getSingerList} from '../../spider'
import {tag} from './common/SingerList.js'
import {getNewSingerList} from '../../spider'
import fPagination from './Pagination'
export default {
Expand All @@ -60,10 +80,10 @@ export default {
totalPage: 0,
page: 0,
loading: false,
singertypeList,
singerNameList,
selectCountry: 'all_all',
selectName: 'all'
tagList: tag,
selectTag: {
area: -100, sex: -100, genre: -100, index: -100
}
}
},
components: {
Expand All @@ -72,9 +92,8 @@ export default {
methods: {
async getTheSingeList (newPage) {
this.loading = true
let data = await getSingerList({
country: this.selectCountry,
name: this.selectName,
let data = await getNewSingerList({
...this.selectTag,
page: newPage
})
this.page = newPage
Expand All @@ -97,10 +116,10 @@ export default {
border-radius: 10%;
box-shadow: 4px 5px 7px 1px rgba(112,128,151,0.35);
}
.singer-type-list>.singer-country{
.singer-type-list:first-child{
margin-bottom: 3px;
}
.singer-type-list>.singer-firstname{
.singer-type-list>.singer-type-item{
margin-bottom: 5px;
}
.singer-type-list button{
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/components/SongList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
</div>
</transition-group>


<div class="music-location">
<transition name="right-show" mode="out-in">
<input class="form-input input-sm" v-model="musicFilter" v-show="showSearch" type="text" placeholder="过滤">
Expand Down Expand Up @@ -97,7 +96,7 @@ export default {
},
musicListFilter () {
return this.musicList.filter(music => {
this.musicFilter === 'miku' && (this.musicFilter = `初音`)
this.musicFilter === 'miku' && (this.musicFilter = `miku|初音`)
let reg = new RegExp(`${this.musicFilter}`)
const singerName = music.singerList.reduce((acc, singer) => acc + singer.singerName, '')
return reg.test(music.songName) || reg.test(singerName) || reg.test(music.album.albumName)
Expand Down
5 changes: 5 additions & 0 deletions src/renderer/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ export default new Router({
name: 'PlayList',
component: PlayList
},
{
path: '/',
name: 'default',
component: SingerList
},
{
path: '*',
name: 'default',
Expand Down
18 changes: 15 additions & 3 deletions src/spider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const cancelMap = {
getSingerAlbumList: null,
getSingerMvList: null,
getAlbum: null,
getPlayListInfo: null
getPlayListInfo: null,
getPlayList: null
}
/**
* c++ 天下第一,客户端,嵌入式,服务器都能做,老子这辈子就学他了。
Expand Down Expand Up @@ -68,7 +69,17 @@ export async function getSingerList ({page, country, name}) {
}
/* eslint-disable */
}

// 新列表 page >= 1
export async function getNewSingerList ({page, area, sex, genre, index}) {
let url = `https://u.y.qq.com/cgi-bin/musicu.fcg?g_tk=5381&loginUin=0&hostUin=0&format=jsonp&inCharset=utf8&outCharset=utf-8&notice=0&platform=yqq&needNewCode=0&data=${encodeURIComponent(`{"comm":{"ct":24,"cv":10000},"singerList":{"module":"Music.SingerListServer","method":"get_singer_list","param":{"area":${area},"sex":${sex},"genre":${genre},"index":${index},"sin":${(page - 1) * 80},"cur_page":${page}}}}`)}`
/* eslint-disable */
let {data: {singerlist, total}} = (await baseRequest(url)).data.singerList
return {
totalPage: Math.floor(total / 80),
singerList: singerlist.map(({singer_name, singer_mid}) => new Singer(singer_name, singer_mid))
}
/* eslint-disable */
}
// page 从 0 开始
export async function getSingerMusicList ({page, singerMid}) {
let source = cancelRequest('getSingerMusicList')
Expand Down Expand Up @@ -203,8 +214,9 @@ export async function getCategory () {
}

export async function getPlayList ({categoryId, page}) {
let source = cancelRequest('getPlayList')
let url = `https://c.y.qq.com/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg?picmid=1&g_tk=5381&loginUin=0&hostUin=0&format=jsonp&inCharset=utf8&outCharset=utf-8&notice=0&categoryId=${categoryId}&sortId=5&sin=${(page - 1) * 30}&ein=${page * 30 - 1}`
let {list, sum} = JSON.parse((await baseRequest(url)).data.slice(18, -1)).data
let {list, sum} = JSON.parse((await baseRequest(url, {cancelToken: source.token})).data.slice(18, -1)).data
return {
list: list.map(({dissname, imgurl, dissid}) => new PlayList(dissid, dissname, imgurl)),
totalPage: Math.ceil(sum / 40)
Expand Down
15 changes: 15 additions & 0 deletions test/unit/spider/NewSingerList.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const assert = require('assert')
const {getNewSingerList} = require('../../../src/spider/index')

describe('歌词', function () {
it('getNewSingerList', async function () {
let data = await getNewSingerList({
page: 1,
area: -100,
sex: -100,
genre: -100,
index: -100
})
assert(data.singerList.length === 80)
})
})

0 comments on commit f7fad09

Please sign in to comment.