qlfy-ecological-login 1.0.1 → 1.0.3
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 +123 -0
- package/lib/components/qlfyEcologicalLogin/EditForm.vue.d.ts +11 -0
- package/lib/components/qlfyEcologicalLogin/data.d.ts +6 -15
- package/lib/components/qlfyEcologicalLogin/index.vue.d.ts +5 -19
- package/lib/components/qlfyEcologicalLogin/tools.d.ts +15 -4
- package/lib/index.d.ts +5 -18
- package/lib/index.mjs +2804 -1097
- package/lib/index.mjs.gz +0 -0
- package/lib/index.umd.js +11 -6
- package/lib/index.umd.js.gz +0 -0
- package/package.json +1 -1
- package/README +0 -60
package/README.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#### 简介
|
|
2
|
+
|
|
3
|
+
生态工程项目群统一认证登陆功能的逻辑插件,主体功能无实际渲染标签,内置统一登陆跳转、统一登录token获取、token效验、用户数据配置获取、密码修改登功能;
|
|
4
|
+
|
|
5
|
+
仅可在全局范围内加载使用(app.vue),全局仅可使用一次,多次使用,仅初次加载处使用有效;
|
|
6
|
+
|
|
7
|
+
#### 下载
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm i qlfy-ecological-login
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
#### 使用一、局部注册(推荐)
|
|
14
|
+
|
|
15
|
+
例:app.vue
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<template>
|
|
19
|
+
<div class="system-content" v-loading="loading" style="width: 100vw; height: 100vh">
|
|
20
|
+
<qlfyEcologicalLogin
|
|
21
|
+
client-id="xxxx"
|
|
22
|
+
client-secret="xxxx"
|
|
23
|
+
login-page-base-address="http://10.76.34.53:8200/auth"
|
|
24
|
+
login-service-base-address="http://10.76.34.53:48081"
|
|
25
|
+
:use-router="useRouter()"
|
|
26
|
+
@loggingIn="loggingIn"
|
|
27
|
+
@login-success="loginSuccess"
|
|
28
|
+
:token="$counterStore.token"
|
|
29
|
+
></qlfyEcologicalLogin>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
import { ref } from 'vue'
|
|
35
|
+
import { qlfyEcologicalLogin } from 'qlfy-ecological-login'
|
|
36
|
+
import { openChangePassword, closeChangePassword, setDialogConfig } from 'qlfy-ecological-login'
|
|
37
|
+
import { useRoute, useRouter } from 'vue-router'
|
|
38
|
+
import { useCounterStore } from '@/stores/counter'
|
|
39
|
+
// pinia管理对象
|
|
40
|
+
const $counterStore = useCounterStore()
|
|
41
|
+
// 系统loading
|
|
42
|
+
const loading = ref(true)
|
|
43
|
+
// 登陆中
|
|
44
|
+
function loggingIn() {
|
|
45
|
+
loading.value = true
|
|
46
|
+
}
|
|
47
|
+
// 登陆成功
|
|
48
|
+
function loginSuccess() {
|
|
49
|
+
loading.value = false
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<style scoped></style>
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### 使用二、全局注册
|
|
58
|
+
|
|
59
|
+
main.ts
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
// 导入
|
|
63
|
+
import qlfyEcologicalLogin from 'qlfy-ecological-login'
|
|
64
|
+
// 注册
|
|
65
|
+
app.use(qlfyEcologicalLogin)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
#### 组件参数
|
|
71
|
+
|
|
72
|
+
| 属性名 | 说明 | 类型 | 默认值 |
|
|
73
|
+
| ----------------------- | ------------------------------------------------------------ | -------------------- | -------------- |
|
|
74
|
+
| clientId | 应用id,统一认证平台提供,必填 | string | —— |
|
|
75
|
+
| clientSecret | 应用秘钥,统一认证平台提供,必填 | string | —— |
|
|
76
|
+
| loginPageBaseAddress | 登陆页面基础地址,必填 | string | —— |
|
|
77
|
+
| loginServiceBaseAddress | 登录服务基础地址,必填 | string | —— |
|
|
78
|
+
| useRouter | 路由对象,传入vue-Router的useRouter()值 | Router | —— |
|
|
79
|
+
| token | 自定义token<br />传入该值后,如果token有效,不跳登陆直接使用该token | stirng | ‘’ |
|
|
80
|
+
| isEnabled | 是否启用组件,支持动态控制 | boolean | true |
|
|
81
|
+
| listenToken | 实时监听token状态<br />1s检测一次token是否存在,丢失触发重新获取 | boolean | false |
|
|
82
|
+
| redirectPath | 统一登陆成功后,跳转的地址;<br />如不设置,默认跳转至触发登陆的页面 | string | ‘’ |
|
|
83
|
+
| tokenName | local中保存token值的键名称 | string | 'access_token' |
|
|
84
|
+
| tokenValidity | token过期时间,单位秒<br />如该时间内无页面跳转操作则重新触发登陆 | number | 1800 |
|
|
85
|
+
| tenantId | 租户id<br />非特殊要求不需传该参数 | number | ‘’ |
|
|
86
|
+
| dialogConfig | 密码修改弹窗组件参数配置<br />内部支持属性参考element+ el-dialog组件 | Partial<DialogProps> | {} |
|
|
87
|
+
|
|
88
|
+
#### 组件事件
|
|
89
|
+
|
|
90
|
+
| 事件名 | 说明 | 类型 |
|
|
91
|
+
| ------------ | ------------------------------------------ | ------------------------------------------ |
|
|
92
|
+
| loginSuccess | 初次加载,用户权限登陆获取成功后触发该事件 | Function:(userPermission:Object ) => void |
|
|
93
|
+
| loggingIn | 从统一认证平台返回后触发该事件 | Function:( token:string) => void |
|
|
94
|
+
|
|
95
|
+
#### 组件暴露内容
|
|
96
|
+
|
|
97
|
+
| 方法名 | 说明 | 类型 |
|
|
98
|
+
| ----------------- | ---------------------- | -------------------- |
|
|
99
|
+
| logout | 退出登陆 | Function:()=>void |
|
|
100
|
+
| getToken | 获取当前使用的token | Function:()=>string |
|
|
101
|
+
| getUserPermission | 获取当前用户的权限信息 | Function:()=>Object |
|
|
102
|
+
|
|
103
|
+
#### 插件导出
|
|
104
|
+
|
|
105
|
+
可在任意位置导入并使用该插件提供的工具方法、对象,实现相关操作功能
|
|
106
|
+
|
|
107
|
+
导入方法 :
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
import {xxx} from 'qlfy-ecological-login'
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
| 方法名 | 说明 | 类型 |
|
|
114
|
+
| ------------------------ | ------------------------------- | ---------------------------------------- |
|
|
115
|
+
| qlfyEcologicalLogin | 统一登陆组件 | vue组件 |
|
|
116
|
+
| qlfyEcologicalLoginProps | 统一登陆插件接口对象 | interface |
|
|
117
|
+
| LocalStorageManager | LocalStorage工具类 | 类 |
|
|
118
|
+
| logout | 退出登陆 | Function:()=>void |
|
|
119
|
+
| getToken | 获取当前使用的token | Function:()=>string |
|
|
120
|
+
| getUserPermission | 获取当前用户的权限信息 | Function:()=>Object |
|
|
121
|
+
| openChangePassword | 打开密码修改弹窗 | Function:()=>void |
|
|
122
|
+
| closeChangePassword | 关闭密码修改弹窗 | Function:()=>void |
|
|
123
|
+
| setDialogConfig | 设置密码修改弹窗el-dialog的属性 | Function:(Partial<DialogProps>)=>void |
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DialogProps } from 'element-plus';
|
|
2
|
+
/** 组件参数管理对象 */
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
dialogConfig: Partial<DialogProps>;
|
|
5
|
+
};
|
|
6
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
7
|
+
dialogConfig: Partial<DialogProps>;
|
|
8
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
9
|
+
formRef: unknown;
|
|
10
|
+
}, any>;
|
|
11
|
+
export default _default;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Router } from 'vue-router';
|
|
2
|
+
import { DialogProps } from 'element-plus';
|
|
2
3
|
/** 响应式数据对象 */
|
|
3
4
|
export declare class Data {
|
|
4
5
|
}
|
|
@@ -13,41 +14,31 @@ export interface Prop {
|
|
|
13
14
|
/** 应用秘钥,平台提供*/
|
|
14
15
|
clientSecret: string;
|
|
15
16
|
/** 统一登陆页面的ip地址 */
|
|
16
|
-
|
|
17
|
+
loginPageBaseAddress: string;
|
|
17
18
|
/** 登陆服务的ip地址 */
|
|
18
|
-
|
|
19
|
+
loginServiceBaseAddress: string;
|
|
19
20
|
/** 路由对象 */
|
|
20
21
|
useRouter: Router;
|
|
21
|
-
/** 统一认证的登录信息,如传入该值,则不触发登陆,直接使用传入的用户信息,非必填*/
|
|
22
|
-
loginInfo?: LoginInfo;
|
|
23
22
|
/** 传入token则使用外部token */
|
|
24
23
|
token?: string;
|
|
25
24
|
/** 是否启用组件,支持动态控制,非必填*/
|
|
26
25
|
isEnabled?: boolean;
|
|
27
|
-
/** 是否开启路由变动时自动刷新token功能*/
|
|
28
26
|
/** 是否实时监听token状态,非必填*/
|
|
29
27
|
listenToken?: boolean;
|
|
30
28
|
/** 认证成功后的,非必填*/
|
|
31
29
|
redirectPath?: string;
|
|
32
30
|
/** local中保存token值的键名称,非必填*/
|
|
33
31
|
tokenName?: string;
|
|
34
|
-
/** token自动更新的时间间隔,单位秒,非必填*/
|
|
35
|
-
refreshInterval?: number;
|
|
36
32
|
/** token有效期,单位秒,非必填*/
|
|
37
33
|
tokenValidity?: number;
|
|
38
34
|
/** 租户id */
|
|
39
35
|
tenantId?: number;
|
|
36
|
+
/** 修改密码弹窗自定义设置 */
|
|
37
|
+
dialogConfig?: Partial<DialogProps>;
|
|
40
38
|
}
|
|
41
39
|
export interface Emits {
|
|
42
|
-
(e: 'loggingIn',
|
|
43
|
-
code: string | string[];
|
|
44
|
-
grant_type: string;
|
|
45
|
-
state: number;
|
|
46
|
-
}): void;
|
|
40
|
+
(e: 'loggingIn', token: string): void;
|
|
47
41
|
(e: 'loginSuccess', loginInfo: {
|
|
48
42
|
[x: string]: any;
|
|
49
43
|
}): void;
|
|
50
|
-
(e: 'tokenChange', loginInfo: {
|
|
51
|
-
[x: string]: any;
|
|
52
|
-
}): void;
|
|
53
44
|
}
|
|
@@ -1,40 +1,26 @@
|
|
|
1
|
+
import { DialogProps } from 'element-plus';
|
|
1
2
|
import { Prop } from './data';
|
|
2
|
-
import { logout, getToken,
|
|
3
|
+
import { logout, getToken, getUserPermission } from './tools';
|
|
3
4
|
declare const _default: import('vue').DefineComponent<Prop, {
|
|
4
5
|
logout: typeof logout;
|
|
5
6
|
getToken: typeof getToken;
|
|
6
|
-
getLoginInfo: typeof getLoginInfo;
|
|
7
7
|
getUserPermission: typeof getUserPermission;
|
|
8
8
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
9
|
-
loggingIn: (
|
|
10
|
-
code: string | string[];
|
|
11
|
-
grant_type: string;
|
|
12
|
-
state: number;
|
|
13
|
-
}) => any;
|
|
9
|
+
loggingIn: (token: string) => any;
|
|
14
10
|
loginSuccess: (loginInfo: {
|
|
15
11
|
[x: string]: any;
|
|
16
12
|
}) => any;
|
|
17
|
-
tokenChange: (loginInfo: {
|
|
18
|
-
[x: string]: any;
|
|
19
|
-
}) => any;
|
|
20
13
|
}, string, import('vue').PublicProps, Readonly<Prop> & Readonly<{
|
|
21
|
-
onLoggingIn?: (
|
|
22
|
-
code: string | string[];
|
|
23
|
-
grant_type: string;
|
|
24
|
-
state: number;
|
|
25
|
-
}) => any;
|
|
14
|
+
onLoggingIn?: (token: string) => any;
|
|
26
15
|
onLoginSuccess?: (loginInfo: {
|
|
27
16
|
[x: string]: any;
|
|
28
17
|
}) => any;
|
|
29
|
-
onTokenChange?: (loginInfo: {
|
|
30
|
-
[x: string]: any;
|
|
31
|
-
}) => any;
|
|
32
18
|
}>, {
|
|
19
|
+
dialogConfig: Partial<DialogProps>;
|
|
33
20
|
isEnabled: boolean;
|
|
34
21
|
listenToken: boolean;
|
|
35
22
|
redirectPath: string;
|
|
36
23
|
tokenName: string;
|
|
37
|
-
refreshInterval: number;
|
|
38
24
|
tokenValidity: number;
|
|
39
25
|
tenantId: number;
|
|
40
26
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DialogProps } from 'element-plus';
|
|
1
2
|
export declare const componentState: any;
|
|
2
3
|
/** 退出登陆方法 */
|
|
3
4
|
export declare function logout(): any;
|
|
@@ -5,16 +6,26 @@ export declare function logout(): any;
|
|
|
5
6
|
export declare function getToken(): any;
|
|
6
7
|
/** 方法 -- 跳转至登陆页 */
|
|
7
8
|
export declare function goLogin(): void;
|
|
8
|
-
/** 获取统一认证登陆返回信息 */
|
|
9
|
-
export declare function getLoginInfo(): any;
|
|
10
9
|
/**
|
|
11
10
|
* @description 获取跳转至登录页的链接
|
|
12
|
-
* @param {string}
|
|
11
|
+
* @param {string} loginPageBaseAddress 登录页ip地址
|
|
13
12
|
* @param {string} clientId 应用id
|
|
14
13
|
* @param {string} clientSecret 应用密钥
|
|
15
14
|
* @param {string} redirectUrl 重定向地址
|
|
16
15
|
* @returns {string}
|
|
17
16
|
*/
|
|
18
|
-
export declare function getLoginUrl(
|
|
17
|
+
export declare function getLoginUrl(loginPageBaseAddress: string, clientId: string, clientSecret: string, tenantId: string, redirectUrl?: string): string;
|
|
19
18
|
export declare function generateUUID(): string;
|
|
20
19
|
export declare function getUserPermission(): any;
|
|
20
|
+
/** ----------------------- 密码弹窗 ---------------------- */
|
|
21
|
+
/** 密码修改弹窗控制 */
|
|
22
|
+
export declare let dialogStatus: {
|
|
23
|
+
isShow: boolean;
|
|
24
|
+
elDialogConfig: {};
|
|
25
|
+
};
|
|
26
|
+
/** 方法 -- 显示密码弹窗 */
|
|
27
|
+
export declare function openChangePassword(): void;
|
|
28
|
+
/** 方法 -- 显示密码弹窗 */
|
|
29
|
+
export declare function closeChangePassword(): void;
|
|
30
|
+
/** 弹窗配置设置方法 */
|
|
31
|
+
export declare function setDialogConfig(config: Partial<DialogProps>): void;
|
package/lib/index.d.ts
CHANGED
|
@@ -2,38 +2,23 @@
|
|
|
2
2
|
export declare const qlfyEcologicalLogin: import('vue').DefineComponent<import('.').qlfyEcologicalLoginProps, {
|
|
3
3
|
logout: typeof import('.').logout;
|
|
4
4
|
getToken: typeof import('.').getToken;
|
|
5
|
-
getLoginInfo: typeof import('./components/qlfyEcologicalLogin/tools').getLoginInfo;
|
|
6
5
|
getUserPermission: typeof import('.').getUserPermission;
|
|
7
6
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
8
|
-
loggingIn: (
|
|
9
|
-
code: string | string[];
|
|
10
|
-
grant_type: string;
|
|
11
|
-
state: number;
|
|
12
|
-
}) => any;
|
|
7
|
+
loggingIn: (token: string) => any;
|
|
13
8
|
loginSuccess: (loginInfo: {
|
|
14
9
|
[x: string]: any;
|
|
15
10
|
}) => any;
|
|
16
|
-
tokenChange: (loginInfo: {
|
|
17
|
-
[x: string]: any;
|
|
18
|
-
}) => any;
|
|
19
11
|
}, string, import('vue').PublicProps, Readonly<import('.').qlfyEcologicalLoginProps> & Readonly<{
|
|
20
|
-
onLoggingIn?: (
|
|
21
|
-
code: string | string[];
|
|
22
|
-
grant_type: string;
|
|
23
|
-
state: number;
|
|
24
|
-
}) => any;
|
|
12
|
+
onLoggingIn?: (token: string) => any;
|
|
25
13
|
onLoginSuccess?: (loginInfo: {
|
|
26
14
|
[x: string]: any;
|
|
27
15
|
}) => any;
|
|
28
|
-
onTokenChange?: (loginInfo: {
|
|
29
|
-
[x: string]: any;
|
|
30
|
-
}) => any;
|
|
31
16
|
}>, {
|
|
17
|
+
dialogConfig: Partial<import('element-plus').DialogProps>;
|
|
32
18
|
isEnabled: boolean;
|
|
33
19
|
listenToken: boolean;
|
|
34
20
|
redirectPath: string;
|
|
35
21
|
tokenName: string;
|
|
36
|
-
refreshInterval: number;
|
|
37
22
|
tokenValidity: number;
|
|
38
23
|
tenantId: number;
|
|
39
24
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
@@ -41,6 +26,8 @@ export declare const qlfyEcologicalLogin: import('vue').DefineComponent<import('
|
|
|
41
26
|
export type { Prop as qlfyEcologicalLoginProps, Emits } from './components/qlfyEcologicalLogin/data';
|
|
42
27
|
/** 导出工具 */
|
|
43
28
|
export { logout, getToken, getUserPermission } from './components/qlfyEcologicalLogin/tools';
|
|
29
|
+
/** 导出密码弹窗操作方法 */
|
|
30
|
+
export { openChangePassword, closeChangePassword, setDialogConfig } from './components/qlfyEcologicalLogin/tools';
|
|
44
31
|
/** localStorage */
|
|
45
32
|
export * as LocalStorageManager from './components/qlfyEcologicalLogin/LocalStorageManager';
|
|
46
33
|
/** 默认导出install注册方法 */
|