import { Component } from '@angular/core'; import { Title } from '@angular/platform-browser'; import { ToolService } from './services/tool.service'; import { MarkingService } from './services/marking.service'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.less'] }) export class AppComponent { constructor(private titleService:Title, private tool:ToolService, private markingService: MarkingService){ let reg = /^#\/login\/?(\d*)$/; let isHosIdLogin = reg.test(location.hash); let hosId; console.log(isHosIdLogin) if(isHosIdLogin){ // 登录页 hosId = location.hash.replace(reg, '$1'); }else if(location.hash == '#/main/sysConfig' || location.hash == '' || location.href.includes("?")){ // 系统配置页||重定向前||单点登录 hosId = ''; }else{ // 其他页面 hosId = this.tool.getCurrentHospital().id; } console.log(hosId); this.tool.getSysNameAndLogoAsync(hosId).subscribe(result => { // 系统颜色设置 this.tool.setUIColor(result.ui_colour); let marking = result.project || ''; let logoTitle = result.sysName || ''; let logoUrl = location.origin + '/file' + result.logo || ''; let faviconUrl = location.origin + '/file' + result.favicon || ''; this.markingService.setMarking(marking); this.tool.setSysName(logoTitle); this.tool.setLogo(logoUrl); this.tool.setFavicon(faviconUrl); this.titleService.setTitle(this.tool.logoTitle); (document.querySelector('#favicon') as any).href = this.tool.faviconUrl; }) } }