add view idenitify
This commit is contained in:
@@ -10,11 +10,11 @@ export function Registor<T extends { new(...args: any[]): {} }>(constructor: T)
|
||||
}
|
||||
|
||||
|
||||
export abstract class Page {
|
||||
onCreate(): void { }
|
||||
onDestory(): void { }
|
||||
onShow(): void { }
|
||||
onHidden(): void { }
|
||||
export abstract class Panel {
|
||||
onCreate() { }
|
||||
onDestory() { }
|
||||
onShow() { }
|
||||
onHidden() { }
|
||||
|
||||
abstract build(): View
|
||||
|
||||
@@ -22,15 +22,16 @@ export abstract class Page {
|
||||
/**
|
||||
* Native Call
|
||||
*/
|
||||
private __onCreate__(): void {
|
||||
private __onCreate__() {
|
||||
Reflect.defineMetadata(Symbol.for("context"), context, Reflect.getPrototypeOf(context))
|
||||
this.onCreate()
|
||||
}
|
||||
|
||||
private __onDestory__(): void {
|
||||
private __onDestory__() {
|
||||
this.onDestory()
|
||||
}
|
||||
|
||||
private __onShow__(): void {
|
||||
private __onShow__() {
|
||||
this.onShow()
|
||||
}
|
||||
|
||||
@@ -41,4 +42,8 @@ export abstract class Page {
|
||||
private __build__(): View {
|
||||
return this.build()
|
||||
}
|
||||
|
||||
private __responed__(viewId: string, action: string, args: any) {
|
||||
|
||||
}
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
import { Color, GradientColor } from "../util/color"
|
||||
import { Modeling, Model } from "../util/types";
|
||||
import "reflect-metadata"
|
||||
import { uniqueId } from "../util/uniqueId";
|
||||
|
||||
export function Property(target: Object, propKey: string) {
|
||||
Reflect.defineMetadata(propKey, true, target)
|
||||
@@ -33,6 +34,13 @@ export abstract class View implements Modeling {
|
||||
|
||||
@Property
|
||||
alpha?: number
|
||||
|
||||
@Property
|
||||
hidden?: boolean
|
||||
|
||||
@Property
|
||||
viewId = uniqueId('ViewId')
|
||||
|
||||
constructor() {
|
||||
return new Proxy(this, {
|
||||
get: (target, p) => {
|
||||
@@ -92,7 +100,11 @@ export abstract class View implements Modeling {
|
||||
}
|
||||
|
||||
toModel() {
|
||||
return this.__dirty_props__ || {}
|
||||
return {
|
||||
id: this.viewId,
|
||||
type: this.constructor.name,
|
||||
props: this.__dirty_props__,
|
||||
}
|
||||
}
|
||||
|
||||
@Property
|
||||
|
Reference in New Issue
Block a user