basic.component.ts 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import { Component, OnInit } from '@angular/core';
  17. import { SettingsService, User } from '@delon/theme';
  18. import { environment } from '@env/environment';
  19. import { AuthnService } from 'src/app/service/authn.service';
  20. import { CONSTS } from 'src/app/shared/consts';
  21. import { knowHost } from '../../shared/utils/knowhost';
  22. import { LayoutDefaultOptions } from '../../theme/layout-default';
  23. @Component({
  24. selector: 'layout-basic',
  25. styles: [
  26. `
  27. .alain-default__collapsed .alain-default__aside-user {
  28. width: 64px;
  29. margin-left: 16px;
  30. }
  31. `
  32. ],
  33. template: `
  34. <layout-default [options]="options" [asideUser]="asideUserTpl" [content]="contentTpl" [customError]="null">
  35. <layout-default-header-item direction="left" *ngIf="!inst.custom">
  36. <a href="#">
  37. <img src="./assets/logo.png" alt="logo" style="height: 50px;height: 50px;float: left;" />
  38. <div
  39. class="alain-default__nav-item_title"
  40. style="letter-spacing: 2px;
  41. font-size: 20px;
  42. font-weight: bolder;
  43. width: 450px;
  44. margin-top: 12px;"
  45. >
  46. <span style="color: #000099;">Max</span>
  47. <span style="color: #FFD700;">Key</span>
  48. {{ 'mxk.title' | i18n }}
  49. </div>
  50. </a>
  51. </layout-default-header-item>
  52. <layout-default-header-item direction="left" *ngIf="inst.custom">
  53. <a href="#">
  54. <img src="{{ inst.logo }}" alt="logo" style="height: 50px;height: 50px;float: left;" />
  55. <div
  56. class="alain-default__nav-item_title"
  57. style="letter-spacing: 2px;
  58. font-size: 20px;
  59. font-weight: bolder;
  60. width: 450px;
  61. margin-top: 12px;"
  62. >
  63. {{ inst.title }}
  64. </div>
  65. </a>
  66. </layout-default-header-item>
  67. <layout-default-header-item direction="right" hidden="mobile">
  68. <div layout-default-header-item-trigger>
  69. <header-i18n></header-i18n>
  70. </div>
  71. </layout-default-header-item>
  72. <layout-default-header-item direction="right" hidden="mobile">
  73. <div layout-default-header-item-trigger nz-dropdown [nzDropdownMenu]="settingsMenu" nzTrigger="click" nzPlacement="bottomRight">
  74. <i nz-icon nzType="setting"></i>
  75. </div>
  76. <nz-dropdown-menu #settingsMenu="nzDropdownMenu">
  77. <div nz-menu style="width: 200px;">
  78. <div nz-menu-item>
  79. <header-rtl></header-rtl>
  80. </div>
  81. <div nz-menu-item>
  82. <header-fullscreen></header-fullscreen>
  83. </div>
  84. <div nz-menu-item>
  85. <header-clear-storage></header-clear-storage>
  86. </div>
  87. </div>
  88. </nz-dropdown-menu>
  89. </layout-default-header-item>
  90. <layout-default-header-item direction="right">
  91. <header-user></header-user>
  92. </layout-default-header-item>
  93. <ng-template #asideUserTpl>
  94. <div nz-dropdown nzTrigger="click" [nzDropdownMenu]="userMenu" class="alain-default__aside-user">
  95. <div class="alain-default__aside-user-info">
  96. <strong>{{ user.name }}</strong>
  97. <!--<p class="mb0">{{ user.email }}</p>-->
  98. </div>
  99. <!--
  100. <nz-avatar class="alain-default__aside-user-avatar" [nzSrc]="user.avatar"></nz-avatar>
  101. -->
  102. </div>
  103. <nz-dropdown-menu #userMenu="nzDropdownMenu">
  104. <ul nz-menu>
  105. <!--
  106. <li nz-menu-item routerLink="/pro/account/center">{{ 'menu.account.center' | i18n }}</li>
  107. <li nz-menu-item routerLink="/pro/account/settings">{{ 'menu.account.settings' | i18n }}</li>
  108. -->
  109. </ul>
  110. </nz-dropdown-menu>
  111. </ng-template>
  112. <ng-template #contentTpl>
  113. <router-outlet></router-outlet>
  114. </ng-template>
  115. </layout-default>
  116. <global-footer style="border-top: 1px solid #e5e5e5; min-height: 120px; text-shadow: 0 1px 0 #fff;margin:0;">
  117. <div style="margin-top: 30px">
  118. MaxKey {{ version }}<br />
  119. Copyright
  120. <i nz-icon nzType="copyright"></i> 2022 <a href="//www.maxkey.top" target="_blank">http://www.maxkey.top</a><br />
  121. Licensed under the Apache License, Version 2.0
  122. </div>
  123. </global-footer>
  124. <setting-drawer *ngIf="showSettingDrawer"></setting-drawer>
  125. <theme-btn></theme-btn>
  126. `
  127. })
  128. export class LayoutBasicComponent implements OnInit {
  129. version = CONSTS.VERSION;
  130. inst: any;
  131. options: LayoutDefaultOptions = {
  132. logoExpanded: `./assets/logo-full.svg`,
  133. logoCollapsed: `./assets/logo.svg`,
  134. hideAside: false
  135. };
  136. searchToggleStatus = false;
  137. showSettingDrawer = !environment.production;
  138. get user(): User {
  139. return this.settingsService.user;
  140. }
  141. ngOnInit(): void {
  142. this.inst = this.authnService.getInst();
  143. if (this.inst == null) {
  144. this.inst = { custom: false };
  145. this.authnService.initInst().subscribe(res => {
  146. this.authnService.setInst(res.data, !knowHost());
  147. this.inst = this.authnService.getInst();
  148. });
  149. }
  150. }
  151. constructor(private settingsService: SettingsService, private authnService: AuthnService) { }
  152. }