Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
middleLayer_for_debug
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_debug
Commits
5d613c4c
Commit
5d613c4c
authored
Nov 16, 2021
by
huoshizhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 加载线上包
parent
b9b6e1f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
177 deletions
+71
-177
middleLayer_for_debug.fire
...ts/middleLayer_for_debug/scene/middleLayer_for_debug.fire
+5
-5
middleLayer.js
play/assets/middleLayer_for_debug/script/middleLayer.js
+65
-171
project.json
play/project.json
+1
-1
No files found.
play/assets/middleLayer_for_debug/scene/middleLayer_for_debug.fire
View file @
5d613c4c
...
@@ -243,8 +243,8 @@
...
@@ -243,8 +243,8 @@
"width": 1280,
"width": 1280,
"height": 720
"height": 720
},
},
"_fitWidth":
tru
e,
"_fitWidth":
fals
e,
"_fitHeight":
fals
e,
"_fitHeight":
tru
e,
"_id": "59Cd0ovbdF4byw5sbjJDx7"
"_id": "59Cd0ovbdF4byw5sbjJDx7"
},
},
{
{
...
@@ -271,7 +271,7 @@
...
@@ -271,7 +271,7 @@
"_isAbsHorizontalCenter": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalWidth": 0,
"_originalHeight": 0,
"_originalHeight":
72
0,
"_id": "29zXboiXFBKoIV4PQ2liTe"
"_id": "29zXboiXFBKoIV4PQ2liTe"
},
},
{
{
...
@@ -652,7 +652,7 @@
...
@@ -652,7 +652,7 @@
"__id__": 7
"__id__": 7
},
},
"_children": [],
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
"_components": [
{
{
"__id__": 15
"__id__": 15
...
@@ -847,7 +847,7 @@
...
@@ -847,7 +847,7 @@
"__id__": 7
"__id__": 7
},
},
"_children": [],
"_children": [],
"_active":
tru
e,
"_active":
fals
e,
"_components": [
"_components": [
{
{
"__id__": 19
"__id__": 19
...
...
play/assets/middleLayer_for_debug/script/middleLayer.js
View file @
5d613c4c
...
@@ -3,6 +3,8 @@ cc.Class({
...
@@ -3,6 +3,8 @@ cc.Class({
properties
:
{},
properties
:
{},
getData
(
callBack
)
{
getData
(
callBack
)
{
callBack
(
null
);
return
;
if
(
this
.
localMode
)
{
if
(
this
.
localMode
)
{
callBack
(
null
);
callBack
(
null
);
return
;
return
;
...
@@ -16,6 +18,7 @@ cc.Class({
...
@@ -16,6 +18,7 @@ cc.Class({
},
},
onHomeworkFinish
(
callBack
)
{
onHomeworkFinish
(
callBack
)
{
return
;
if
(
this
.
role
==
'
teacher
'
)
{
if
(
this
.
role
==
'
teacher
'
)
{
return
;
return
;
}
}
...
@@ -30,27 +33,6 @@ cc.Class({
...
@@ -30,27 +33,6 @@ cc.Class({
this
.
callNetworkApiPost
(
uri
,
data
,
callBack
);
this
.
callNetworkApiPost
(
uri
,
data
,
callBack
);
},
},
callNetworkApiGet
(
uri
,
data
,
callBack
)
{
let
queryStr
=
'
?
'
;
for
(
const
key
in
data
)
{
if
(
Object
.
hasOwnProperty
.
call
(
data
,
key
))
{
const
value
=
data
[
key
];
queryStr
+=
`
${
key
}
=
${
value
}
`
;
}
}
const
xhr
=
new
XMLHttpRequest
();
xhr
.
onreadystatechange
=
()
=>
{
if
(
xhr
.
readyState
==
4
&&
(
xhr
.
status
>=
200
&&
xhr
.
status
<
400
))
{
const
responseData
=
JSON
.
parse
(
xhr
.
responseText
);
callBack
(
JSON
.
parse
(
responseData
.
data
));
}
};
const
url
=
`
${
this
.
baseUrl
}${
uri
}${
queryStr
}
`
;
console
.
log
(
'
url =
'
+
url
);
xhr
.
open
(
'
GET
'
,
url
,
true
);
xhr
.
send
();
},
callNetworkApiPost
(
uri
,
data
,
callBack
)
{
callNetworkApiPost
(
uri
,
data
,
callBack
)
{
const
xhr
=
new
XMLHttpRequest
();
const
xhr
=
new
XMLHttpRequest
();
const
url
=
`
${
this
.
baseUrl
}${
uri
}
`
;
const
url
=
`
${
this
.
baseUrl
}${
uri
}
`
;
...
@@ -65,17 +47,11 @@ cc.Class({
...
@@ -65,17 +47,11 @@ cc.Class({
},
},
start
()
{
start
()
{
this
.
node
.
zIndex
=
9999
;
this
.
node
.
zIndex
=
9999
;
// this.showWaitingLetters();
cc
.
game
.
addPersistRootNode
(
this
.
node
);
cc
.
game
.
addPersistRootNode
(
this
.
node
);
this
.
initListener
();
this
.
initListener
();
// this.getBundleInfoList();
},
},
asyncDelayLog
(
str
)
{
asyncDelayLog
(
str
)
{
...
@@ -87,108 +63,24 @@ cc.Class({
...
@@ -87,108 +63,24 @@ cc.Class({
});
});
},
},
getBundleInfoList
()
{
callNetworkApiGet
(
baseUrl
,
uri
,
data
,
callBack
)
{
let
queryStr
=
'
?
'
;
for
(
const
key
in
data
)
{
const
jsonStr
=
this
.
callNativeFunction
({
name
:
'
loadSceneList
'
,
value
:
''
});
if
(
Object
.
hasOwnProperty
.
call
(
data
,
key
))
{
// const jsonStr = `{"bundleInfoList":[{"sceneName":"dfzx_cocos_T_FT_01","version":"c1a41","bondleUrl":"http://staging-teach.cdn.ireadabc.com//h5template/dfzx_cocos_T_FT_01/v3/android/dfzx_cocos_T_FT_01","token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NDYyLCJ1dWlkIjoiZDNlODE0OGItOTNlNC00NzdiLWEyMmEtMjNkYTk4ZWVlMGYwIiwicGhvbmUiOiIxNTk0MDgzMzk1MCIsIm5pY2tfbmFtZSI6IuaZk-aFp-a1i-ivlSIsIm9yZ19pZCI6MTEsInNjaG9vbF9pZCI6MjA0LCJjbGFzc19pZCI6MTQxLCJkZnp4X3VzZXJfdXVpZCI6ImVmMTNhNTI3ZDg2ZDQ1MGY4MWJjMWE1OWQ0NDcyZTQwIiwiZGVsIjowLCJjcmVhdGVkX2RhdGUiOiIyMDIwLTA4LTA2VDA2OjA1OjUxLjAwMFoiLCJ1cGRhdGVkX2RhdGUiOiIyMDIwLTA4LTA3VDA4OjI3OjQwLjAwMFoiLCJhY2NvdW50X3R5cGUiOjIsImVuZF9kYXRlIjoiMjAyMS0xMC0xM1QxNjowMDowMC4wMDBaIiwiY2xhc3NSb2xlIjoic3R1IiwiaWF0IjoxNjI5ODYyMTA2LCJleHAiOjE2MzI0NTQxMDZ9.pKvGgI9yijd57vJBLAM9wuiPV5KkCriezV-FlD8fmLI","baseUrl":"http://staging-teach.ireadabc.com/api/","homework_id":"313","syllabus_id":"18984","role":"student"},{"sceneName":"dfzx_cocos_T_FT_01","version":"c1a41","bondleUrl":"http://staging-teach.cdn.ireadabc.com//h5template/dfzx_cocos_T_FT_01/v3/android/dfzx_cocos_T_FT_01","token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NDYyLCJ1dWlkIjoiZDNlODE0OGItOTNlNC00NzdiLWEyMmEtMjNkYTk4ZWVlMGYwIiwicGhvbmUiOiIxNTk0MDgzMzk1MCIsIm5pY2tfbmFtZSI6IuaZk-aFp-a1i-ivlSIsIm9yZ19pZCI6MTEsInNjaG9vbF9pZCI6MjA0LCJjbGFzc19pZCI6MTQxLCJkZnp4X3VzZXJfdXVpZCI6ImVmMTNhNTI3ZDg2ZDQ1MGY4MWJjMWE1OWQ0NDcyZTQwIiwiZGVsIjowLCJjcmVhdGVkX2RhdGUiOiIyMDIwLTA4LTA2VDA2OjA1OjUxLjAwMFoiLCJ1cGRhdGVkX2RhdGUiOiIyMDIwLTA4LTA3VDA4OjI3OjQwLjAwMFoiLCJhY2NvdW50X3R5cGUiOjIsImVuZF9kYXRlIjoiMjAyMS0xMC0xM1QxNjowMDowMC4wMDBaIiwiY2xhc3NSb2xlIjoic3R1IiwiaWF0IjoxNjI5ODYyMTA2LCJleHAiOjE2MzI0NTQxMDZ9.pKvGgI9yijd57vJBLAM9wuiPV5KkCriezV-FlD8fmLI","baseUrl":"http://staging-teach.ireadabc.com/api/","homework_id":"313","syllabus_id":"18984","role":"student"}],"defaultBundleIdx":0}`;
const
value
=
data
[
key
];
queryStr
+=
`
${
key
}
=
${
value
}
`
;
const
{
bundleInfoList
,
defaultBundleIdx
}
=
JSON
.
parse
(
jsonStr
);
this
.
bundleInfoList
=
bundleInfoList
;
this
.
jumpToBundleByIndex
(
defaultBundleIdx
);
},
jumpToBundleByIndex
(
index
)
{
this
.
currentBundleIndex
=
index
;
const
currentBundleInfo
=
this
.
bundleInfoList
[
this
.
currentBundleIndex
];
const
btnLeft
=
this
.
node
.
getChildByName
(
'
BtnLeft
'
);
const
btnRight
=
this
.
node
.
getChildByName
(
'
BtnRight
'
);
btnLeft
.
active
=
true
;
btnRight
.
active
=
true
;
if
(
this
.
currentBundleIndex
==
0
)
{
btnLeft
.
active
=
false
;
}
if
(
this
.
currentBundleIndex
==
this
.
bundleInfoList
.
length
-
1
)
{
btnRight
.
active
=
false
;
}
this
.
baseUrl
=
currentBundleInfo
.
baseUrl
;
this
.
token
=
currentBundleInfo
.
token
;
this
.
homework_id
=
currentBundleInfo
.
homework_id
;
this
.
syllabus_id
=
currentBundleInfo
.
syllabus_id
;
this
.
role
=
currentBundleInfo
.
role
;
cc
.
assetManager
.
loadBundle
(
currentBundleInfo
.
bondleUrl
,
{
version
:
currentBundleInfo
.
version
},
async
(
err
,
bundle
)
=>
{
if
(
err
)
{
return
this
.
asyncDelayLog
(
err
);
}
}
}
bundle
.
loadScene
(
currentBundleInfo
.
sceneName
,
(
err
,
scene
)
=>
{
const
xhr
=
new
XMLHttpRequest
();
if
(
err
)
{
xhr
.
onreadystatechange
=
()
=>
{
this
.
asyncDelayLog
(
'
err:
'
,
err
);
if
(
xhr
.
readyState
==
4
&&
(
xhr
.
status
>=
200
&&
xhr
.
status
<
400
))
{
}
callBack
(
xhr
.
responseText
);
this
.
hideWaitingLetters
();
cc
.
director
.
runScene
(
scene
);
});
});
},
loadDefaultBundle
()
{
const
jsonStr
=
this
.
callNativeFunction
({
name
:
'
loadScene
'
,
value
:
''
});
const
{
sceneName
,
version
,
bondleUrl
,
token
,
baseUrl
,
homework_id
,
syllabus_id
,
role
}
=
JSON
.
parse
(
jsonStr
);
this
.
baseUrl
=
baseUrl
;
this
.
token
=
token
;
this
.
homework_id
=
homework_id
;
this
.
syllabus_id
=
syllabus_id
;
this
.
role
=
role
;
cc
.
assetManager
.
loadBundle
(
bondleUrl
,
{
version
:
version
},
(
err
,
bundle
)
=>
{
if
(
err
)
{
return
this
.
asyncDelayLog
(
err
);
}
}
};
bundle
.
loadScene
(
sceneName
,
(
err
,
scene
)
=>
{
const
url
=
`
${
baseUrl
}${
uri
}${
queryStr
}
`
;
console
.
log
(
'
url =
'
+
url
);
this
.
hideWaitingLetters
();
xhr
.
open
(
'
GET
'
,
url
,
true
);
xhr
.
send
();
cc
.
director
.
runScene
(
scene
);
});
});
},
},
initListener
()
{
initListener
()
{
...
@@ -200,40 +92,32 @@ cc.Class({
...
@@ -200,40 +92,32 @@ cc.Class({
.
to
(
0.1
,
{
scaleX
:
1
,
scaleY
:
1
})
.
to
(
0.1
,
{
scaleX
:
1
,
scaleY
:
1
})
.
call
(()
=>
{
.
call
(()
=>
{
cc
.
game
.
removePersistRootNode
(
this
.
node
);
cc
.
game
.
removePersistRootNode
(
this
.
node
);
cc
.
director
.
loadScene
(
"
emptyScene
"
,
()
=>
{
cc
.
director
.
loadScene
(
"
middleLayer_for_debug
"
,
()
=>
{
this
.
callNativeFunction
({
name
:
'
exit
'
,
value
:
''
});
});
});
})
})
.
start
();
.
start
();
});
});
const
btnLeft
=
this
.
node
.
getChildByName
(
'
BtnLeft
'
);
btnLeft
.
on
(
'
click
'
,
()
=>
{
if
(
this
.
currentBundleIndex
-
1
<
0
)
{
return
;
}
this
.
jumpToBundleByIndex
(
this
.
currentBundleIndex
-
1
);
});
const
btnRight
=
this
.
node
.
getChildByName
(
'
BtnRight
'
);
btnRight
.
on
(
'
click
'
,
()
=>
{
if
(
this
.
currentBundleIndex
+
1
>=
this
.
bundleInfoList
.
length
)
{
return
;
}
this
.
jumpToBundleByIndex
(
this
.
currentBundleIndex
+
1
);
});
const
BtnStartLocal
=
cc
.
find
(
'
middleLayer/ui/BtnStartLocal
'
);
const
BtnStartLocal
=
cc
.
find
(
'
middleLayer/ui/BtnStartLocal
'
);
BtnStartLocal
.
on
(
'
click
'
,
()
=>
{
BtnStartLocal
.
on
(
'
click
'
,
()
=>
{
const
addressText
=
cc
.
find
(
'
middleLayer/ui/address
'
);
const
addressText
=
cc
.
find
(
'
middleLayer/ui/address
'
);
const
str
=
addressText
.
getComponent
(
cc
.
EditBox
).
string
;
const
str
=
addressText
.
getComponent
(
cc
.
EditBox
).
string
;
const
address
=
str
.
split
(
'
:
'
)[
0
];
const
address
=
str
.
split
(
'
:
'
)[
0
];
const
port
=
str
.
split
(
'
:
'
)[
0
]
|
8081
;
const
port
=
str
.
split
(
'
:
'
)[
0
]
|
8081
;
console
.
log
(
'
汪汪汪:
'
+
`address =
${
address
}
, port =
${
port
}
`
);
this
.
localMode
=
true
;
this
.
localMode
=
true
;
this
.
loadBundle
(
address
,
port
);
this
.
loadLocalBundle
(
address
,
port
);
this
.
showWaitingLetters
();
this
.
hideUI
();
});
const
BtnStartOnline
=
cc
.
find
(
'
middleLayer/ui/BtnStartOnline
'
);
BtnStartOnline
.
on
(
'
click
'
,
()
=>
{
this
.
showWaitingLetters
();
this
.
showWaitingLetters
();
this
.
hideUI
();
this
.
hideUI
();
const
nameText
=
cc
.
find
(
'
middleLayer/ui/bundleName
'
);
const
bundleName
=
nameText
.
getComponent
(
cc
.
EditBox
).
string
;
this
.
loadOnlineBundle
(
bundleName
);
});
});
},
},
...
@@ -241,31 +125,41 @@ cc.Class({
...
@@ -241,31 +125,41 @@ cc.Class({
cc
.
find
(
'
middleLayer/ui
'
).
active
=
false
;
cc
.
find
(
'
middleLayer/ui
'
).
active
=
false
;
},
},
loadBundle
(
address
,
port
)
{
loadOnlineBundle
(
bundleName
)
{
const
xhr
=
new
XMLHttpRequest
();
this
.
callNetworkApiGet
(
`http://staging-teach.ireadabc.com`
,
`/api/template/v1/
${
bundleName
}
`
,
{},
(
datastr
)
=>
{
xhr
.
onreadystatechange
=
()
=>
{
const
data
=
JSON
.
parse
(
datastr
);
if
(
xhr
.
readyState
==
4
&&
(
xhr
.
status
>=
200
&&
xhr
.
status
<
400
))
{
const
configData
=
data
.
data
.
conf
.
android
;
const
data
=
JSON
.
parse
(
xhr
.
responseText
);
const
sceneName
=
configData
.
sceneName
;
const
configData
=
data
.
android
;
const
version
=
configData
.
version
;
const
bondleUrl
=
`http://
${
address
}
:
${
port
}
/publish/android/
${
configData
.
sceneName
}
/`
;
const
bondleUrl
=
configData
.
bondleUrl
;
cc
.
assetManager
.
loadBundle
(
bondleUrl
,
{
version
:
configData
.
version
},
async
(
err
,
bundle
)
=>
{
this
.
loadBundle
(
sceneName
,
version
,
bondleUrl
);
if
(
err
)
{
});
return
this
.
asyncDelayLog
(
err
);
},
}
bundle
.
loadScene
(
configData
.
sceneName
,
(
err
,
scene
)
=>
{
loadLocalBundle
(
address
,
port
)
{
if
(
err
)
{
this
.
callNetworkApiGet
(
`http://
${
address
}
:
${
port
}
`
,
'
/publish/config.json
'
,
{},
(
datastr
)
=>
{
this
.
asyncDelayLog
(
'
err:
'
,
err
);
const
data
=
JSON
.
parse
(
datastr
);
}
console
.
log
(
JSON
.
stringify
(
data
));
this
.
hideWaitingLetters
();
const
sceneName
=
data
.
android
.
sceneName
;
cc
.
director
.
runScene
(
scene
);
const
version
=
data
.
android
.
version
;
});
const
bondleUrl
=
`http://
${
address
}
:
${
port
}
/publish/android/
${
sceneName
}
/`
;
});
this
.
loadBundle
(
sceneName
,
version
,
bondleUrl
);
});
},
loadBundle
(
sceneName
,
version
,
bondleUrl
)
{
cc
.
assetManager
.
loadBundle
(
bondleUrl
,
{
version
:
version
},
async
(
err
,
bundle
)
=>
{
if
(
err
)
{
return
this
.
asyncDelayLog
(
err
);
}
}
};
bundle
.
loadScene
(
sceneName
,
(
err
,
scene
)
=>
{
const
url
=
`http://
${
address
}
:
${
port
}
/publish/config.json`
;
if
(
err
)
{
console
.
log
(
'
url =
'
+
url
);
this
.
asyncDelayLog
(
'
err:
'
,
err
);
xhr
.
open
(
'
GET
'
,
url
,
true
);
}
xhr
.
send
();
this
.
hideWaitingLetters
();
cc
.
director
.
runScene
(
scene
);
});
});
},
},
callNativeFunction
(
param
)
{
callNativeFunction
(
param
)
{
...
...
play/project.json
View file @
5d613c4c
...
@@ -3,6 +3,6 @@
...
@@ -3,6 +3,6 @@
"packages"
:
"packages"
,
"packages"
:
"packages"
,
"name"
:
"play"
,
"name"
:
"play"
,
"id"
:
"9af72fd2-44a6-4131-8ea3-3e1b3fa22231"
,
"id"
:
"9af72fd2-44a6-4131-8ea3-3e1b3fa22231"
,
"version"
:
"2.4.
4
"
,
"version"
:
"2.4.
0
"
,
"isNew"
:
false
"isNew"
:
false
}
}
\ No newline at end of file
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