Remove namespace and export default interface

This commit is contained in:
Maroxy 2021-10-17 22:28:26 +02:00
parent 3049aaeff2
commit 3d10bfc3c7
2 changed files with 63 additions and 65 deletions

140
src/ts/GIJSON.d.ts vendored
View file

@ -1,73 +1,69 @@
declare module GIJSON { interface VoicePack {
language: string;
interface VoicePack { name: string;
language: string; path: string;
name: string; size: string;
path: string; md5: string;
size: string; }
md5: string;
} interface Latest {
name: string;
interface Latest { version: string;
name: string; path: string;
version: string; size: string;
path: string; md5: string;
size: string; entry: string;
md5: string; voice_packs: VoicePack[];
entry: string; decompressed_path: string;
voice_packs: VoicePack[]; segments: any[];
decompressed_path: string; }
segments: any[];
} interface Diff {
name: string;
interface Diff { version: string;
name: string; path: string;
version: string; size: string;
path: string; md5: string;
size: string; is_recommended_update: boolean;
md5: string; voice_packs: VoicePack[];
is_recommended_update: boolean; }
voice_packs: VoicePack[];
} interface Game {
latest: Latest;
interface Game { diffs: Diff[];
latest: Latest; }
diffs: Diff[];
} interface Plugins {
name: string;
interface Plugins { version: string;
name: string; path: string;
version: string; size: string;
path: string; md5: string;
size: string; entry: string;
md5: string; }
entry: string;
} interface Plugin {
plugins: Plugins[];
interface Plugin { version: string;
plugins: Plugins[]; }
version: string;
} interface DeprecatedPackage {
name: string;
interface DeprecatedPackage { md5: string;
name: string; }
md5: string;
} interface Data {
game: Game;
interface Data { plugin: Plugin;
game: Game; web_url: string;
plugin: Plugin; force_update?: any;
web_url: string; pre_download_game?: any;
force_update?: any; deprecated_packages: DeprecatedPackage[];
pre_download_game?: any; sdk?: any;
deprecated_packages: DeprecatedPackage[]; }
sdk?: any;
} export default interface GIJSON {
retcode: number;
export interface Type { message: string;
retcode: number; data: Data;
message: string;
data: Data;
}
} }

View file

@ -1,3 +1,5 @@
import GIJSON from "./GIJSON";
const https = require('https'); const https = require('https');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
@ -74,7 +76,7 @@ export class Genshinlib
response.on('data', (chunk: any) => data += chunk); response.on('data', (chunk: any) => data += chunk);
response.on('end', () => { response.on('end', () => {
let jsondata: GIJSON.Type = JSON.parse(data); let jsondata: GIJSON = JSON.parse(data);
return jsondata.message === 'OK' ? resolve(jsondata.data) : reject(null); return jsondata.message === 'OK' ? resolve(jsondata.data) : reject(null);
}); });