mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 04:19:30 +08:00
修改热重载与打包的细节
This commit is contained in:
parent
8ec41d634a
commit
35f166fe9a
@ -731,7 +731,7 @@ actions.prototype._sys_onmove_choices = function (x, y, px, py) {
|
|||||||
actions.prototype._sys_onmove = function (x, y, px, py) {
|
actions.prototype._sys_onmove = function (x, y, px, py) {
|
||||||
if (core.status.lockControl) return false;
|
if (core.status.lockControl) return false;
|
||||||
|
|
||||||
if (core.status.preview.dragging) {
|
if (core.status.preview?.dragging) {
|
||||||
core.setViewport(
|
core.setViewport(
|
||||||
core.bigmap.offsetX - px + core.status.preview.px,
|
core.bigmap.offsetX - px + core.status.preview.px,
|
||||||
core.bigmap.offsetY - py + core.status.preview.py
|
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;
|
core.status.preview.py = py;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (core.status.preview.prepareDragging) {
|
if (core.status.preview?.prepareDragging) {
|
||||||
if (
|
if (
|
||||||
Math.abs(px - core.status.preview.px) <= 20 &&
|
Math.abs(px - core.status.preview.px) <= 20 &&
|
||||||
Math.abs(py - core.status.preview.py) <= 20
|
Math.abs(py - core.status.preview.py) <= 20
|
||||||
|
@ -328,7 +328,7 @@ main.prototype.init = async function (mode, callback) {
|
|||||||
core.resetSettings();
|
core.resetSettings();
|
||||||
core.plugin.showMarkedEnemy.value = true;
|
core.plugin.showMarkedEnemy.value = true;
|
||||||
}
|
}
|
||||||
if (main.useCompress) {
|
if (main.pluginUseCompress) {
|
||||||
await main.loadScript(`project/plugin.min.js?v=${main.version}`);
|
await main.loadScript(`project/plugin.min.js?v=${main.version}`);
|
||||||
} else {
|
} else {
|
||||||
for await (const plugin of mainData.plugin) {
|
for await (const plugin of mainData.plugin) {
|
||||||
|
@ -26,9 +26,6 @@ let hotReloadData = '';
|
|||||||
/** 是否已经启动了热重载模块 */
|
/** 是否已经启动了热重载模块 */
|
||||||
let watched = false;
|
let watched = false;
|
||||||
|
|
||||||
/** 是否已经启动了录像调试模块 */
|
|
||||||
let replayed = false;
|
|
||||||
|
|
||||||
/** 监听端口 */
|
/** 监听端口 */
|
||||||
let port = 3000;
|
let port = 3000;
|
||||||
const next = () => {
|
const next = () => {
|
||||||
@ -41,11 +38,18 @@ const next = () => {
|
|||||||
};
|
};
|
||||||
next();
|
next();
|
||||||
|
|
||||||
let repStart;
|
|
||||||
|
|
||||||
const listenedFloors = [];
|
const listenedFloors = [];
|
||||||
const listenedPlugins = [];
|
const listenedPlugins = [];
|
||||||
|
|
||||||
|
const hasPlugin = (function () {
|
||||||
|
try {
|
||||||
|
fss.readdirSync('./project/plugin');
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
// ----- GET file
|
// ----- GET file
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -346,10 +350,12 @@ async function watch() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 插件热重载
|
// 插件热重载
|
||||||
const plugins = await extract('project/plugin/*.js');
|
if (hasPlugin) {
|
||||||
plugins.forEach(v => {
|
const plugins = await extract('project/plugin/*.js');
|
||||||
watchOnePlugin(v.slice(15));
|
plugins.forEach(v => {
|
||||||
});
|
watchOnePlugin(v.slice(15));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 数据热重载
|
// 数据热重载
|
||||||
const datas = (await extract('project/*.js')).filter(
|
const datas = (await extract('project/*.js')).filter(
|
||||||
@ -383,6 +389,7 @@ function testWatchFloor(url) {
|
|||||||
* @param {string} url 要测试的路径
|
* @param {string} url 要测试的路径
|
||||||
*/
|
*/
|
||||||
function testWatchPlugin(url) {
|
function testWatchPlugin(url) {
|
||||||
|
if (!hasPlugin) return;
|
||||||
if (/project(\/|\\)plugin(\/|\\).*\.js/.test(url)) {
|
if (/project(\/|\\)plugin(\/|\\).*\.js/.test(url)) {
|
||||||
const f = url.slice(15);
|
const f = url.slice(15);
|
||||||
if (!listenedFloors.includes(f.slice(0, -3))) {
|
if (!listenedFloors.includes(f.slice(0, -3))) {
|
||||||
@ -414,7 +421,7 @@ function watchOneFloor(file) {
|
|||||||
function watchOnePlugin(file) {
|
function watchOnePlugin(file) {
|
||||||
if (!/.*\.js/.test(file)) return;
|
if (!/.*\.js/.test(file)) return;
|
||||||
const f = file.slice(0, -3);
|
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 }, () => {
|
fss.watchFile(`project/plugin/${file}`, { interval: 500 }, () => {
|
||||||
const plugin = f;
|
const plugin = f;
|
||||||
if (hotReloadData.includes(`@@plugin:${plugin}`)) return;
|
if (hotReloadData.includes(`@@plugin:${plugin}`)) return;
|
||||||
|
@ -39,7 +39,6 @@ import { exec } from 'child_process';
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
await fse.remove('./dist/maps/');
|
await fse.remove('./dist/maps/');
|
||||||
await fse.remove('./dist/extensions/');
|
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
// 2. 压缩字体
|
// 2. 压缩字体
|
||||||
|
Loading…
Reference in New Issue
Block a user