完善资源分离,生成可发布结构

This commit is contained in:
AncTe committed 2023-06-09 11:07:31 +08:00
1 parent b5649c996b
commit 820dc5bf4c
9 files changed
+139 -45

No files matched your search

+1 -30
View File
@@ -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() {}