Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_47285076
NeteaseCloudMusicApi_nicole-n
提交
7f5953ed
N
NeteaseCloudMusicApi_nicole-n
项目概览
weixin_47285076
/
NeteaseCloudMusicApi_nicole-n
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
NeteaseCloudMusicApi_nicole-n
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
7f5953ed
编写于
2月 05, 2021
作者:
B
binaryify
提交者:
GitHub
2月 05, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1116 from MuBeiSAMA/master
feat: Batch upload
上级
d6426267
282c19dc
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
71 addition
and
48 deletion
+71
-48
public/cloud.html
public/cloud.html
+71
-48
未找到文件。
public/cloud.html
浏览文件 @
7f5953ed
<!DOCTYPE html>
<html
lang=
"zh"
>
<head>
<head>
<meta
charset=
"UTF-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<title>
云盘上传
</title>
</head>
</head>
<body>
<input
id=
"file"
type=
"file"
accept=
"audio/mpeg"
/>
<body>
<input
id=
"file"
type=
"file"
multiple
/>
<script
src=
"https://cdn.bootcdn.net/ajax/libs/axios/0.20.0-0/axios.min.js"
></script>
<script>
const
phone
=
''
const
password
=
''
const
phone
=
''
// 这里填手机号
const
password
=
''
// 这里填密码
const
fileUpdateTime
=
{}
let
fileLength
=
0
let
cookieToken
=
''
if
(
!
phone
||
!
password
)
{
const
msg
=
'
请设置你的手机号码和密码
'
...
...
@@ -24,32 +26,53 @@
main
()
async
function
login
()
{
const
res
=
await
axios
({
url
:
`/login/cellphone?phone=
${
phone
}
&password=
${
password
}
`
,
url
:
`/login/cellphone?phone=
${
phone
}
&password=
${
encodeURIComponent
(
password
)
}
`
,
withCredentials
:
true
,
//关键
})
cookieToken
=
res
.
data
.
cookie
}
async
function
main
()
{
function
main
()
{
document
.
querySelector
(
'
input[type="file"]
'
)
.
addEventListener
(
'
change
'
,
function
(
e
)
{
var
file
=
this
.
files
[
0
]
upload
(
file
)
console
.
log
(
this
.
files
)
let
currentIndx
=
0
fileLength
=
this
.
files
.
length
for
(
const
item
of
this
.
files
)
{
currentIndx
+=
1
upload
(
item
,
currentIndx
)
}
})
}
async
function
upload
(
file
)
{
function
upload
(
file
,
currentIndx
)
{
var
formData
=
new
FormData
()
formData
.
append
(
'
songFile
'
,
file
)
const
res
=
await
axios
({
axios
({
method
:
'
post
'
,
url
:
`http://localhost:3000/cloud?time=
${
Date
.
now
()}
`
,
headers
:
{
'
Content-Type
'
:
'
multipart/form-data
'
,
},
data
:
formData
,
}).
then
(
res
=>
{
console
.
log
(
`
${
file
.
name
}
上传成功`
)
if
(
currentIndx
>=
fileLength
)
{
console
.
log
(
'
上传完毕
'
)
}
}).
catch
(
async
err
=>
{
console
.
log
(
err
)
console
.
log
(
fileUpdateTime
)
fileUpdateTime
[
file
.
name
]
?
fileUpdateTime
[
file
.
name
]
+=
1
:
fileUpdateTime
[
file
.
name
]
=
1
if
(
fileUpdateTime
[
file
.
name
]
>=
4
)
{
console
.
error
(
`丢,这首歌怎么都传不上:
${
file
.
name
}
`
)
return
}
else
{
console
.
error
(
`
${
file
.
name
}
失败
${
fileUpdateTime
[
file
.
name
]}
次`
)
}
await
login
()
upload
(
file
,
currentIndx
)
})
}
</script>
</body>
</body>
</html>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录