diff --git a/public/libs/control.js b/public/libs/control.js
index e2ab60f..37ca008 100644
--- a/public/libs/control.js
+++ b/public/libs/control.js
@@ -2568,7 +2568,7 @@ control.prototype._doSL_load = function (id, callback) {
id == 'autoSave' ? id : 'save' + id,
null,
function (data) {
- if (!main.replayChecking) {
+ if (!main.replayChecking && data) {
core.plugin.startOpened.value = false;
core.plugin.loaded.value = false;
}
diff --git a/public/libs/core.js b/public/libs/core.js
index 4f10a4f..6e34670 100644
--- a/public/libs/core.js
+++ b/public/libs/core.js
@@ -322,11 +322,10 @@ core.prototype._loadPlugin = async function () {
if (main.pluginUseCompress) {
await main.loadScript(`project/plugin.m.js?v=${main.version}`);
} else {
- for await (const plugin of mainData.plugin) {
- await main.loadScript(
- `project/plugin/${plugin}.js?v=${main.version}`
- );
- }
+ await main.loadScript(
+ `project/plugin/index.js?v=${main.version}`,
+ true
+ );
}
};
diff --git a/public/main.js b/public/main.js
index 40a93ef..f5b2865 100644
--- a/public/main.js
+++ b/public/main.js
@@ -5,7 +5,7 @@ function main() {
this.version = '1.0.0'; // 游戏版本号;如果更改了游戏内容建议修改此version以免造成缓存问题。
this.useCompress = false; // 是否使用压缩文件
- this.pluginUseCompress = false; // 仅限于gh-pages使用
+ this.pluginUseCompress = false;
// 当你即将发布你的塔时,请使用“JS代码压缩工具”将所有js代码进行压缩,然后将这里的useCompress改为true。
// 请注意,只有useCompress是false时才会读取floors目录下的文件,为true时会直接读取libs目录下的floors.min.js文件。
// 如果要进行剧本的修改请务必将其改成false。
@@ -219,9 +219,10 @@ function main() {
}
// >>>> body end
-main.prototype.loadScript = async function (src) {
+main.prototype.loadScript = async function (src, module) {
const script = document.createElement('script');
script.src = src;
+ if (module) script.type = 'module';
document.body.appendChild(script);
await new Promise(res => {
script.addEventListener('load', res);
diff --git a/public/project/floors/MT42.js b/public/project/floors/MT42.js
index 0d1897f..dd12f07 100644
--- a/public/project/floors/MT42.js
+++ b/public/project/floors/MT42.js
@@ -59,13 +59,6 @@ main.floors.MT42=
0,
13
]
- },
- "8,12": {
- "floorId": "MT48",
- "loc": [
- 3,
- 7
- ]
}
},
"beforeBattle": {},
diff --git a/public/project/plugin/index.js b/public/project/plugin/index.js
index 6aea035..076069e 100644
--- a/public/project/plugin/index.js
+++ b/public/project/plugin/index.js
@@ -1,21 +1,21 @@
-import './fiveLayer';
-import './heroFourFrames';
-import './hotReload';
-import './itemDetail';
-import './popup';
-import './replay';
-import './ui';
-import * as halo from './halo';
-import * as hero from './hero';
-import * as loopMap from './loopMap';
-import * as remainEnemy from './remainEnemy';
-import * as removeMap from './removeMap';
-import * as shop from './shop';
-import * as skill from './skills';
-import * as skillTree from './skillTree';
-import * as study from './study';
-import * as towerBoss from './towerBoss';
-import * as utils from './utils';
+import './fiveLayer.js';
+import './heroFourFrames.js';
+import './hotReload.js';
+import './itemDetail.js';
+import './popup.js';
+import './replay.js';
+import './ui.js';
+import * as halo from './halo.js';
+import * as hero from './hero.js';
+import * as loopMap from './loopMap.js';
+import * as remainEnemy from './remainEnemy.js';
+import * as removeMap from './removeMap.js';
+import * as shop from './shop.js';
+import * as skill from './skills.js';
+import * as skillTree from './skillTree.js';
+import * as study from './study.js';
+import * as towerBoss from './towerBoss.js';
+import * as utils from './utils.js';
export {
halo,
diff --git a/public/project/plugin/loopMap.js b/public/project/plugin/loopMap.js
index 4cdef85..93cf92c 100644
--- a/public/project/plugin/loopMap.js
+++ b/public/project/plugin/loopMap.js
@@ -1,5 +1,5 @@
///
-import { slide } from './utils';
+import { slide } from './utils.js';
const list = ['tower6'];
diff --git a/public/project/plugin/replay.js b/public/project/plugin/replay.js
index b246dd4..24012a7 100644
--- a/public/project/plugin/replay.js
+++ b/public/project/plugin/replay.js
@@ -1,6 +1,6 @@
///
-import { studySkill, canStudySkill } from './study';
+import { studySkill, canStudySkill } from './study.js';
const replayableSettings = ['autoSkill'];
diff --git a/script/build.ts b/script/build.ts
index 4104431..45850c9 100644
--- a/script/build.ts
+++ b/script/build.ts
@@ -108,11 +108,6 @@ import * as rollup from 'rollup';
const compressed = babel.transformSync(code.output[0].code)?.code!;
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/');
} catch (e) {
console.log('压缩插件失败');
@@ -121,7 +116,11 @@ import * as rollup from 'rollup';
// 4. 压缩main.js
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 nonCompress = main.slice(0, endIndex);
const needCompress = main.slice(endIndex + 17);
diff --git a/src/types/core.d.ts b/src/types/core.d.ts
index 2209235..5a75455 100644
--- a/src/types/core.d.ts
+++ b/src/types/core.d.ts
@@ -1267,7 +1267,7 @@ interface Main extends MainData {
* 加载一个脚本
* @param src 脚本路径
*/
- loadScript(src: string): Promise;
+ loadScript(src: string, module?: boolean): Promise;
/**
* 动态加载js文件