Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cake
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
cake
Commits
b2f124f4
Commit
b2f124f4
authored
Nov 25, 2021
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs:
parent
adc27763
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
30 deletions
+35
-30
README.md
README.md
+1
-1
cocos_generator.meta
assets/cocos_generator.meta
+1
-15
MyCocosSceneComponent.ts
assets/cocos_generator/script/MyCocosSceneComponent.ts
+1
-1
buildCocos.js
bin/buildCocos.js
+32
-13
No files found.
README.md
View file @
b2f124f4
...
@@ -81,4 +81,4 @@ npm start
...
@@ -81,4 +81,4 @@ npm start
*
手机和电脑连接同一个Wifi
*
手机和电脑连接同一个Wifi
*
打开调试app,根据提示输入IP地址,点击开始就可以在手机上预览模板了
*
打开调试app,根据提示输入IP地址,点击开始就可以在手机上预览模板了
*
*
使用 this.log("==调试信息=="); 可以打印日志进行必要的调试
\ No newline at end of file
\ No newline at end of file
assets/cocos_generator.meta
View file @
b2f124f4
{
{"ver":"1.1.2","uuid":"c35bb2f6-f24a-4850-ae44-643f2fdc7541","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}}
"ver": "1.1.2",
\ No newline at end of file
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {
"ios": false,
"android": false
},
"subMetas": {}
}
\ No newline at end of file
assets/cocos_generator/script/MyCocosSceneComponent.ts
View file @
b2f124f4
...
@@ -126,7 +126,7 @@ export class MyCocosSceneComponent extends cc.Component {
...
@@ -126,7 +126,7 @@ export class MyCocosSceneComponent extends cc.Component {
log
(
str
)
{
log
(
str
)
{
const
node
=
cc
.
find
(
'
middleLayer
'
);
const
node
=
cc
.
find
(
'
middleLayer
'
);
if
(
node
){
if
(
node
){
node
.
getComponent
(
'
middleLayer
'
).
showL
og
(
str
);
node
.
getComponent
(
'
middleLayer
'
).
l
og
(
str
);
}
else
{
}
else
{
cc
.
log
(
str
);
cc
.
log
(
str
);
}
}
...
...
bin/buildCocos.js
View file @
b2f124f4
...
@@ -128,15 +128,28 @@ async function buildWebBundle() {
...
@@ -128,15 +128,28 @@ async function buildWebBundle() {
await
buildCocos
(
args
);
await
buildCocos
(
args
);
}
}
function
createConfigFile
(
projectName
)
{
function
createConfigFile
(
projectName
,
type
)
{
const
androidPaths
=
fs
.
readdirSync
(
`dist/android/
${
projectName
}
`
);
let
iosVersion
=
""
;
const
androidConfigFileName
=
androidPaths
.
find
(
path
=>
path
.
indexOf
(
'
config
'
)
==
0
);
let
androidVersion
=
""
;
const
androidVersion
=
androidConfigFileName
.
split
(
'
.
'
)[
1
];
if
(
!
type
){
const
androidPaths
=
fs
.
readdirSync
(
`dist/android/
${
projectName
}
`
);
const
iosPaths
=
fs
.
readdirSync
(
`dist/ios/
${
projectName
}
`
);
const
androidConfigFileName
=
androidPaths
.
find
(
path
=>
path
.
indexOf
(
'
config
'
)
==
0
);
const
iosConfigFileName
=
iosPaths
.
find
(
path
=>
path
.
indexOf
(
'
config
'
)
==
0
);
androidVersion
=
androidConfigFileName
.
split
(
'
.
'
)[
1
];
const
iosVersion
=
iosConfigFileName
.
split
(
'
.
'
)[
1
];
const
iosPaths
=
fs
.
readdirSync
(
`dist/ios/
${
projectName
}
`
);
const
iosConfigFileName
=
iosPaths
.
find
(
path
=>
path
.
indexOf
(
'
config
'
)
==
0
);
iosVersion
=
iosConfigFileName
.
split
(
'
.
'
)[
1
];
}
else
{
if
(
type
==
"
android
"
){
const
androidPaths
=
fs
.
readdirSync
(
`dist/android/
${
projectName
}
`
);
const
androidConfigFileName
=
androidPaths
.
find
(
path
=>
path
.
indexOf
(
'
config
'
)
==
0
);
androidVersion
=
androidConfigFileName
.
split
(
'
.
'
)[
1
];
}
else
{
const
iosPaths
=
fs
.
readdirSync
(
`dist/ios/
${
projectName
}
`
);
const
iosConfigFileName
=
iosPaths
.
find
(
path
=>
path
.
indexOf
(
'
config
'
)
==
0
);
iosVersion
=
iosConfigFileName
.
split
(
'
.
'
)[
1
];
}
}
const
config
=
{
const
config
=
{
"
ios
"
:
{
"
ios
"
:
{
"
sceneName
"
:
projectName
,
"
sceneName
"
:
projectName
,
...
@@ -342,32 +355,38 @@ module.exports = {
...
@@ -342,32 +355,38 @@ module.exports = {
},
},
buildAndroid
:
async
function
()
{
buildAndroid
:
async
function
()
{
// 构建前检查
const
projectName
=
build_check
();
// 改设置为bundle
// 改设置为bundle
changeSettingsToBundle
();
changeSettingsToBundle
();
await
removeDir
(
'
dist/android
'
);
await
removeDir
(
'
dist/android
'
);
await
buildAndroidBundle
();
await
buildAndroidBundle
();
await
copyDir
(
'
build_android/jsb-link/remote
'
,
'
dist/android
'
);
await
copyDir
(
'
build_android/jsb-link/remote
'
,
'
dist/android
'
);
console
.
log
(
'
构建 android bundle 成功!
'
);
// 改设置为非bundle
// 改设置为非bundle
changeSettingToWebDesktop
();
changeSettingToWebDesktop
();
createConfigFile
(
projectName
,
"
android
"
);
await
removeDir
(
'
build_android
'
);
await
removeDir
(
'
build_android
'
);
console
.
log
(
'
构建 android bundle 成功!
'
);
},
},
buildIos
:
async
function
()
{
buildIos
:
async
function
()
{
// 构建前检查
const
projectName
=
build_check
();
// 改设置为bundle
// 改设置为bundle
changeSettingsToBundle
();
changeSettingsToBundle
();
await
removeDir
(
'
dist/ios
'
);
await
removeDir
(
'
dist/ios
'
);
await
buildIosBundle
();
await
buildIosBundle
();
await
copyDir
(
'
build_ios/jsb-link/remote
'
,
'
dist/ios
'
);
await
copyDir
(
'
build_ios/jsb-link/remote
'
,
'
dist/ios
'
);
console
.
log
(
'
构建 ios bundle 成功!
'
);
// 改设置为非bundle
// 改设置为非bundle
changeSettingToWebDesktop
();
changeSettingToWebDesktop
();
createConfigFile
(
projectName
,
"
ios
"
);
await
removeDir
(
'
build_ios
'
);
await
removeDir
(
'
build_ios
'
);
console
.
log
(
'
构建 ios bundle 成功!
'
);
}
}
};
};
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