diff --git a/packages/api/app.js b/packages/api/app.js
index 2eaec497..4ac4764e 100644
--- a/packages/api/app.js
+++ b/packages/api/app.js
@@ -26,7 +26,7 @@ app.use((req, res, next) => {
// cookie parser
app.use((req, res, next) => {
req.cookies = {}
- ;(req.headers.cookie || '').split(/\s*;\s*/).forEach(pair => {
+ ;(req.headers.cookie || '').split(/\s*;\s*/).forEach((pair) => {
let crack = pair.indexOf('=')
if (crack < 1 || crack == pair.length - 1) return
req.cookies[
@@ -56,7 +56,7 @@ const special = {
fs.readdirSync(path.join(__dirname, 'module'))
.reverse()
- .forEach(file => {
+ .forEach((file) => {
if (!file.endsWith('.js')) return
let route =
file in special
@@ -77,12 +77,12 @@ fs.readdirSync(path.join(__dirname, 'module'))
)
question(query, request)
- .then(answer => {
+ .then((answer) => {
console.log('[OK]', decodeURIComponent(req.originalUrl))
res.append('Set-Cookie', answer.cookie)
res.status(answer.status).send(answer.body)
})
- .catch(answer => {
+ .catch((answer) => {
console.log('[ERR]', decodeURIComponent(req.originalUrl), {
status: answer.status,
body: answer.body,
diff --git a/packages/api/module/song_url.js b/packages/api/module/song_url.js
index 26631659..8d2e2b2f 100644
--- a/packages/api/module/song_url.js
+++ b/packages/api/module/song_url.js
@@ -1,7 +1,28 @@
// 歌曲链接
+// 从 packages/unblock 中解析网易云音乐ID的播放链接,突破灰色歌曲限制
+const match = require('@nondanee/unblockneteasemusic')
const crypto = require('crypto')
+const find = async (id) => {
+ await match(id, [
+ 'qq',
+ // 'xiami',
+ // 'baidu',
+ 'kugou',
+ 'kuwo',
+ // 'joox',
+ // 'youtube',
+ 'migu',
+ ])
+ .then((url) => {
+ return url.url
+ })
+ .catch((e) => {
+ return ''
+ })
+}
+
module.exports = (query, request) => {
if (!('MUSIC_U' in query.cookie))
query.cookie._ntes_nuid = crypto.randomBytes(16).toString('hex')
@@ -22,4 +43,22 @@ module.exports = (query, request) => {
url: '/api/song/enhance/player/url',
},
)
+ .then(async (v) => {
+ const { body } = v
+ let i = 0
+ while (i < body.data.length) {
+ if (!body.data[i].url) {
+ const url = await find(body.data[i].id)
+ v.body.data[i].url = url
+ }
+ i++
+ }
+ return v
+ })
+ .catch((e) => {
+ return {
+ status: 500,
+ body: e,
+ }
+ })
}
diff --git a/packages/api/package.json b/packages/api/package.json
index b9faa4b7..355ddd93 100644
--- a/packages/api/package.json
+++ b/packages/api/package.json
@@ -45,7 +45,8 @@
"express": "^4.17.1",
"express-fileupload": "^1.1.9",
"pac-proxy-agent": "^4.0.0",
- "tunnel": "^0.0.6"
+ "tunnel": "^0.0.6",
+ "@nondanee/unblockneteasemusic": "file:../unblock"
},
"devDependencies": {
"@types/node": "14.11.10",
diff --git a/packages/unblock/src/provider/match.js b/packages/unblock/src/provider/match.js
index f690bc0e..f7499ffd 100644
--- a/packages/unblock/src/provider/match.js
+++ b/packages/unblock/src/provider/match.js
@@ -32,7 +32,6 @@ const match = (id, source) => {
.then(songs => {
songs = songs.filter(song => song.url)
if (!songs.length) return Promise.reject()
- console.log(`[${meta.id}] ${meta.name}\n${songs[0].url}`)
return songs[0]
})
}
diff --git a/src/components/table/index.tsx b/src/components/table/index.tsx
index c05abe27..0f763403 100644
--- a/src/components/table/index.tsx
+++ b/src/components/table/index.tsx
@@ -40,6 +40,7 @@ export const Table = defineComponent({
{
useMutations(FooterMutations.PAUES_MUSIC)
- useActions(FooterActions.SET_MUSIC, item.id)
+ useActions(FooterActions.SET_MUSIC, {
+ url: item.url,
+ id: item.id
+ })
}
const trigger = () => {
diff --git a/src/pages/footer/sage.ts b/src/pages/footer/sage.ts
index de518b36..a49a6846 100644
--- a/src/pages/footer/sage.ts
+++ b/src/pages/footer/sage.ts
@@ -140,20 +140,24 @@ export const getters: GetterTree = {
}
export const actions: ActionTree = {
- async [FooterActions.SET_MUSIC]({ state, dispatch, commit }, id: number) {
- const data = await getSongUrl(id)
- if (state.sourceElement && state.audioElement) {
- if (data.length) {
- const url =
- data[0].url ||
- `https://music.163.com/song/media/outer/url?id=${id}.mp3`
- state.musicUrl = url
- commit(FooterMutations.CAN_PLAY, false)
- await dispatch(FooterActions.SET_MUSIC_DEFAILT, id)
- await dispatch(FooterActions.SET_MUSIC_LYRICS, id)
- commit(FooterMutations.SET_MUSIC_URL, url)
- }
+ async [FooterActions.SET_MUSIC](
+ { state, dispatch, commit },
+ payload: number | { url: string; id: number }
+ ) {
+ let id, url
+ if (typeof payload === 'number') {
+ const data = await getSongUrl(payload)
+ id = payload
+ url = data[0].url
+ } else {
+ id = payload.id
+ url = payload.url
}
+ state.musicUrl = url
+ commit(FooterMutations.CAN_PLAY, false)
+ await dispatch(FooterActions.SET_MUSIC_DEFAILT, id)
+ await dispatch(FooterActions.SET_MUSIC_LYRICS, id)
+ commit(FooterMutations.SET_MUSIC_URL, url)
},
async [FooterActions.SET_MUSIC_DEFAILT]({ state }, id: number | number[]) {
const data = await getSongDetail(id)
diff --git a/src/pages/song/view/index.less b/src/pages/song/view/index.less
index c94688a9..bbdecdc6 100644
--- a/src/pages/song/view/index.less
+++ b/src/pages/song/view/index.less
@@ -9,7 +9,7 @@
display: flex;
padding: 10px;
&--coverimg {
- width: 180px;
+ width: 210px;
height: 210px;
margin-right: 20px;
border-radius: 4px;
diff --git a/src/pages/song/view/index.tsx b/src/pages/song/view/index.tsx
index af1d3ce9..233e4b2d 100644
--- a/src/pages/song/view/index.tsx
+++ b/src/pages/song/view/index.tsx
@@ -18,11 +18,27 @@ import { RouterLink } from 'vue-router'
const renderClass = (name: string) => `song-list-${name}`
const columns = [
+ {
+ width: 80,
+ align: 'center',
+ customRender: ({ index }: { index: number }) => (
+ {++index < 10 ? '0' + index : index}
+ )
+ },
{
title: '音乐标题',
- dataIndex: 'name',
- key: 'name',
- ellipsis: true
+ ellipsis: true,
+ customRender: ({ text }: { text: Tracks }) => {
+ return (
+
+ {text.name}
+
+ )
+ }
},
{
title: '歌手',
@@ -83,12 +99,9 @@ export default defineComponent({
const tracksDetail = await getSongUrl(tracks.map(item => item.id))
const stack = tracks.map(item => {
const urlItem = tracksDetail.find(o => o.id === item.id)
- const url = urlItem
- ? urlItem.url
- : ` https://music.163.com/song/media/outer/url?${item.id}=id.mp3`
return {
...item,
- url: url
+ url: urlItem?.url
}
})
footerStore.useMutations(FooterMutations.SET_PLAYLIST_TO_STACK, stack)
@@ -96,7 +109,10 @@ export default defineComponent({
const { music } = footerStore.useState()
if (music?.id !== stack[0].id) {
footerStore.useMutations(FooterMutations.PAUES_MUSIC)
- await footerStore.useActions(FooterActions.SET_MUSIC, stack[0].id)
+ await footerStore.useActions(FooterActions.SET_MUSIC, {
+ id: stack[0].id,
+ url: stack[0].url
+ })
footerStore.useMutations(FooterMutations.PLAY_MUSIC)
}
}
diff --git a/src/theme/cover.less b/src/theme/cover.less
index 49cd691e..9efe541e 100644
--- a/src/theme/cover.less
+++ b/src/theme/cover.less
@@ -26,3 +26,15 @@ li {
button.easy-button-text {
color: #1890ff !important;
}
+
+.ant-table-body {
+ font-size: 13px;
+}
+
+.ant-table-row-cell-ellipsis {
+ > div {
+ width: 100%;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+}
diff --git a/src/utils/http.ts b/src/utils/http.ts
index e8404d90..1e2f5069 100644
--- a/src/utils/http.ts
+++ b/src/utils/http.ts
@@ -20,7 +20,7 @@ const baseURL =
const http: AxiosInstance = Axios.create({
baseURL: baseURL,
- timeout: 5000
+ timeout: 20000
})
http.interceptors.request.use(