修改热重载与打包的细节

This commit is contained in:
unanmed 2023-02-28 20:09:41 +08:00
parent 8ec41d634a
commit 35f166fe9a
4 changed files with 20 additions and 14 deletions

View File

@ -731,7 +731,7 @@ actions.prototype._sys_onmove_choices = function (x, y, px, py) {
actions.prototype._sys_onmove = function (x, y, px, py) {
if (core.status.lockControl) return false;
if (core.status.preview.dragging) {
if (core.status.preview?.dragging) {
core.setViewport(
core.bigmap.offsetX - px + core.status.preview.px,
core.bigmap.offsetY - py + core.status.preview.py
@ -740,7 +740,7 @@ actions.prototype._sys_onmove = function (x, y, px, py) {
core.status.preview.py = py;
return true;
}
if (core.status.preview.prepareDragging) {
if (core.status.preview?.prepareDragging) {
if (
Math.abs(px - core.status.preview.px) <= 20 &&
Math.abs(py - core.status.preview.py) <= 20

View File

@ -328,7 +328,7 @@ main.prototype.init = async function (mode, callback) {
core.resetSettings();
core.plugin.showMarkedEnemy.value = true;
}
if (main.useCompress) {
if (main.pluginUseCompress) {
await main.loadScript(`project/plugin.min.js?v=${main.version}`);
} else {
for await (const plugin of mainData.plugin) {

View File

@ -26,9 +26,6 @@ let hotReloadData = '';
/** 是否已经启动了热重载模块 */
let watched = false;
/** 是否已经启动了录像调试模块 */
let replayed = false;
/** 监听端口 */
let port = 3000;
const next = () => {
@ -41,11 +38,18 @@ const next = () => {
};
next();
let repStart;
const listenedFloors = [];
const listenedPlugins = [];
const hasPlugin = (function () {
try {
fss.readdirSync('./project/plugin');
return true;
} catch {
return false;
}
})();
// ----- GET file
/**
@ -346,10 +350,12 @@ async function watch() {
});
// 插件热重载
const plugins = await extract('project/plugin/*.js');
plugins.forEach(v => {
watchOnePlugin(v.slice(15));
});
if (hasPlugin) {
const plugins = await extract('project/plugin/*.js');
plugins.forEach(v => {
watchOnePlugin(v.slice(15));
});
}
// 数据热重载
const datas = (await extract('project/*.js')).filter(
@ -383,6 +389,7 @@ function testWatchFloor(url) {
* @param {string} url 要测试的路径
*/
function testWatchPlugin(url) {
if (!hasPlugin) return;
if (/project(\/|\\)plugin(\/|\\).*\.js/.test(url)) {
const f = url.slice(15);
if (!listenedFloors.includes(f.slice(0, -3))) {
@ -414,7 +421,7 @@ function watchOneFloor(file) {
function watchOnePlugin(file) {
if (!/.*\.js/.test(file)) return;
const f = file.slice(0, -3);
listenedFloors.push(file.slice(0, -3));
listenedPlugins.push(file.slice(0, -3));
fss.watchFile(`project/plugin/${file}`, { interval: 500 }, () => {
const plugin = f;
if (hotReloadData.includes(`@@plugin:${plugin}`)) return;

View File

@ -39,7 +39,6 @@ import { exec } from 'child_process';
})
);
await fse.remove('./dist/maps/');
await fse.remove('./dist/extensions/');
} catch {}
// 2. 压缩字体