修复bug

This commit is contained in:
unanmed 2023-04-16 17:30:22 +08:00
parent 81f6815429
commit 225585977a
9 changed files with 34 additions and 42 deletions

View File

@ -2568,7 +2568,7 @@ control.prototype._doSL_load = function (id, callback) {
id == 'autoSave' ? id : 'save' + id, id == 'autoSave' ? id : 'save' + id,
null, null,
function (data) { function (data) {
if (!main.replayChecking) { if (!main.replayChecking && data) {
core.plugin.startOpened.value = false; core.plugin.startOpened.value = false;
core.plugin.loaded.value = false; core.plugin.loaded.value = false;
} }

View File

@ -322,11 +322,10 @@ core.prototype._loadPlugin = async function () {
if (main.pluginUseCompress) { if (main.pluginUseCompress) {
await main.loadScript(`project/plugin.m.js?v=${main.version}`); await main.loadScript(`project/plugin.m.js?v=${main.version}`);
} else { } else {
for await (const plugin of mainData.plugin) { await main.loadScript(
await main.loadScript( `project/plugin/index.js?v=${main.version}`,
`project/plugin/${plugin}.js?v=${main.version}` true
); );
}
} }
}; };

View File

@ -5,7 +5,7 @@ function main() {
this.version = '1.0.0'; // 游戏版本号如果更改了游戏内容建议修改此version以免造成缓存问题。 this.version = '1.0.0'; // 游戏版本号如果更改了游戏内容建议修改此version以免造成缓存问题。
this.useCompress = false; // 是否使用压缩文件 this.useCompress = false; // 是否使用压缩文件
this.pluginUseCompress = false; // 仅限于gh-pages使用 this.pluginUseCompress = false;
// 当你即将发布你的塔时请使用“JS代码压缩工具”将所有js代码进行压缩然后将这里的useCompress改为true。 // 当你即将发布你的塔时请使用“JS代码压缩工具”将所有js代码进行压缩然后将这里的useCompress改为true。
// 请注意只有useCompress是false时才会读取floors目录下的文件为true时会直接读取libs目录下的floors.min.js文件。 // 请注意只有useCompress是false时才会读取floors目录下的文件为true时会直接读取libs目录下的floors.min.js文件。
// 如果要进行剧本的修改请务必将其改成false。 // 如果要进行剧本的修改请务必将其改成false。
@ -219,9 +219,10 @@ function main() {
} }
// >>>> body end // >>>> body end
main.prototype.loadScript = async function (src) { main.prototype.loadScript = async function (src, module) {
const script = document.createElement('script'); const script = document.createElement('script');
script.src = src; script.src = src;
if (module) script.type = 'module';
document.body.appendChild(script); document.body.appendChild(script);
await new Promise(res => { await new Promise(res => {
script.addEventListener('load', res); script.addEventListener('load', res);

View File

@ -59,13 +59,6 @@ main.floors.MT42=
0, 0,
13 13
] ]
},
"8,12": {
"floorId": "MT48",
"loc": [
3,
7
]
} }
}, },
"beforeBattle": {}, "beforeBattle": {},

View File

@ -1,21 +1,21 @@
import './fiveLayer'; import './fiveLayer.js';
import './heroFourFrames'; import './heroFourFrames.js';
import './hotReload'; import './hotReload.js';
import './itemDetail'; import './itemDetail.js';
import './popup'; import './popup.js';
import './replay'; import './replay.js';
import './ui'; import './ui.js';
import * as halo from './halo'; import * as halo from './halo.js';
import * as hero from './hero'; import * as hero from './hero.js';
import * as loopMap from './loopMap'; import * as loopMap from './loopMap.js';
import * as remainEnemy from './remainEnemy'; import * as remainEnemy from './remainEnemy.js';
import * as removeMap from './removeMap'; import * as removeMap from './removeMap.js';
import * as shop from './shop'; import * as shop from './shop.js';
import * as skill from './skills'; import * as skill from './skills.js';
import * as skillTree from './skillTree'; import * as skillTree from './skillTree.js';
import * as study from './study'; import * as study from './study.js';
import * as towerBoss from './towerBoss'; import * as towerBoss from './towerBoss.js';
import * as utils from './utils'; import * as utils from './utils.js';
export { export {
halo, halo,

View File

@ -1,5 +1,5 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
import { slide } from './utils'; import { slide } from './utils.js';
const list = ['tower6']; const list = ['tower6'];

View File

@ -1,6 +1,6 @@
///<reference path="../../../src/types/core.d.ts" /> ///<reference path="../../../src/types/core.d.ts" />
import { studySkill, canStudySkill } from './study'; import { studySkill, canStudySkill } from './study.js';
const replayableSettings = ['autoSkill']; const replayableSettings = ['autoSkill'];

View File

@ -108,11 +108,6 @@ import * as rollup from 'rollup';
const compressed = babel.transformSync(code.output[0].code)?.code!; const compressed = babel.transformSync(code.output[0].code)?.code!;
await fs.writeFile('./dist/project/plugin.m.js', compressed, 'utf-8'); await fs.writeFile('./dist/project/plugin.m.js', compressed, 'utf-8');
const main = await fs.readFile('./dist/main.js', 'utf-8');
main.replace(
/this.pluginUseCompress\s*=\s*false\;/,
'this.pluginUseCompress = true;'
);
await fse.remove('./dist/project/plugin/'); await fse.remove('./dist/project/plugin/');
} catch (e) { } catch (e) {
console.log('压缩插件失败'); console.log('压缩插件失败');
@ -121,7 +116,11 @@ import * as rollup from 'rollup';
// 4. 压缩main.js // 4. 压缩main.js
try { try {
// 先获取不能压缩的部分 // 先获取不能压缩的部分
const main = await fs.readFile('./dist/main.js', 'utf-8'); const main = (await fs.readFile('./public/main.js', 'utf-8')).replace(
/this.pluginUseCompress\s*=\s*false\;/,
'this.pluginUseCompress = true;'
);
const endIndex = main.indexOf('// >>>> body end'); const endIndex = main.indexOf('// >>>> body end');
const nonCompress = main.slice(0, endIndex); const nonCompress = main.slice(0, endIndex);
const needCompress = main.slice(endIndex + 17); const needCompress = main.slice(endIndex + 17);

2
src/types/core.d.ts vendored
View File

@ -1267,7 +1267,7 @@ interface Main extends MainData {
* *
* @param src * @param src
*/ */
loadScript(src: string): Promise<void>; loadScript(src: string, module?: boolean): Promise<void>;
/** /**
* js文件 * js文件