kst-auth
TypeScript icon, indicating that this package has built-in type declarations

0.3.2 • Public • Published

KstAuth

统一授权前端类库

使用

Installation

yarn add kst-auth

初始化

  1. 安装依赖
  • yarn add jquery bootstrap js-cookie moment

  • 下载 font-awesome4.7

  1. 配置依赖

转到angular.json,添加配置

"styles": [
  "src/assets/font-awesome-4.7.0/css/font-awesome.min.css",
  "node_modules\\bootstrap\\dist\\css\\bootstrap.min.css",
  
],
"scripts": [
  "node_modules\\jquery\\dist\\jquery.slim.min.js",
  "node_modules\\bootstrap\\dist\\js\\bootstrap.min.js"
]
  1. 引入类库
  • 在跟模块(一般为AppModule)中:
import { AccountModule, AppAccountSession } from 'kst-auth';
  • 在应用初始化中(依然在跟模块):
export function appInitializerFactory(injector: Injector) {

  const appSession = injector.get(AppAccountSession);

  return () => {
    return new Promise((reslove, reject) => {
      // 应用初始化
      // 此处必须条用getCurrentLoginInfo
      appSession.getCurrentLoginInfo(() => {
        reslove();
      });
    });
  };
}
// ------------------------
 providers: [{
    provide: APP_INITIALIZER,
    useFactory: appInitializerFactory,
    deps: [Injector],
    multi: true
  }]
  • 在根路由模块AppRoutingModule:
	{ path: 'account', loadChildren: () => import('kst-auth').then(mod => mod.AccountModule) }
  1. 启动查看效果

Readme

Keywords

none

Package Sidebar

Install

npm i kst-auth

Weekly Downloads

10

Version

0.3.2

License

GPL

Unpacked Size

672 kB

Total Files

62

Last publish

Collaborators

  • gexiaoxu