在路劲
C:\Users\Administrator.CocosCreator\packages\hot-update-tool
替换文件
main.zip (993 字节)
已经测试过了,热更新插件主要的问题还是代码老了
经过很多次测试查资料
我发现官方https://github.com/cocos-creator/tutorial-hot-update这个里面的代码时可用的
// 在 main.js 的开头添加如下代码
(function () {
if (typeof window.jsb === ‘object’) {
var hotUpdateSearchPaths = localStorage.getItem(‘HotUpdateSearchPaths’);
if (hotUpdateSearchPaths) {
var paths = JSON.parse(hotUpdateSearchPaths);
jsb.fileUtils.setSearchPaths(paths);
var fileList = [];
var storagePath = paths[0] || '';
var tempPath = storagePath + '_temp/';
var baseOffset = tempPath.length;
if (jsb.fileUtils.isDirectoryExist(tempPath) && !jsb.fileUtils.isFileExist(tempPath + 'project.manifest.temp')) {
jsb.fileUtils.listFilesRecursively(tempPath, fileList);
fileList.forEach(srcPath => {
var relativePath = srcPath.substr(baseOffset);
var dstPath = storagePath + relativePath;
if (srcPath[srcPath.length] == '/') {
cc.fileUtils.createDirectory(dstPath)
}
else {
if (cc.fileUtils.isFileExist(dstPath)) {
cc.fileUtils.removeFile(dstPath)
}
cc.fileUtils.renameFile(srcPath, dstPath);
}
})
cc.fileUtils.removeDirectory(tempPath);
}
}
}
})();
最后我手动修改了插件的main.js文件 然后热更新插件变得好用多了