mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-18 11:59:26 +08:00
修复服务器bug
This commit is contained in:
parent
a746823f63
commit
72e61ccf41
5
components.d.ts
vendored
5
components.d.ts
vendored
@ -7,7 +7,12 @@ export {}
|
||||
|
||||
declare module '@vue/runtime-core' {
|
||||
export interface GlobalComponents {
|
||||
ADivider: typeof import('ant-design-vue/es')['Divider']
|
||||
AProgress: typeof import('ant-design-vue/es')['Progress']
|
||||
ASelect: typeof import('ant-design-vue/es')['Select']
|
||||
ASelectOption: typeof import('ant-design-vue/es')['SelectOption']
|
||||
ASlider: typeof import('ant-design-vue/es')['Slider']
|
||||
ASwitch: typeof import('ant-design-vue/es')['Switch']
|
||||
Box: typeof import('./src/components/box.vue')['default']
|
||||
BoxAnimate: typeof import('./src/components/boxAnimate.vue')['default']
|
||||
Colomn: typeof import('./src/components/colomn.vue')['default']
|
||||
|
@ -314,6 +314,7 @@ async function writeMultiFiles(req: Request, res: Response) {
|
||||
* @param {string} data 信息
|
||||
*/
|
||||
async function doDeclaration(type: string, data: string) {
|
||||
try {
|
||||
const buf = Buffer.from(data, 'base64');
|
||||
data = buf.toString('utf-8');
|
||||
if (type === 'events') {
|
||||
@ -324,7 +325,7 @@ async function doDeclaration(type: string, data: string) {
|
||||
for (const id in eventData.commonEvent) {
|
||||
eventDec += ` | '${id}'\n`;
|
||||
}
|
||||
await fs.writeFile('../src/source/events.d.ts', eventDec, 'utf-8');
|
||||
await fs.writeFile('src/source/events.d.ts', eventDec, 'utf-8');
|
||||
} else if (type === 'items') {
|
||||
// 道具
|
||||
const itemData = JSON.parse(data.split('\n').slice(1).join(''));
|
||||
@ -334,7 +335,7 @@ async function doDeclaration(type: string, data: string) {
|
||||
itemDec += ` ${id}: '${itemData[id].cls}';\n`;
|
||||
}
|
||||
itemDec += '}';
|
||||
await fs.writeFile('../src/source/items.d.ts', itemDec, 'utf-8');
|
||||
await fs.writeFile('src/source/items.d.ts', itemDec, 'utf-8');
|
||||
} else if (type === 'maps') {
|
||||
// 映射
|
||||
const d = JSON.parse(data.split('\n').slice(1).join(''));
|
||||
@ -351,9 +352,9 @@ async function doDeclaration(type: string, data: string) {
|
||||
id2cls += '}';
|
||||
id2num += '}';
|
||||
num2id += '}';
|
||||
await fs.writeFile('../src/source/cls.d.ts', id2cls, 'utf-8');
|
||||
await fs.writeFile('src/source/cls.d.ts', id2cls, 'utf-8');
|
||||
await fs.writeFile(
|
||||
'../src/source/maps.d.ts',
|
||||
'src/source/maps.d.ts',
|
||||
`${id2num}\n${num2id}`,
|
||||
'utf-8'
|
||||
);
|
||||
@ -381,7 +382,7 @@ async function doDeclaration(type: string, data: string) {
|
||||
names += '}';
|
||||
|
||||
await fs.writeFile(
|
||||
'../src/source/data.d.ts',
|
||||
'src/source/data.d.ts',
|
||||
`
|
||||
${floorId}
|
||||
${d.images.length > 0 ? imgs : 'type ImageIds = never\n'}
|
||||
@ -394,6 +395,9 @@ ${names}
|
||||
'utf-8'
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function startHttpServer(port: number = 3000) {
|
||||
@ -496,7 +500,7 @@ function watchProject() {
|
||||
|
||||
// 数据热重载
|
||||
if (/project(\/|\\).*\.js/.test(path)) {
|
||||
const data = basename(path);
|
||||
const data = basename(path).slice(0, -3);
|
||||
ws.send(JSON.stringify({ type: 'dataHotReload', data }));
|
||||
console.log(`Data hot reload: ${data}.`);
|
||||
return;
|
||||
@ -510,7 +514,9 @@ function watchProject() {
|
||||
}
|
||||
|
||||
// 剩余内容全部reload
|
||||
if (!/_.*/.test(path)) {
|
||||
ws.send(JSON.stringify({ type: 'reload' }));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ export {};
|
||||
*/
|
||||
async function reloadData(data) {
|
||||
const script = document.createElement('script');
|
||||
script.src = `.forceTem/project/${data}.js?v=${Date.now()}`;
|
||||
script.src = `/forceTem/project/${data}.js?v=${Date.now()}`;
|
||||
document.body.appendChild(script);
|
||||
await new Promise(res => {
|
||||
script.onload = () => res('success');
|
||||
|
Loading…
Reference in New Issue
Block a user