mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-29 13:34:32 +08:00
完善资源分离,生成可发布结构
This commit is contained in:
1 parent
b5649c996b
commit
820dc5bf4c
9 files changed
+139
-45
No files matched your search
+1
-30
@@ -1,30 +1 @@
|
||||
import axios, { AxiosRequestConfig } from 'axios';
|
||||
|
||||
class LoadTask<T> {
|
||||
loaded: boolean = false;
|
||||
promise?: Promise<T>;
|
||||
url: string;
|
||||
config?: AxiosRequestConfig<T>;
|
||||
|
||||
constructor(url: string, config?: AxiosRequestConfig<T>) {
|
||||
this.url = url;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
load() {
|
||||
if (this.promise) return this.promise;
|
||||
|
||||
return (this.promise = axios.get(this.url, this.config));
|
||||
}
|
||||
|
||||
static list: Promise<any>[] = [];
|
||||
static push(...tasks: LoadTask<any>[]) {
|
||||
this.list.push(...tasks.map(v => v.load()));
|
||||
}
|
||||
|
||||
static onEnd<T extends any[] = any[]>(): Promise<T> {
|
||||
return Promise.all(LoadTask.list) as Promise<T>;
|
||||
}
|
||||
}
|
||||
|
||||
export default function load() {}
|
||||
export function readyAllResource() {}
|
||||
Reference in new issue
Block a user