mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-18 20:09:27 +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' {
|
declare module '@vue/runtime-core' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
|
ADivider: typeof import('ant-design-vue/es')['Divider']
|
||||||
AProgress: typeof import('ant-design-vue/es')['Progress']
|
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']
|
Box: typeof import('./src/components/box.vue')['default']
|
||||||
BoxAnimate: typeof import('./src/components/boxAnimate.vue')['default']
|
BoxAnimate: typeof import('./src/components/boxAnimate.vue')['default']
|
||||||
Colomn: typeof import('./src/components/colomn.vue')['default']
|
Colomn: typeof import('./src/components/colomn.vue')['default']
|
||||||
|
140
script/dev.ts
140
script/dev.ts
@ -314,75 +314,76 @@ async function writeMultiFiles(req: Request, res: Response) {
|
|||||||
* @param {string} data 信息
|
* @param {string} data 信息
|
||||||
*/
|
*/
|
||||||
async function doDeclaration(type: string, data: string) {
|
async function doDeclaration(type: string, data: string) {
|
||||||
const buf = Buffer.from(data, 'base64');
|
try {
|
||||||
data = buf.toString('utf-8');
|
const buf = Buffer.from(data, 'base64');
|
||||||
if (type === 'events') {
|
data = buf.toString('utf-8');
|
||||||
// 事件
|
if (type === 'events') {
|
||||||
const eventData = JSON.parse(data.split('\n').slice(1).join(''));
|
// 事件
|
||||||
|
const eventData = JSON.parse(data.split('\n').slice(1).join(''));
|
||||||
|
|
||||||
let eventDec = 'type EventDeclaration = \n';
|
let eventDec = 'type EventDeclaration = \n';
|
||||||
for (const id in eventData.commonEvent) {
|
for (const id in eventData.commonEvent) {
|
||||||
eventDec += ` | '${id}'\n`;
|
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') {
|
} else if (type === 'items') {
|
||||||
// 道具
|
// 道具
|
||||||
const itemData = JSON.parse(data.split('\n').slice(1).join(''));
|
const itemData = JSON.parse(data.split('\n').slice(1).join(''));
|
||||||
|
|
||||||
let itemDec = 'interface ItemDeclaration {\n';
|
let itemDec = 'interface ItemDeclaration {\n';
|
||||||
for (const id in itemData) {
|
for (const id in itemData) {
|
||||||
itemDec += ` ${id}: '${itemData[id].cls}';\n`;
|
itemDec += ` ${id}: '${itemData[id].cls}';\n`;
|
||||||
}
|
}
|
||||||
itemDec += '}';
|
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') {
|
} else if (type === 'maps') {
|
||||||
// 映射
|
// 映射
|
||||||
const d = JSON.parse(data.split('\n').slice(1).join(''));
|
const d = JSON.parse(data.split('\n').slice(1).join(''));
|
||||||
|
|
||||||
let id2num = 'interface IdToNumber {\n';
|
let id2num = 'interface IdToNumber {\n';
|
||||||
let num2id = 'interface NumberToId {\n';
|
let num2id = 'interface NumberToId {\n';
|
||||||
let id2cls = 'interface IdToCls {\n';
|
let id2cls = 'interface IdToCls {\n';
|
||||||
for (const num in d) {
|
for (const num in d) {
|
||||||
const { id, cls } = d[num];
|
const { id, cls } = d[num];
|
||||||
id2num += ` ${id}: ${num};\n`;
|
id2num += ` ${id}: ${num};\n`;
|
||||||
num2id += ` ${num}: '${id}';\n`;
|
num2id += ` ${num}: '${id}';\n`;
|
||||||
id2cls += ` ${id}: '${cls}';\n`;
|
id2cls += ` ${id}: '${cls}';\n`;
|
||||||
}
|
}
|
||||||
id2cls += '}';
|
id2cls += '}';
|
||||||
id2num += '}';
|
id2num += '}';
|
||||||
num2id += '}';
|
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(
|
await fs.writeFile(
|
||||||
'../src/source/maps.d.ts',
|
'src/source/maps.d.ts',
|
||||||
`${id2num}\n${num2id}`,
|
`${id2num}\n${num2id}`,
|
||||||
'utf-8'
|
'utf-8'
|
||||||
);
|
);
|
||||||
} else if (type === 'data') {
|
} else if (type === 'data') {
|
||||||
// 全塔属性的注册信息
|
// 全塔属性的注册信息
|
||||||
const d = JSON.parse(data.split('\n').slice(1).join('')).main;
|
const d = JSON.parse(data.split('\n').slice(1).join('')).main;
|
||||||
|
|
||||||
let floorId = 'type FloorIds =\n';
|
let floorId = 'type FloorIds =\n';
|
||||||
let imgs = 'type ImageIds =\n';
|
let imgs = 'type ImageIds =\n';
|
||||||
let anis = 'type AnimationIds =\n';
|
let anis = 'type AnimationIds =\n';
|
||||||
let sounds = 'type SoundIds =\n';
|
let sounds = 'type SoundIds =\n';
|
||||||
let names = 'interface NameMap {\n';
|
let names = 'interface NameMap {\n';
|
||||||
let bgms = 'type BgmIds =\n';
|
let bgms = 'type BgmIds =\n';
|
||||||
let fonts = 'type FontIds =\n';
|
let fonts = 'type FontIds =\n';
|
||||||
|
|
||||||
floorId += d.floorIds.map((v: any) => ` | '${v}'\n`).join('');
|
floorId += d.floorIds.map((v: any) => ` | '${v}'\n`).join('');
|
||||||
imgs += d.images.map((v: any) => ` | '${v}'\n`).join('');
|
imgs += d.images.map((v: any) => ` | '${v}'\n`).join('');
|
||||||
anis += d.animates.map((v: any) => ` | '${v}'\n`).join('');
|
anis += d.animates.map((v: any) => ` | '${v}'\n`).join('');
|
||||||
sounds += d.sounds.map((v: any) => ` | '${v}'\n`).join('');
|
sounds += d.sounds.map((v: any) => ` | '${v}'\n`).join('');
|
||||||
bgms += d.bgms.map((v: any) => ` | '${v}'\n`).join('');
|
bgms += d.bgms.map((v: any) => ` | '${v}'\n`).join('');
|
||||||
fonts += d.fonts.map((v: any) => ` | '${v}'\n`).join('');
|
fonts += d.fonts.map((v: any) => ` | '${v}'\n`).join('');
|
||||||
for (const name in d.nameMap) {
|
for (const name in d.nameMap) {
|
||||||
names += ` '${name}': '${d.nameMap[name]}';\n`;
|
names += ` '${name}': '${d.nameMap[name]}';\n`;
|
||||||
}
|
}
|
||||||
names += '}';
|
names += '}';
|
||||||
|
|
||||||
await fs.writeFile(
|
await fs.writeFile(
|
||||||
'../src/source/data.d.ts',
|
'src/source/data.d.ts',
|
||||||
`
|
`
|
||||||
${floorId}
|
${floorId}
|
||||||
${d.images.length > 0 ? imgs : 'type ImageIds = never\n'}
|
${d.images.length > 0 ? imgs : 'type ImageIds = never\n'}
|
||||||
${d.animates.length > 0 ? anis : 'type AnimationIds = never\n'}
|
${d.animates.length > 0 ? anis : 'type AnimationIds = never\n'}
|
||||||
@ -391,8 +392,11 @@ ${d.bgms.length > 0 ? bgms : 'type BgmIds = never\n'}
|
|||||||
${d.fonts.length > 0 ? fonts : 'type FontIds = never\n'}
|
${d.fonts.length > 0 ? fonts : 'type FontIds = never\n'}
|
||||||
${names}
|
${names}
|
||||||
`,
|
`,
|
||||||
'utf-8'
|
'utf-8'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,7 +500,7 @@ function watchProject() {
|
|||||||
|
|
||||||
// 数据热重载
|
// 数据热重载
|
||||||
if (/project(\/|\\).*\.js/.test(path)) {
|
if (/project(\/|\\).*\.js/.test(path)) {
|
||||||
const data = basename(path);
|
const data = basename(path).slice(0, -3);
|
||||||
ws.send(JSON.stringify({ type: 'dataHotReload', data }));
|
ws.send(JSON.stringify({ type: 'dataHotReload', data }));
|
||||||
console.log(`Data hot reload: ${data}.`);
|
console.log(`Data hot reload: ${data}.`);
|
||||||
return;
|
return;
|
||||||
@ -510,7 +514,9 @@ function watchProject() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 剩余内容全部reload
|
// 剩余内容全部reload
|
||||||
ws.send(JSON.stringify({ type: 'reload' }));
|
if (!/_.*/.test(path)) {
|
||||||
|
ws.send(JSON.stringify({ type: 'reload' }));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ export {};
|
|||||||
*/
|
*/
|
||||||
async function reloadData(data) {
|
async function reloadData(data) {
|
||||||
const script = document.createElement('script');
|
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);
|
document.body.appendChild(script);
|
||||||
await new Promise(res => {
|
await new Promise(res => {
|
||||||
script.onload = () => res('success');
|
script.onload = () => res('success');
|
||||||
|
Loading…
Reference in New Issue
Block a user