Add API Moudle!
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import { Modular, Manager, ILifetime } from "../../core/Module";
|
||||
import { API, IParamSetting } from "../../core/Api";
|
||||
import { Storage } from "../../core/Storage";
|
||||
|
||||
/**
|
||||
* 顶部状态栏
|
||||
*/
|
||||
class TestCore<M extends Manager> extends Modular<M>
|
||||
implements Partial<ILifetime> {
|
||||
|
||||
public onLoad() {
|
||||
|
||||
let s = new Storage("test", {
|
||||
a: new Date(),
|
||||
be: 2
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
s.set("be", 12);
|
||||
}, 1000)
|
||||
|
||||
interface ITestApiInput {
|
||||
name: string,
|
||||
id: number,
|
||||
info: {
|
||||
data: string
|
||||
}
|
||||
}
|
||||
|
||||
class TestApi extends API<ITestApiInput, {}> {
|
||||
|
||||
public override key:string = "TestApi";
|
||||
|
||||
public override params: IParamSetting<ITestApiInput> = {
|
||||
name: {
|
||||
tester: "123"
|
||||
},
|
||||
id: {
|
||||
parse: (i) => ++i,
|
||||
},
|
||||
info: {}
|
||||
}
|
||||
|
||||
public constructor(data:ITestApiInput) {
|
||||
super(data);
|
||||
this.initLabel();
|
||||
this.initData();
|
||||
}
|
||||
}
|
||||
|
||||
let api = new TestApi({
|
||||
name: "123",
|
||||
id: 456,
|
||||
info: {
|
||||
data: "abc"
|
||||
}
|
||||
});
|
||||
console.log(api);
|
||||
}
|
||||
}
|
||||
|
||||
export default TestCore;
|
||||
export { TestCore };
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Manager} from "../../core/Module";
|
||||
import { StatusBar } from "./StatusBar";
|
||||
import { TestCore } from "./TestCore";
|
||||
|
||||
/**
|
||||
* 此页面使用 Manager 进行模块化管理
|
||||
@@ -7,4 +8,5 @@ import { StatusBar } from "./StatusBar";
|
||||
*/
|
||||
Manager.Page((manager)=>{
|
||||
manager.addModule(StatusBar, "statusBar");
|
||||
manager.addModule(TestCore, "testCore");
|
||||
})
|
||||
Reference in New Issue
Block a user