首页 > 其他分享 >ng-alain解决新版本发布后前端存在缓存而导致路由出错问题

ng-alain解决新版本发布后前端存在缓存而导致路由出错问题

时间:2022-08-23 14:22:54浏览次数:58  
标签:instanceof 缓存 alain ng environment VERSION import ev

app.component.ts

import { Component, ElementRef, OnInit, Renderer2 } from '@angular/core';
import { NavigationEnd, NavigationError, RouteConfigLoadStart, Router } from '@angular/router';
import { TitleService, VERSION as VERSION_ALAIN } from '@delon/theme';
import { environment } from '@env/environment';
import { NzModalService } from 'ng-zorro-antd/modal';
import { VERSION as VERSION_ZORRO } from 'ng-zorro-antd/version';


@Component({
  selector: 'app-root',
  template: ` <router-outlet></router-outlet> `
})
export class AppComponent implements OnInit {
  constructor(
    el: ElementRef,
    renderer: Renderer2,
    private router: Router,
    private titleSrv: TitleService,
    private modalSrv: NzModalService
  ) {
    renderer.setAttribute(el.nativeElement, 'ng-alain-version', VERSION_ALAIN.full);
    renderer.setAttribute(el.nativeElement, 'ng-zorro-version', VERSION_ZORRO.full);
  }

ngOnInit(): void { let configLoad = false; this.router.events.subscribe(ev => { if (ev instanceof RouteConfigLoadStart) { configLoad = true; } if (configLoad && ev instanceof NavigationError) { this.modalSrv.confirm({ nzTitle: `提醒`, nzContent: environment.production ? `应用可能已发布新版本,请点击刷新才能生效。` : `无法加载路由:${ev.url}`, nzCancelDisabled: false, nzOkText: '刷新', nzCancelText: '忽略', nzOnOk: () => location.reload() }); } if (ev instanceof NavigationEnd) { this.titleSrv.setTitle(); this.modalSrv.closeAll(); } }); } }

标签:instanceof,缓存,alain,ng,environment,VERSION,import,ev
From: https://www.cnblogs.com/jokerWzz/p/16615973.html

相关文章

  • Django mysql 操作类
    Django-Chain-PyMySQLEasytousePyMySQLindjango.对PyMySQL进行封装,增加链式操作,方便快捷进行CURD操作注:基于Chain-PyMySQL->https://github.com/Tiacx/ch......
  • spring boot的静态文件
    原理:基于http协议获取远程文件实现:远程为HTTP服务器,浏览器发出请求即可基于SpringBoot下载静态文件,tomcat作为http服务器,从配置的角度完成两步即可 第一步:spring.......
  • Golang基础篇2
    标识符的组成标识符由数字、字母和下划线(_)组成。123abc_只能以字母和下划线(_)开头。abc123_sysVar123abc标识符区分大小写。nameNameNAME go语言关键字......
  • uff转engine踩䟘记录
    网上找了篇文章,用tensorrt自带转换工具trtexec转成engine格式的方法,网址如下:https://www.cnblogs.com/xiaoxiaomajinjiebiji/p/14451398.html文章中举例的转换指令为:/us......
  • csharp: Zip and Unzip files using GZipStream
      usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.......
  • Docker之Nginx保姆级别安装
    Docker之Nginx保姆级别安装:如果觉得样式不好:跳转即可 http://www.lifengying.site/(md文件复制过来有些样式会不一样)学英语网站项目:自己先保证Redis、Nginx、RabbitMQ、E......
  • IDEA中用Maven构建Spring Boot项目
    第一步,创建一个Maven项目第二步,配置pom.xml文件添加父依赖 <parent><artifactId>spring-boot-dependencies</artifactId><groupId>org.springfram......
  • String ==和equals的区别
    public boolean equals(Object obj) {    return (this == obj);} Object中的equals()方法其实就是==,而String重写了equals()方法把它修改成比......
  • Chapter 10 - Archiving (C#实现,实现NSDocument类型窗口的保存和载入)
    这个例子是在Chapter09-NSUndoManager 上继续实现的。所以大家要看前面的例子。xcode布局改变,记住给MainMenu.xib下的Open菜单项添加openDocument:操作关于PersonMo......
  • Got permission denied while trying to connect to the Docker daemon socket at uni
    [问题解决]GotpermissiondeniedwhiletryingtoconnecttotheDockerdaemonsocketatunix:///var/run/docker.sock 写了一个脚本读取docker日志,发生报错:Gotp......