Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
middleLayer_for_njstar
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
middleLayer_for_njstar
Commits
dcb39598
Commit
dcb39598
authored
Aug 14, 2023
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat
parent
41985056
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
143 deletions
+89
-143
middleLayer.ts
assets/middleLayer_for_njstar/script/middleLayer.ts
+9
-44
supportToos.js
assets/middleLayer_for_njstar/script/supportToos.js
+80
-99
No files found.
assets/middleLayer_for_njstar/script/middleLayer.ts
View file @
dcb39598
...
@@ -279,16 +279,7 @@ export default class NewClass extends middleLayerBase {
...
@@ -279,16 +279,7 @@ export default class NewClass extends middleLayerBase {
}
}
async
getOnlineVersion
()
{
async
getOnlineVersion
()
{
let
platform
=
''
;
let
platform
=
'
web
'
;
if
(
cc
.
sys
.
isNative
&&
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
platform
=
'
ios
'
;
}
else
if
(
cc
.
sys
.
isNative
&&
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
)
{
platform
=
'
android
'
;
}
else
if
(
cc
.
sys
.
isNative
&&
cc
.
sys
.
os
==
cc
.
sys
.
OS_WINDOWS
)
{
platform
=
'
windows
'
;
}
else
{
platform
=
'
web
'
;
}
const
res
:
any
=
await
this
.
asyncCallNetworkApiGet
(
'
/api/application/v1/checkVersion
'
,
{
const
res
:
any
=
await
this
.
asyncCallNetworkApiGet
(
'
/api/application/v1/checkVersion
'
,
{
pkg_name
:
'
com.iplayabc.oxford.lite
'
,
pkg_name
:
'
com.iplayabc.oxford.lite
'
,
...
@@ -327,12 +318,7 @@ export default class NewClass extends middleLayerBase {
...
@@ -327,12 +318,7 @@ export default class NewClass extends middleLayerBase {
preloadAll
(
onProgress
,
onComplete
)
{
preloadAll
(
onProgress
,
onComplete
)
{
let
platform
=
"
web_desktop
"
;
let
platform
=
"
web_desktop
"
;
if
(
cc
.
sys
.
isNative
&&
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
platform
=
"
ios
"
;
}
if
(
cc
.
sys
.
isNative
&&
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
)
{
platform
=
"
android
"
;
}
this
.
callNetworkApiGet
(
`/api/syllabus/v1/allbundles`
,
{
orgid
:
this
.
ORG_ID
,
platform
},
(
datastr
)
=>
{
this
.
callNetworkApiGet
(
`/api/syllabus/v1/allbundles`
,
{
orgid
:
this
.
ORG_ID
,
platform
},
(
datastr
)
=>
{
const
data
=
JSON
.
parse
(
datastr
);
const
data
=
JSON
.
parse
(
datastr
);
this
.
batchPreloadScene
(
data
.
rows
,
[],
onProgress
,
onComplete
);
this
.
batchPreloadScene
(
data
.
rows
,
[],
onProgress
,
onComplete
);
...
@@ -706,20 +692,10 @@ export default class NewClass extends middleLayerBase {
...
@@ -706,20 +692,10 @@ export default class NewClass extends middleLayerBase {
const
templateBaseUrl
=
`
${
this
.
DOMAIN
}
h5template/
${
data
.
name
}
/v
${
data
.
last_version
}
`
;
const
templateBaseUrl
=
`
${
this
.
DOMAIN
}
h5template/
${
data
.
name
}
/v
${
data
.
last_version
}
`
;
this
.
getConfigInfo
(
templateBaseUrl
,
(
conf
)
=>
{
this
.
getConfigInfo
(
templateBaseUrl
,
(
conf
)
=>
{
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
sceneName
=
conf
.
android
.
sceneName
;
sceneName
=
conf
.
ios
.
sceneName
;
version
=
""
;
version
=
conf
.
ios
.
version
;
bondleUrl
=
`
${
templateBaseUrl
}
/web_desktop`
;
bondleUrl
=
`
${
templateBaseUrl
}
/ios/
${
conf
.
ios
.
sceneName
}
`
;
}
else
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
)
{
sceneName
=
conf
.
android
.
sceneName
;
version
=
conf
.
android
.
version
;
bondleUrl
=
`
${
templateBaseUrl
}
/android/
${
conf
.
android
.
sceneName
}
`
;
}
else
{
sceneName
=
conf
.
android
.
sceneName
;
version
=
""
;
bondleUrl
=
`
${
templateBaseUrl
}
/web_desktop`
;
}
this
.
loadBundle
(
sceneName
,
version
,
bondleUrl
,
()
=>
{
this
.
loadBundle
(
sceneName
,
version
,
bondleUrl
,
()
=>
{
cc
.
find
(
'
middleLayer/ram
'
).
active
=
bundleName
==
'
NJ_YouLeChang
'
;
cc
.
find
(
'
middleLayer/ram
'
).
active
=
bundleName
==
'
NJ_YouLeChang
'
;
cc
.
find
(
'
middleLayer/cross
'
).
active
=
(
bundleName
==
'
NJ_YouLeChang
'
&&
this
.
gameModel
==
'
cross
'
);
cc
.
find
(
'
middleLayer/cross
'
).
active
=
(
bundleName
==
'
NJ_YouLeChang
'
&&
this
.
gameModel
==
'
cross
'
);
...
@@ -741,20 +717,9 @@ export default class NewClass extends middleLayerBase {
...
@@ -741,20 +717,9 @@ export default class NewClass extends middleLayerBase {
let
sceneName
,
version
,
bondleUrl
=
""
;
let
sceneName
,
version
,
bondleUrl
=
""
;
const
templateBaseUrl
=
`
${
this
.
DOMAIN
}
h5template/
${
this
.
courseItem
.
template_name
}
/v
${
this
.
courseItem
.
last_version
}
`
;
const
templateBaseUrl
=
`
${
this
.
DOMAIN
}
h5template/
${
this
.
courseItem
.
template_name
}
/v
${
this
.
courseItem
.
last_version
}
`
;
this
.
getConfigInfo
(
templateBaseUrl
,
(
conf
)
=>
{
this
.
getConfigInfo
(
templateBaseUrl
,
(
conf
)
=>
{
sceneName
=
conf
.
android
.
sceneName
;
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
version
=
""
;
sceneName
=
conf
.
ios
.
sceneName
;
bondleUrl
=
`
${
templateBaseUrl
}
/web_desktop`
;
version
=
conf
.
ios
.
version
;
bondleUrl
=
`
${
templateBaseUrl
}
/ios/
${
conf
.
ios
.
sceneName
}
`
;
}
else
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
)
{
sceneName
=
conf
.
android
.
sceneName
;
version
=
conf
.
android
.
version
;
bondleUrl
=
`
${
templateBaseUrl
}
/android/
${
conf
.
ios
.
sceneName
}
`
;
}
else
{
sceneName
=
conf
.
android
.
sceneName
;
version
=
""
;
bondleUrl
=
`
${
templateBaseUrl
}
/web_desktop`
;
}
this
.
loadBundle
(
sceneName
,
version
,
bondleUrl
,
callback
);
this
.
loadBundle
(
sceneName
,
version
,
bondleUrl
,
callback
);
});
});
});
});
...
...
assets/middleLayer_for_njstar/script/supportToos.js
View file @
dcb39598
...
@@ -125,118 +125,99 @@ export function initRecorder() {
...
@@ -125,118 +125,99 @@ export function initRecorder() {
var
isSpeechToText
;
var
isSpeechToText
;
export
function
supportMethod
(
method
,
param
)
{
export
function
supportMethod
(
method
,
param
)
{
if
(
cc
.
sys
.
isNative
)
{
if
(
method
==
'
getEngineInfo
'
){
// 原生调用
window
.
air
.
getEngineInfoCallback
({
isDev
:
0
,
uuid
:
'
debug-njstar-xxxxxx
'
});
const
paramStr
=
JSON
.
stringify
(
param
);
}
else
if
(
method
==
'
startTest
'
)
{
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_IOS
)
{
// 初始化参数
return
jsb
.
reflection
.
callStaticMethod
(
'
RootViewController
'
,
`
${
method
}
:`
,
paramStr
);
initSkKouYuParms
(
param
.
params
,
'
para.eval
'
);
}
const
rec
=
getWebRecordInstanse
();
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_ANDROID
)
{
rec
.
start
();
return
jsb
.
reflection
.
callStaticMethod
(
'
com/iplayabc/cocos/AppActivity
'
,
method
,
'
(Ljava/lang/String;)Ljava/lang/String;
'
,
paramStr
);
}
else
if
(
method
==
'
stopTest
'
)
{
}
const
rec
=
getWebRecordInstanse
();
if
(
cc
.
sys
.
os
==
cc
.
sys
.
OS_WINDOWS
)
{
rec
.
stop
();
console
.
error
(
'
暂不支持此平台
'
);
rec
.
getBlob
(
async
(
blob
)
=>
{
const
maxAge
=
70
*
365
*
24
*
60
*
60
;
// 70年
const
now
=
Date
.
now
();
const
audioName
=
`
${
now
}
_
${
Math
.
random
().
toString
(
36
).
substr
(
2
)}
.mp3`
;
const
oss
=
await
getOssInstanse
();
await
oss
.
put
(
audioName
,
blob
,
{
'
Cache-Control
'
:
`max-age=
${
70
*
365
*
24
*
60
*
60
}
`
,
Expires
:
new
Date
(
now
+
maxAge
*
1000
).
toGMTString
(),
'
Last-Modified
'
:
new
Date
().
toGMTString
(),
'
Content-type
'
:
`audio/mpeg`
,
}
);
const
audioUrl
=
`
${
global
.
middleLayer
.
DOMAIN
}${
audioName
}
`
;
console
.
log
(
`上传的录音是:
${
audioUrl
}
`
);
const
formData
=
new
FormData
();
formData
.
append
(
'
audio
'
,
blob
);
formData
.
append
(
"
text
"
,
JSON
.
stringify
(
pubskyparms
));
var
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
"
post
"
,
baseUrl
+
'
para.eval
'
);
xhr
.
setRequestHeader
(
"
Request-Index
"
,
"
0
"
);
//Request-Index 固定为0
xhr
.
send
(
formData
);
xhr
.
onreadystatechange
=
function
()
{
if
(
xhr
.
readyState
==
4
&&
xhr
.
status
==
200
){
const
res
=
JSON
.
parse
(
xhr
.
responseText
);
window
.
air
.
testCallBack
({...
res
,
audioUrl
});
}
};
});
}
else
if
(
method
==
'
startRecord
'
)
{
isSpeechToText
=
param
.
isSpeechToText
;
// 初始化参数
if
(
isSpeechToText
==
1
)
{
initSkKouYuParms
(
""
,
'
asr.rec
'
);
}
}
}
else
if
(
cc
.
sys
.
isBrowser
)
{
const
rec
=
getWebRecordInstanse
();
if
(
method
==
'
getEngineInfo
'
){
rec
.
start
();
window
.
air
.
getEngineInfoCallback
({
isDev
:
0
,
uuid
:
'
debug-njstar-xxxxxx
'
});
}
else
if
(
method
==
'
stopRecord
'
)
{
}
else
if
(
method
==
'
startTest
'
)
{
const
rec
=
getWebRecordInstanse
();
// 初始化参数
rec
.
stop
();
initSkKouYuParms
(
param
.
params
,
'
para.eval
'
);
rec
.
getBlob
(
async
(
blob
)
=>
{
const
rec
=
getWebRecordInstanse
();
const
maxAge
=
70
*
365
*
24
*
60
*
60
;
// 70年
rec
.
start
();
const
now
=
Date
.
now
();
}
else
if
(
method
==
'
stopTest
'
)
{
const
audioName
=
`
${
now
}
_
${
Math
.
random
().
toString
(
36
).
substr
(
2
)}
.mp3`
;
const
rec
=
getWebRecordInstanse
();
const
oss
=
await
getOssInstanse
();
rec
.
stop
();
await
oss
.
put
(
rec
.
getBlob
(
async
(
blob
)
=>
{
audioName
,
const
maxAge
=
70
*
365
*
24
*
60
*
60
;
// 70年
blob
,
const
now
=
Date
.
now
();
{
const
audioName
=
`
${
now
}
_
${
Math
.
random
().
toString
(
36
).
substr
(
2
)}
.mp3`
;
'
Cache-Control
'
:
`max-age=
${
70
*
365
*
24
*
60
*
60
}
`
,
const
oss
=
await
getOssInstanse
();
Expires
:
new
Date
(
now
+
maxAge
*
1000
).
toGMTString
(),
await
oss
.
put
(
'
Last-Modified
'
:
new
Date
().
toGMTString
(),
audioName
,
'
Content-type
'
:
`audio/mpeg`
,
blob
,
}
{
);
'
Cache-Control
'
:
`max-age=
${
70
*
365
*
24
*
60
*
60
}
`
,
const
audioUrl
=
`
${
global
.
middleLayer
.
DOMAIN
}${
audioName
}
`
;
Expires
:
new
Date
(
now
+
maxAge
*
1000
).
toGMTString
(),
console
.
log
(
`上传的录音是:
${
audioUrl
}
`
);
'
Last-Modified
'
:
new
Date
().
toGMTString
(),
'
Content-type
'
:
`audio/mpeg`
,
}
);
const
audioUrl
=
`
${
global
.
middleLayer
.
DOMAIN
}${
audioName
}
`
;
console
.
log
(
`上传的录音是:
${
audioUrl
}
`
);
if
(
isSpeechToText
==
1
)
{
const
formData
=
new
FormData
();
const
formData
=
new
FormData
();
formData
.
append
(
'
audio
'
,
blob
);
formData
.
append
(
'
audio
'
,
blob
);
formData
.
append
(
"
text
"
,
JSON
.
stringify
(
pubskyparms
));
formData
.
append
(
"
text
"
,
JSON
.
stringify
(
pubskyparms
));
var
xhr
=
new
XMLHttpRequest
();
var
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
"
post
"
,
baseUrl
+
'
para.eval
'
);
xhr
.
open
(
"
post
"
,
baseUrl
+
'
asr.rec
'
);
xhr
.
setRequestHeader
(
"
Request-Index
"
,
"
0
"
);
//Request-Index 固定为0
xhr
.
setRequestHeader
(
"
Request-Index
"
,
"
0
"
);
//Request-Index 固定为0
xhr
.
send
(
formData
);
xhr
.
send
(
formData
);
xhr
.
onreadystatechange
=
function
()
{
xhr
.
onreadystatechange
=
function
()
{
if
(
xhr
.
readyState
==
4
&&
xhr
.
status
==
200
){
if
(
xhr
.
readyState
==
4
&&
xhr
.
status
==
200
){
const
res
=
JSON
.
parse
(
xhr
.
responseText
);
const
res
=
JSON
.
parse
(
xhr
.
responseText
);
window
.
air
.
testCallBack
({...
res
,
audioUrl
});
window
.
air
.
recordCallBack
({
text
:
res
.
result
.
recognition
,
audioUrl
,
...
res
});
isSpeechToText
=
0
;
}
}
};
};
});
}
else
{
}
else
if
(
method
==
'
startRecord
'
)
{
window
.
air
.
recordCallBack
({
audioUrl
});
isSpeechToText
=
param
.
isSpeechToText
;
// 初始化参数
if
(
isSpeechToText
==
1
)
{
initSkKouYuParms
(
""
,
'
asr.rec
'
);
}
}
const
rec
=
getWebRecordInstanse
();
});
rec
.
start
();
}
else
if
(
method
==
'
startBuyToAppStore
'
)
{
}
else
if
(
method
==
'
stopRecord
'
)
{
window
.
air
.
startBuyToAppStoreCallBack
({
productid
:
1
,
puid
:
22
,
receiptData
:
"
HelloWorld
"
,
error
:
""
});
const
rec
=
getWebRecordInstanse
();
}
else
{
rec
.
stop
();
console
.
error
(
`
${
method
}
方法还没有Mock数据,请联系技术支持人员添加`
);
rec
.
getBlob
(
async
(
blob
)
=>
{
const
maxAge
=
70
*
365
*
24
*
60
*
60
;
// 70年
const
now
=
Date
.
now
();
const
audioName
=
`
${
now
}
_
${
Math
.
random
().
toString
(
36
).
substr
(
2
)}
.mp3`
;
const
oss
=
await
getOssInstanse
();
await
oss
.
put
(
audioName
,
blob
,
{
'
Cache-Control
'
:
`max-age=
${
70
*
365
*
24
*
60
*
60
}
`
,
Expires
:
new
Date
(
now
+
maxAge
*
1000
).
toGMTString
(),
'
Last-Modified
'
:
new
Date
().
toGMTString
(),
'
Content-type
'
:
`audio/mpeg`
,
}
);
const
audioUrl
=
`
${
global
.
middleLayer
.
DOMAIN
}${
audioName
}
`
;
console
.
log
(
`上传的录音是:
${
audioUrl
}
`
);
if
(
isSpeechToText
==
1
)
{
const
formData
=
new
FormData
();
formData
.
append
(
'
audio
'
,
blob
);
formData
.
append
(
"
text
"
,
JSON
.
stringify
(
pubskyparms
));
var
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
"
post
"
,
baseUrl
+
'
asr.rec
'
);
xhr
.
setRequestHeader
(
"
Request-Index
"
,
"
0
"
);
//Request-Index 固定为0
xhr
.
send
(
formData
);
xhr
.
onreadystatechange
=
function
()
{
if
(
xhr
.
readyState
==
4
&&
xhr
.
status
==
200
){
const
res
=
JSON
.
parse
(
xhr
.
responseText
);
window
.
air
.
recordCallBack
({
text
:
res
.
result
.
recognition
,
audioUrl
,
...
res
});
isSpeechToText
=
0
;
}
};
}
else
{
window
.
air
.
recordCallBack
({
audioUrl
});
}
});
}
else
if
(
method
==
'
startBuyToAppStore
'
)
{
window
.
air
.
startBuyToAppStoreCallBack
({
productid
:
1
,
puid
:
22
,
receiptData
:
"
HelloWorld
"
,
error
:
""
});
}
else
{
console
.
error
(
`
${
method
}
方法还没有Mock数据,请联系技术支持人员添加`
);
}
}
else
{
// 其他环境
if
(
method
==
'
getEngineInfo
'
){
window
.
air
.
getEngineInfoCallback
({
isDev
:
1
,
uuid
:
'
debug-xxxxxx-xxxxxx
'
});
}
}
}
}
}
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