import {Injectable} from '@angular/core' import {Router, ActivatedRoute} from '@angular/router' import {ToastrService} from 'ngx-toastr'; import {ContainerContent, overlayConfigFactory} from "ngx-modialog"; import {BSModalContext, Modal} from "ngx-modialog/plugins/bootstrap"; import StorageService from "@common/services/storage"; import config from "../../config"; @Injectable() export default class UtilService { constructor(private router: Router, private modal: Modal, private toastr: ToastrService, private storageService: StorageService) { } exitLogin() { setTimeout(ev => { window.location.href = config.loginUrl; setTimeout(() => { this.storageService.clear(); }, 500); }, 200) } reload(route) { this.router.navigate(['./', {timestamp: (new Date()).valueOf()}], { relativeTo: route, queryParamsHandling: 'preserve', replaceUrl: true }); } toastrSuccess(message = '') { this.toastr.success(message, '操作成功!'); } toastrError(message = '') { this.toastr.error(message, '操作失败!'); } showModal(modal, modalContext, args = {}) { this.modal.open(modal, overlayConfigFactory(new modalContext(args), BSModalContext) ); } listFilter(route, queryParams) { this.router.navigate(['../', 1, {timestamp: (new Date()).valueOf()}], { relativeTo: route, queryParams: queryParams }) } }