项目

管理个人资料页面标签页

管理个人资料页面

管理个人资料页面中的标签页可以通过@volo/abp.ng.account/public/config包提供的ManageProfileTabsService进行管理。使用此服务,您可以添加、删除或编辑标签页。

以下示例展示了所有功能:

// manage-profile-tabs.provider.ts

import { Component, inject, provideAppInitializer } from "@angular/core";
import { TwoFactorTabComponent } from "@volo/abp.ng.account/public";
import {
  eAccountManageProfileTabNames,
  ManageProfileTabsService,
} from "@volo/abp.ng.account/public/config";

@Component({
  selector: "abp-my-awesome-tab",
  template: `我的超棒标签页`,
})
class MyAwesomeTabComponent {}

export const MANAGE_PROFILE_TAB_PROVIDER = [
  provideAppInitializer(() => {
    configureManageProfileTabs();
  }),
];

export function configureManageProfileTabs() {
  const tabs = inject(ManageProfileTabsService);
  tabs.add([
    {
      name: "::MyAwesomeTab", // 支持本地化键
      order: 5,
      component: MyAwesomeTabComponent,
    },
  ]);

  tabs.patch(eAccountManageProfileTabNames.TwoFactor, {
    name: "双因素认证",
    component: TwoFactorTabComponent,
  });

  tabs.remove([eAccountManageProfileTabNames.ProfilePicture]);
}
//app.config.ts

import { MANAGE_PROFILE_TAB_PROVIDER } from "./manage-profile-tabs.provider";

export const appConfig: ApplicationConfig = {
  providers: [
    // ...
    MANAGE_PROFILE_TAB_PROVIDER,
  ],
};

我们上面完成的操作:

  • 创建了manage-profile-page-tabs.provider.ts文件
  • 定义了configureManageProfileTabs函数来执行管理个人资料标签页的操作
    • 添加了一个名为"我的超棒标签页"的新标签页
    • 重命名了"双因素认证"标签页的显示名称
    • 移除了"个人资料图片"标签页
  • 定义了MANAGE_PROFILE_TAB_PROVIDER以便在初始化时运行configureManageProfileTabs函数
  • MANAGE_PROFILE_TAB_PROVIDER注册到appConfig的providers中

查看结果:

我的超棒标签页

在本文档中