Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zacharyzlj
Yz Music
提交
a88a1a49
Y
Yz Music
项目概览
zacharyzlj
/
Yz Music
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
Yz Music
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a88a1a49
编写于
2月 24, 2021
作者:
Z
Zachary
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add song download and share func
上级
e71084e0
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
84 addition
and
8 deletion
+84
-8
Plan.md
Plan.md
+8
-2
demo/demo.gif
demo/demo.gif
+0
-0
src/api/song.js
src/api/song.js
+1
-1
src/components/common/ModListMenu.vue
src/components/common/ModListMenu.vue
+75
-2
src/views/musicLibrary/Ranking.vue
src/views/musicLibrary/Ranking.vue
+0
-3
未找到文件。
Plan.md
浏览文件 @
a88a1a49
...
@@ -27,11 +27,17 @@
...
@@ -27,11 +27,17 @@
7.
mv 列表页
7.
mv 列表页
-
[x] 无限滚动
-
[x] 无限滚动
-
[x] mv 详情播放页
-
[x] mv 详情播放页
8.
功能条
8.
大功能条
-
[x] 播放
-
收藏
-
收藏
-
分享
-
分享
-
添加
-
添加
9.
[x] 懒加载
9.
小功能条
-
[x] 播放
-
[x] 下载
-
[x] 分享
-
添加
10.
[x] 懒加载
-
[ ] 样式调整
-
[ ] 样式调整
-
[ ] 组件抽离
-
[ ] 组件抽离
demo/demo.gif
查看替换文件 @
e71084e0
浏览文件 @
a88a1a49
4.2 MB
|
W:
|
H:
4.7 MB
|
W:
|
H:
2-up
Swipe
Onion skin
src/api/song.js
浏览文件 @
a88a1a49
import
{
requset
}
from
"
./base
"
;
import
{
requset
}
from
"
./base
"
;
export
const
getSong
=
id
=>
requset
.
get
(
`/song/url?id=
${
id
}
`
);
export
const
getSong
Url
=
id
=>
requset
.
get
(
`/song/url?id=
${
id
}
`
);
export
const
getSongDetail
=
ids
=>
requset
.
get
(
`/song/detail?ids=
${
ids
}
`
);
export
const
getSongDetail
=
ids
=>
requset
.
get
(
`/song/detail?ids=
${
ids
}
`
);
...
...
src/components/common/ModListMenu.vue
浏览文件 @
a88a1a49
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
title=
"下载"
title=
"下载"
aria-haspopup=
"true"
aria-haspopup=
"true"
v-if=
"kind == 0"
v-if=
"kind == 0"
@
click=
"download(song.id)"
>
>
<i
class=
"list_menu__icon_down"
></i>
<i
class=
"list_menu__icon_down"
></i>
<span
class=
"icon_txt"
>
下载
</span>
<span
class=
"icon_txt"
>
下载
</span>
...
@@ -29,18 +30,27 @@
...
@@ -29,18 +30,27 @@
class=
"list_menu__item list_menu__share js_share"
class=
"list_menu__item list_menu__share js_share"
title=
"分享"
title=
"分享"
aria-haspopup=
"true"
aria-haspopup=
"true"
@
click=
"share"
>
>
<i
class=
"list_menu__icon_share"
></i>
<i
class=
"list_menu__icon_share"
></i>
<span
class=
"icon_txt"
>
分享
</span>
<span
class=
"icon_txt"
>
分享
</span>
</a>
</a>
</div>
</div>
<black-tip
:ifShow=
"true"
:tip=
"tip"
v-if=
"ifShow"
/>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
playTheSong
,
playSonglist
,
createSongs
}
from
"
common/utils
"
;
import
BlackTip
from
"
components/common/BlackTip
"
;
import
{
getPlaylistDetial
,
getSongDetail
,
getAlbum
}
from
"
api
"
;
import
{
playTheSong
,
playSonglist
,
createSongs
,
copyText
}
from
"
common/utils
"
;
import
{
getPlaylistDetial
,
getSongDetail
,
getAlbum
,
getSongUrl
}
from
"
api
"
;
export
default
{
export
default
{
data
()
{
return
{
ifShow
:
false
,
tip
:
""
,
};
},
props
:
{
props
:
{
song
:
{
song
:
{
type
:
Object
,
type
:
Object
,
...
@@ -87,6 +97,69 @@ export default {
...
@@ -87,6 +97,69 @@ export default {
playSonglist
(
songs
);
playSonglist
(
songs
);
});
});
},
},
share
()
{
switch
(
this
.
kind
)
{
case
0
:
this
.
tip
=
"
已复制歌曲链接
"
;
let
txt
=
this
.
song
.
url
;
copyText
(
txt
);
this
.
ifShow
=
true
;
if
(
this
.
timer
)
clearTimeout
(
this
.
timer
);
setTimeout
(()
=>
{
this
.
ifShow
=
false
;
},
1000
);
break
;
case
1
:
break
;
case
2
:
break
;
default
:
console
.
log
(
this
.
kind
);
}
},
download
(
id
)
{
getSongUrl
(
id
).
then
((
res
)
=>
{
console
.
log
(
res
);
let
url
=
res
.
data
.
data
[
0
].
url
;
this
.
downloadFile
(
url
);
//window.open(url, "_self");
});
},
downloadFile
(
url
)
{
url
=
url
.
replace
(
/
\\
/g
,
"
/
"
);
const
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
"
GET
"
,
url
,
true
);
xhr
.
responseType
=
"
blob
"
;
// 文件下载进度
xhr
.
onprogress
=
(
res
)
=>
{
this
.
loadingTip
=
"
源文件下载中:
"
+
((
res
.
loaded
/
res
.
total
)
*
100
).
toFixed
(
2
)
+
"
%
"
;
};
xhr
.
onload
=
()
=>
{
this
.
loadingTip
=
""
;
this
.
loading
=
false
;
if
(
xhr
.
status
===
200
)
{
// 获取文件blob数据并保存
var
num
=
url
.
lastIndexOf
(
"
/
"
)
+
1
;
//把参数和文件名分割开
var
fileName
=
url
.
substring
(
num
).
split
(
"
?
"
)[
0
];
var
export_blob
=
new
Blob
([
xhr
.
response
]);
var
save_link
=
document
.
createElementNS
(
"
http://www.w3.org/1999/xhtml
"
,
"
a
"
);
save_link
.
href
=
URL
.
createObjectURL
(
export_blob
);
save_link
.
download
=
fileName
;
save_link
.
click
();
}
};
this
.
loading
=
true
;
xhr
.
send
();
},
},
components
:
{
BlackTip
,
},
},
};
};
</
script
>
</
script
>
...
...
src/views/musicLibrary/Ranking.vue
浏览文件 @
a88a1a49
...
@@ -315,12 +315,9 @@ export default {
...
@@ -315,12 +315,9 @@ export default {
sortType
:
2
,
sortType
:
2
,
};
};
getCommentsNew
(
params
).
then
((
res
)
=>
{
getCommentsNew
(
params
).
then
((
res
)
=>
{
console
.
log
(
res
.
data
);
this
.
commentCount
=
this
.
commentCount
=
res
.
data
.
data
.
totalCount
>
5000
?
5000
:
res
.
data
.
data
.
totalCount
;
res
.
data
.
data
.
totalCount
>
5000
?
5000
:
res
.
data
.
data
.
totalCount
;
this
.
comments
=
res
.
data
.
data
.
comments
;
this
.
comments
=
res
.
data
.
data
.
comments
;
console
.
log
(
this
.
commentCount
);
console
.
log
(
this
.
comments
);
});
});
},
},
currentChange
(
v
)
{
currentChange
(
v
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录