* 所有的 CDN 依賴已全部 npm 化 * Webpack? 一邊去! Vite 太好用啦! * 將 Imports.ts 剔除 * 移除了大量的靜態文件 * 將 index.html 的部分代碼分離 * 修改 deno task * 移除了動態編譯頁面的支持 * ./static 引用全部變更為 npm 包引用
22 lines
753 B
TypeScript
22 lines
753 B
TypeScript
import EventCallbackFunction from "../typedef/EventCallbackFunction.ts"
|
|
import ApiManager from "./ApiManager.ts"
|
|
import { CallMethod } from './ApiDeclare.ts'
|
|
|
|
export default abstract class BaseApi {
|
|
abstract getName(): string
|
|
constructor() {
|
|
this.onInit()
|
|
}
|
|
abstract onInit(): void
|
|
checkArgsMissing(args: { [key: string]: unknown }, names: string[]) {
|
|
for (const k of names)
|
|
if (!(k in args))
|
|
return true
|
|
return false
|
|
}
|
|
registerEvent(name: CallMethod, func: EventCallbackFunction) {
|
|
if (!name.startsWith(this.getName() + ".")) throw Error("注冊的事件應該與接口集合命名空間相匹配: " + name)
|
|
ApiManager.addEventListener(name, func)
|
|
}
|
|
}
|