login-authorization-v2 2.0.0-beta.1 → 2.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -47
- package/dist/index.d.ts +14 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +405 -497
- package/dist/index.umd.js +424 -537
- package/dist/src/request.d.ts.map +1 -1
- package/package.json +29 -25
- package/babel.config.js +0 -6
- package/coverage/clover.xml +0 -140
- package/coverage/coverage-final.json +0 -8
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/common-authorization-v2/index.html +0 -116
- package/coverage/lcov-report/common-authorization-v2/index.ts.html +0 -547
- package/coverage/lcov-report/common-authorization-v2/src/compatible.ts.html +0 -223
- package/coverage/lcov-report/common-authorization-v2/src/constance.ts.html +0 -106
- package/coverage/lcov-report/common-authorization-v2/src/cookie.ts.html +0 -346
- package/coverage/lcov-report/common-authorization-v2/src/dom.ts.html +0 -262
- package/coverage/lcov-report/common-authorization-v2/src/index.html +0 -206
- package/coverage/lcov-report/common-authorization-v2/src/request.ts.html +0 -361
- package/coverage/lcov-report/common-authorization-v2/src/shares.ts.html +0 -163
- package/coverage/lcov-report/common-authorization-v2/src/types.ts.html +0 -412
- package/coverage/lcov-report/common-authorization-v2/src/utils.ts.html +0 -145
- package/coverage/lcov-report/compatible.ts.html +0 -223
- package/coverage/lcov-report/constance.ts.html +0 -106
- package/coverage/lcov-report/cookie.ts.html +0 -310
- package/coverage/lcov-report/dom.ts.html +0 -262
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -206
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/shares.ts.html +0 -163
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov-report/types.ts.html +0 -412
- package/coverage/lcov-report/utils.ts.html +0 -145
- package/coverage/lcov.info +0 -268
- package/dist/compatible.d.ts +0 -10
- package/dist/compatible.d.ts.map +0 -1
- package/dist/constance.d.ts +0 -6
- package/dist/constance.d.ts.map +0 -1
- package/dist/cookie.d.ts +0 -8
- package/dist/cookie.d.ts.map +0 -1
- package/dist/dom.d.ts +0 -2
- package/dist/dom.d.ts.map +0 -1
- package/dist/index.js.LICENSE.txt +0 -1
- package/dist/request.d.ts +0 -36
- package/dist/request.d.ts.map +0 -1
- package/dist/shares.d.ts +0 -10
- package/dist/shares.d.ts.map +0 -1
- package/dist/test/cookie.test.d.ts +0 -2
- package/dist/test/cookie.test.d.ts.map +0 -1
- package/dist/test/shares.test.d.ts +0 -2
- package/dist/test/shares.test.d.ts.map +0 -1
- package/dist/types.d.ts +0 -89
- package/dist/types.d.ts.map +0 -1
- package/dist/utils.d.ts +0 -2
- package/dist/utils.d.ts.map +0 -1
- package/index.html +0 -28
- package/index.ts +0 -154
- package/jest.config.js +0 -6
- package/src/compatible.ts +0 -46
- package/src/constance.ts +0 -7
- package/src/cookie.ts +0 -75
- package/src/dom.ts +0 -59
- package/src/request.ts +0 -99
- package/src/shares.ts +0 -26
- package/src/types.ts +0 -109
- package/src/utils.ts +0 -20
- package/tests/compatible.test.ts +0 -420
- package/tests/cookie.test.ts +0 -78
- package/tests/dom.test.ts +0 -95
- package/tests/index.test.ts +0 -126
- package/tests/shares.test.ts +0 -52
- package/tests/utils.test.ts +0 -79
- package/tsconfig.json +0 -49
- package/webpack.config.mjs +0 -47
package/README.md
CHANGED
|
@@ -1,55 +1,53 @@
|
|
|
1
|
-
# login-authorization
|
|
1
|
+
# login-authorization-v2
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
## 安装
|
|
4
|
+
```bash
|
|
5
|
+
#npm
|
|
6
|
+
npm install login-authorization-v2
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
npm install login-authorization --save
|
|
9
|
-
# or with yarn
|
|
10
|
-
yarn add login-authorization
|
|
8
|
+
#yarn
|
|
9
|
+
yarn add login-authorization-v2
|
|
11
10
|
```
|
|
12
|
-
## 方法使用说明
|
|
13
|
-
### 初始化:init(requestUrl, loginUrl, systemName) 此方法必须在入口文件中调用
|
|
14
|
-
```bash
|
|
15
|
-
import { init } from 'login-authorization';
|
|
16
|
-
|
|
17
|
-
init('http://127.0.0.1','http://127.0.0.1/#/login?systemName=Finance', 'Finance').then(res => {
|
|
18
|
-
if (res) {
|
|
19
|
-
// true 已登录
|
|
20
|
-
} else {
|
|
21
|
-
// false 未登录
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
11
|
|
|
25
|
-
|
|
12
|
+
## 使用文档
|
|
13
|
+
### 基本使用
|
|
14
|
+
```javascript
|
|
15
|
+
import { make } from 'login-authorization-v2'
|
|
26
16
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
### 获取idToken:getIdToken()
|
|
33
|
-
```bash
|
|
34
|
-
import { getIdToken } from 'login-authorization';
|
|
17
|
+
const { init, logout } = make({
|
|
18
|
+
moduleName: 'Portal', // 当前模块名称
|
|
19
|
+
moduleBaseUrl: 'https://servers-api.gztest.net:8107', // 后端的 module_base 服务地址
|
|
20
|
+
loginPageUrl: 'http://huangcheng.ddmarketinghub.com:8080', // 如果未登录,跳转的登录页地址
|
|
21
|
+
})
|
|
35
22
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
init({ brand: 1, tenantId: 1 }).then(menus => {
|
|
24
|
+
// menus 即为当前用户的菜单权限数据
|
|
25
|
+
}).catch(err => {
|
|
26
|
+
// 任何不能正常登陆的情况都会进入这里
|
|
27
|
+
})
|
|
41
28
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
import { logout } from 'login-authorization';
|
|
47
|
-
|
|
48
|
-
logout().then(res => {
|
|
49
|
-
if (res) {
|
|
50
|
-
// true 登出成功,会自动跳转到登录页面
|
|
51
|
-
} else {
|
|
52
|
-
// false 登出失败
|
|
53
|
-
}
|
|
29
|
+
logout().then(() => {
|
|
30
|
+
// 退出登陆成功
|
|
31
|
+
}).catch(() => {
|
|
32
|
+
// 可以不用管
|
|
54
33
|
})
|
|
55
|
-
```
|
|
34
|
+
```
|
|
35
|
+
> tenantId、brand、moduleName 枚举值可以在 login-authorization-v2 包内的 `./dist/src/types.d.ts` 文件中查看
|
|
36
|
+
|
|
37
|
+
### 新增方法
|
|
38
|
+
#### main
|
|
39
|
+
1. make(options: MakeFnParams): { init, logout }
|
|
40
|
+
2. init(params: InitParams): Promise<MenuItem[]>
|
|
41
|
+
3. logout(): Promise<void>
|
|
42
|
+
|
|
43
|
+
#### cookie 相关方法
|
|
44
|
+
1. setAccessToken(string | null): void
|
|
45
|
+
2. getAccessToken(): string | undefined
|
|
46
|
+
3. setRefreshToken(string | null): void
|
|
47
|
+
4. getRefreshToken(): string | undefined
|
|
48
|
+
5. setSystemType(string | null): void
|
|
49
|
+
6. getSystemType(): string | undefined
|
|
50
|
+
|
|
51
|
+
#### 工具函数
|
|
52
|
+
1. isMobile(): boolean // 判断当前环境是否为移动端
|
|
53
|
+
2. getUserInfo(): Promise<UserInfo | null> // 获取当前用户信息
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
export * from './src/cookie';
|
|
2
2
|
export * from './src/compatible';
|
|
3
|
-
|
|
3
|
+
export * from './src/utils';
|
|
4
|
+
import { Brand, type ModuleName, Tenant } from './src/types';
|
|
4
5
|
type MakeFnParams = {
|
|
5
|
-
brand: Brand;
|
|
6
|
-
tenantId: Tenant;
|
|
7
6
|
moduleName: ModuleName;
|
|
8
7
|
moduleBaseUrl: string;
|
|
9
8
|
loginPageUrl: string;
|
|
10
9
|
};
|
|
10
|
+
type InitFnParams = {
|
|
11
|
+
brand?: Brand;
|
|
12
|
+
tenantId: Tenant;
|
|
13
|
+
};
|
|
11
14
|
export declare const make: (config: MakeFnParams) => {
|
|
12
|
-
init: () => Promise<
|
|
15
|
+
init: (initConfig: InitFnParams) => Promise<{
|
|
16
|
+
groupName: ModuleName;
|
|
17
|
+
icon: string;
|
|
18
|
+
id: number;
|
|
19
|
+
label: string;
|
|
20
|
+
staffEndpoint: boolean;
|
|
21
|
+
url: string;
|
|
22
|
+
}[]>;
|
|
13
23
|
logout: () => Promise<import("axios").AxiosResponse<any, any>>;
|
|
14
24
|
};
|
|
15
25
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAO3B,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAc,MAAM,EAAiB,MAAM,aAAa,CAAA;AAGvF,KAAK,YAAY,GAAG;IAClB,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,KAAK,YAAY,GAAG;IAClB,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,IAAI,GAAI,QAAQ,YAAY;uBAUb,YAAY;;;;;;;;;CAmIvC,CAAA"}
|