npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@asushiye/ngx-core

v14.2.0

Published

安装&使用 1.如何安装 2.如何使用 日志跟踪服务 拦截跟踪http请求 公用类 功能列表

Readme

安装@asushiye/ngx-core库

安装&使用
  1.如何安装
  2.如何使用
    日志跟踪服务
    拦截跟踪http请求
    公用类
功能列表

提示: 该文件来源: asu-learning/angular-learning/7增强模块\5库开发\2实战演练\create-ngx-core.md

安装&使用

ng new quickstart  --stype=css --routing=false --strict=true  # 新建项目

当然也可以在已存在项目中使用

  1. 如何安装
  2. 如何使用

1.如何安装

在项目根路径下, 执行安装命令

npm install @asushiye/ngx-core      # 假如发布latest 标记版本, 推荐使用
npm install @asushiye/[email protected] 

2.如何使用

导入模块

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { NgxCoreModule } from '@asushiye/ngx-core';

@NgModule({
  declarations: [ AppComponent ],
  imports: [BrowserModule, NgxCoreModule],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

日志跟踪服务

import { Component } from '@angular/core';
import { TrackerService, Result } from '@asushiye/ngx-core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  result: Result<any> = { status: true, code: 200, msg: 'success', data: null };
  constructor(private tracker: TrackerService){ }
  addLog(){
    this.tracker.debug('dddd');
  } 
}

<p>@asushiye/ngx-core</p>
<p>{{result|json}}}</p>

<button (click)="addLog()">name</button>
<ngx-core-logger></ngx-core-tracker>

拦截跟踪http请求

注册跟踪拦截器

import { TrackerInterceptor } from '@asushiye/ngx-core';

const INTERCEPTOR_PROVIDES = [
  { provide: HTTP_INTERCEPTORS, useClass: TrackerInterceptor, multi: true },
];
@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule],
  providers: [...INTERCEPTOR_PROVIDES],
  bootstrap: [AppComponent],
})
export class AppModule {}

定义跟踪组件路由

import { TrackerComponent } from '@asushiye/ngx-core';
const routes: Routes = [
  { path: 'tracker', component: TrackerComponent },
  ];
@NgModule({
  imports: [
    RouterModule.forRoot(routes, {
      useHash: environment.useHash,
      scrollPositionRestoration: 'top',
      enableTracing: !environment.production
    }),
  ],
  exports: [RouterModule],
})
export class RouteRoutingModule {}

定义跟踪页面

        <!-- asushiye -->
        <div nz-menu-item routerLink="/tracker">
          <i nz-icon nzType="info" class="mr-sm"></i>
          {{ 'menu.account.tracker' | translate }}
        </div> 

公用类

对于class类和服务类,直接导入就可以使用

import { Result } from '@asushiye/ngx-core';
import { TrackerService } from '@asushiye/ngx-core';

功能列表

export * from './lib/ngx-core.module';
export * from './lib/system/result/result';
export * from './lib/system/result/page';
export * from './lib/system/dto/dto';

export * from './lib/tracker/tracker.component';
export * from './lib/tracker/tracker.service';
export * from './lib/tracker/tracker-interceptor';

export * from './lib/cache/cache.service';
export * from './lib/error/http-error-handler.service';

下一步行动