app.component.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { Component } from '@angular/core';
  2. import { Title } from '@angular/platform-browser';
  3. import { ToolService } from './services/tool.service';
  4. import { MarkingService } from './services/marking.service';
  5. @Component({
  6. selector: 'app-root',
  7. templateUrl: './app.component.html',
  8. styleUrls: ['./app.component.less']
  9. })
  10. export class AppComponent {
  11. constructor(private titleService:Title, private tool:ToolService, private markingService: MarkingService){
  12. let reg = /^#\/login\/?(\d*)$/;
  13. let isHosIdLogin = reg.test(location.hash);
  14. let hosId;
  15. console.log(isHosIdLogin)
  16. if(isHosIdLogin){
  17. // 登录页
  18. hosId = location.hash.replace(reg, '$1');
  19. }else if(location.hash == '#/main/sysConfig' || location.hash == '' || location.href.includes("?")){
  20. // 系统配置页||重定向前||单点登录
  21. hosId = '';
  22. }else{
  23. // 其他页面
  24. hosId = this.tool.getCurrentHospital().id;
  25. }
  26. console.log(hosId);
  27. this.tool.getSysNameAndLogoAsync(hosId).subscribe(result => {
  28. // 系统颜色设置
  29. this.tool.setUIColor(result.ui_colour);
  30. let marking = result.project || '';
  31. let logoTitle = result.sysName || '';
  32. let logoUrl = location.origin + '/file' + result.logo || '';
  33. let faviconUrl = location.origin + '/file' + result.favicon || '';
  34. this.markingService.setMarking(marking);
  35. this.tool.setSysName(logoTitle);
  36. this.tool.setLogo(logoUrl);
  37. this.tool.setFavicon(faviconUrl);
  38. this.titleService.setTitle(this.tool.logoTitle);
  39. (document.querySelector('#favicon') as any).href = this.tool.faviconUrl;
  40. })
  41. }
  42. }