Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JM_network_test
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
JM_network_test
Commits
88ae8435
Commit
88ae8435
authored
Oct 26, 2021
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: xhr调试
parent
ba5b918c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
12 deletions
+36
-12
play.component.html
src/app/play/play.component.html
+0
-2
play.component.ts
src/app/play/play.component.ts
+34
-8
index.html
src/index.html
+2
-2
No files found.
src/app/play/play.component.html
View file @
88ae8435
...
@@ -14,8 +14,6 @@
...
@@ -14,8 +14,6 @@
</div>
</div>
<input
type=
"file"
value=
"请选择文件"
/>
<form
method=
"POST"
[
action
]="
uploadUrl
"
></form>
<!-- <div style="position: absolute; top: 0">
<!-- <div style="position: absolute; top: 0">
<label style="font-family: Aileron-Black;"></label>
<label style="font-family: Aileron-Black;"></label>
...
...
src/app/play/play.component.ts
View file @
88ae8435
...
@@ -745,7 +745,7 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -745,7 +745,7 @@ export class PlayComponent implements OnInit, OnDestroy {
}
}
const
startTime
=
new
Date
().
getTime
();
const
startTime
=
new
Date
().
getTime
();
greadPapersForCheck
({
type
:
'
pos
'
,
blankWord
:
'
NN
'
,
word
:
'
apple
'
},
res
=>
{
greadPapersForCheck
({
type
:
'
VB
'
,
blankWord
:
'
apple
'
,
word
:
'
apple
'
},
res
=>
{
// res 需要toJSON
// res 需要toJSON
const
endTime
=
new
Date
().
getTime
();
const
endTime
=
new
Date
().
getTime
();
const
durTime
=
endTime
-
startTime
;
const
durTime
=
endTime
-
startTime
;
...
@@ -799,15 +799,39 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -799,15 +799,39 @@ export class PlayComponent implements OnInit, OnDestroy {
url2Blob
(
url
)
{
url2Blob
(
url
)
{
return
new
Promise
(
resolve
=>
{
return
new
Promise
(
resolve
=>
{
console
.
log
(
'
in url2Blob ..
'
)
console
.
log
(
'
url:
'
,
url
);
var
xhr
=
new
XMLHttpRequest
();
var
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
'
get
'
,
url
,
true
);
xhr
.
open
(
'
get
'
,
url
,
true
);
xhr
.
responseType
=
'
blob
'
;
xhr
.
responseType
=
'
arraybuffer
'
;
xhr
.
onload
=
()
=>
{
// xhr.onload = () => {
if
(
xhr
.
status
==
200
)
{
// console.log(' in url2Blob load end..')
// if (xhr.status == 200) {
// console.log(xhr.response);
// console.log(xhr.response);
// resolve(xhr.response);
// }
// };
xhr
.
onreadystatechange
=
()
=>
{
if
(
xhr
.
readyState
!==
4
)
{
return
;
}
const
status
=
xhr
.
status
;
console
.
log
(
'
status:
'
,
status
);
if
((
status
>=
200
&&
status
<
300
)
||
status
===
304
)
{
console
.
log
(
'
request success
'
);
console
.
log
(
xhr
.
response
);
resolve
(
xhr
.
response
);
resolve
(
xhr
.
response
);
}
else
{
console
.
log
(
'
request error
'
);
console
.
log
(
'
xhr.response:
'
,
xhr
.
response
);
}
}
};
};
xhr
.
send
();
xhr
.
send
();
...
@@ -817,14 +841,16 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -817,14 +841,16 @@ export class PlayComponent implements OnInit, OnDestroy {
uploadTestAudio
(
text
,
url
,
key
)
{
uploadTestAudio
(
text
,
url
,
key
)
{
console
.
log
(
'
in uploadTestAudio 111
'
);
this
.
url2Blob
(
url
).
then
((
res
)
=>
{
this
.
url2Blob
(
url
).
then
((
buffer
)
=>
{
console
.
log
(
'
res:
'
,
res
);
console
.
log
(
'
res:
'
,
buffer
);
const
startTime
=
new
Date
().
getTime
();
const
startTime
=
new
Date
().
getTime
();
const
blob
=
res
//new Blob([u8arr], {type: mime});
const
blob
=
new
Blob
([
<
ArrayBuffer
>
buffer
],
{
type
:
"
audio/mpeg
"
});
// const blob = res //new Blob([u8arr], {type: mime});
const
fd
=
new
FormData
();
const
fd
=
new
FormData
();
fd
.
append
(
"
file
"
,
<
Blob
>
blob
,
'
test_audio.mp3
'
);
fd
.
append
(
"
file
"
,
<
Blob
>
blob
,
'
test_audio.mp3
'
);
this
.
http
.
post
(
this
.
uploadUrl
,
fd
).
subscribe
((
res
)
=>
{
this
.
http
.
post
(
this
.
uploadUrl
,
fd
).
subscribe
((
res
)
=>
{
...
...
src/index.html
View file @
88ae8435
...
@@ -9,12 +9,12 @@
...
@@ -9,12 +9,12 @@
<link
rel=
"icon"
type=
"image/x-icon"
href=
"favicon.ico"
>
<link
rel=
"icon"
type=
"image/x-icon"
href=
"favicon.ico"
>
<script
type=
"text/javascript"
src=
"https://staging-teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air_online_open.js"
></script>
<script
type=
"text/javascript"
src=
"https://staging-teach.cdn.ireadabc.com/h5template/h5-static-lib/js/air_online_open.js"
></script>
<
!-- <
script src="https://cdn.bootcdn.net/ajax/libs/vConsole/3.9.0/vconsole.min.js"></script>
<script
src=
"https://cdn.bootcdn.net/ajax/libs/vConsole/3.9.0/vconsole.min.js"
></script>
<script>
<script>
// init vConsole
// init vConsole
var
vConsole
=
new
VConsole
();
var
vConsole
=
new
VConsole
();
console
.
log
(
'
Hello world
'
);
console
.
log
(
'
Hello world
'
);
</script>
-->
</script>
</head>
</head>
<body>
<body>
<app-root></app-root>
<app-root></app-root>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment