Managers.ets
726 Bytes
import { window } from '@kit.ArkUI';
import { common } from '@kit.AbilityKit';
export class WindowSizeManager {
private size: window.Size = { width: 0, height: 0 };
// 获取UIAbility上下文
private context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext
constructor() {
window.getLastWindow(this.context).then((value: window.Window) => {
const rect: window.Rect = value.getWindowProperties().windowRect;
this.size.width = px2vp(rect.width);
this.size.height = px2vp(rect.height);
// console.log('MultiPictureDetailItemComponent', `[windowWidth]${this.size.width} [windowHeight]${this.size.height}`);
})
}
get(): window.Size {
return this.size;
}
}