修复长按桌面空白页menu内容在预定条件下不改变的问题

Signed-off-by: zhangchao <zhangchao338@huawei.com>
This commit is contained in:
zhangchao 2022-06-25 17:21:52 +08:00
parent 9a6c68688a
commit 5985514a7c
2 changed files with 6 additions and 2 deletions

View File

@ -24,6 +24,7 @@ const TAG = 'AppMenu';
@Component @Component
export default struct AppMenu { export default struct AppMenu {
menuInfoList: Array<MenuInfo> = new Array<MenuInfo>(); menuInfoList: Array<MenuInfo> = new Array<MenuInfo>();
getMenuInfoList: Function;
menuMode: number = CommonConstants.MENU_UI_MODE_LIGHT; menuMode: number = CommonConstants.MENU_UI_MODE_LIGHT;
fixedMenuList: Array<MenuInfo> = null; fixedMenuList: Array<MenuInfo> = null;
dynamicMenuList: Array<MenuInfo> = null; dynamicMenuList: Array<MenuInfo> = null;
@ -31,6 +32,9 @@ export default struct AppMenu {
aboutToAppear() { aboutToAppear() {
Log.showInfo(TAG, 'aboutToAppear start'); Log.showInfo(TAG, 'aboutToAppear start');
if (this.getMenuInfoList) {
this.menuInfoList = this.getMenuInfoList();
}
this.fixedMenuList = new Array<MenuInfo>(); this.fixedMenuList = new Array<MenuInfo>();
this.dynamicMenuList = new Array<MenuInfo>(); this.dynamicMenuList = new Array<MenuInfo>();
for (let menuInfo of this.menuInfoList) { for (let menuInfo of this.menuInfoList) {

View File

@ -109,7 +109,7 @@ export default struct PageDesktopLayout {
return true; return true;
} }
private getMenu() { private getMenu(): MenuInfo[] {
let menuInfoList = new Array<MenuInfo>(); let menuInfoList = new Array<MenuInfo>();
let setting = new MenuInfo(); let setting = new MenuInfo();
setting.menuType = CommonConstants.MENU_TYPE_FIXED setting.menuType = CommonConstants.MENU_TYPE_FIXED
@ -141,7 +141,7 @@ export default struct PageDesktopLayout {
if (this.logId()) { if (this.logId()) {
Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
AppMenu({ AppMenu({
menuInfoList: this.getMenu() getMenuInfoList: this.getMenu
}) })
} }
.width(StyleConstants.CONTEXT_MENU_WIDTH) .width(StyleConstants.CONTEXT_MENU_WIDTH)