qlfy-ecological-login 1.1.10 → 1.2.0

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.
@@ -0,0 +1,31 @@
1
+ /** 检测浏览器是否支持IndexedDB */
2
+ export declare function isIndexedDBSupported(): boolean;
3
+ /** 统一数据管理接口 */
4
+ export interface IDataManager {
5
+ set(key: string, value: any): Promise<void> | void;
6
+ get(key: string): Promise<any> | any;
7
+ remove(key: string): Promise<void> | void;
8
+ }
9
+ /** IndexedDB数据管理器包装类 */
10
+ export declare class IndexedDBDataManager implements IDataManager {
11
+ private indexedDBManager;
12
+ private isInitialized;
13
+ constructor();
14
+ private ensureInitialized;
15
+ set(key: string, value: any): Promise<void>;
16
+ get(key: string): Promise<any>;
17
+ remove(key: string): Promise<void>;
18
+ }
19
+ /** LocalStorage数据管理器包装类 */
20
+ export declare class LocalStorageDataManager implements IDataManager {
21
+ private localStorageManager;
22
+ constructor();
23
+ set(key: string, value: any): void;
24
+ get(key: string): any;
25
+ remove(key: string): void;
26
+ }
27
+ /**
28
+ * 获取文件管理对象
29
+ * @returns {IDataManager}
30
+ */
31
+ export default function getDataManager(): IDataManager;
@@ -1,11 +1,41 @@
1
+ import { LoginInfo as UserLoginInfo } from './data';
2
+ /** ----------------------- 组件数据操作 ---------------------- */
3
+ interface LoginInfo {
4
+ /** 角色id */
5
+ tenant_id: string | number;
6
+ /** 组件参数 */
7
+ props: any;
8
+ /** token */
9
+ token: string;
10
+ /** 登陆信息 */
11
+ loginInfo: any;
12
+ /** 是否为外源token */
13
+ isOutLogin: boolean;
14
+ /** 用户权限配置 */
15
+ userPermission: any;
16
+ /** 当前路由模式 */
17
+ routerMode: 'history' | 'hash';
18
+ refreshToken: string;
19
+ }
20
+ /** 登陆数据存储 */
21
+ export declare function setComponentData(dataInfo: LoginInfo): Promise<void>;
22
+ /** 登陆数据删除 */
23
+ export declare function removeComponentData(): Promise<void>;
24
+ /** 登陆数据获取 */
25
+ export declare function getComponentData(clientId?: string): Promise<LoginInfo>;
26
+ /** ----------------------- 登陆状态操作 ---------------------- */
1
27
  /** 退出登陆方法 */
2
- export declare function logout(isGoLog?: boolean, success?: (res: any) => void, error?: (err: any) => void): void;
3
- /** 获取统一登陆token */
4
- export declare function getToken(): any;
5
- /** 获取统一登陆token */
6
- export declare function getRefreshToken(): string;
28
+ export declare function logout(isGoLog?: boolean, success?: (res: any) => void, error?: (err: any) => void): Promise<void>;
7
29
  /** 方法 -- 跳转至登陆页 */
8
- export declare function goLogin(): void;
30
+ export declare function goLogin(): Promise<void>;
31
+ /** ----------------------- 组件信息获取 ---------------------- */
32
+ /** 获取统一登陆token */
33
+ export declare function getToken(): Promise<string>;
34
+ /** 获取token登陆返回信息 */
35
+ export declare function getLoginInfo(): Promise<UserLoginInfo>;
36
+ export declare function getUserPermission(): Promise<any>;
37
+ /** 获取refreshToken */
38
+ export declare function getRefreshToken(): Promise<string>;
9
39
  /**
10
40
  * @description 获取跳转至登录页的链接
11
41
  * @param {string} loginPageBaseAddress 登录页ip地址
@@ -14,33 +44,23 @@ export declare function goLogin(): void;
14
44
  * @param {string} redirectUrl 重定向地址
15
45
  * @returns {string}
16
46
  */
17
- export declare function getLoginUrl(loginPageBaseAddress: string, clientId: string, clientSecret: string, redirectUrl?: string): string;
18
- export declare function generateUUID(): string;
19
- export declare function getUserPermission(): any;
20
- /** ----------------------- 登陆数据操作 ---------------------- */
21
- interface LoginInfo {
22
- tenantId: string | number;
23
- refreshToken?: string;
24
- userPermission: any;
25
- props: any;
26
- routerMode: string;
27
- }
28
- /** 登陆数据存储 */
29
- export declare function setLoginInfo(dataInfo: LoginInfo): void;
30
- /** 登陆数据删除 */
31
- export declare function removeLoginInfo(): void;
32
- /** 登陆数据数据 */
33
- export declare function getLoginInfo(): LoginInfo;
34
- /** 清除本组件所有缓存数据 */
35
- export declare function clearLoginData(): void;
36
- /** ----------------------- 密码修改 ---------------------- */
37
- export declare function changePassword(newPassword: string, oldPassword: string): Promise<any>;
38
- /**
39
- * 移除URL中指定的参数,不刷新页面
40
- * @param {string} routerMode - 路由模式,'hash' 或 'history'
41
- * @param {string[]} paramsToRemove - 需要移除的参数名称数组
42
- */
47
+ export declare function getLoginUrl(): Promise<string | null>;
43
48
  /** 检测当前路由模式 */
44
49
  export declare function detectRouterMode(): 'hash' | 'history';
45
- export declare function removeUrlParams(paramsToRemove: string[], routerMode?: string): void;
50
+ /**
51
+ * 移除URL中的指定参数
52
+ * @param paramsToRemove 需要移除的参数名数组
53
+ * @param routerMode 路由模式,默认为 'hash'
54
+ * @param nowUrl 原始URL
55
+ * @returns 移除参数后的新URL
56
+ */
57
+ export declare function removeUrlParams(paramsToRemove: string[], isAsync?: boolean, nowUrl?: string, routerMode?: string): Promise<string>;
58
+ /** 数据深拷贝 */
59
+ export declare function deepClone(obj: any): any;
60
+ /**
61
+ * 判断当前Vue Router是否为hash模式
62
+ * @param router Vue Router实例(兼容2.x/3.x/4.x)
63
+ * @returns 是否为hash模式
64
+ */
65
+ export declare function isHashMode(router: any): boolean;
46
66
  export {};
@@ -0,0 +1,30 @@
1
+ export default class LocalStorageManager {
2
+ /**
3
+ * 设置存储项
4
+ * @param {string} key - 存储键名
5
+ * @param {*} value - 存储值
6
+ * @param {number} [seconds] - 有效期(秒)
7
+ */
8
+ set(key: string, value: any, seconds?: number | undefined): void;
9
+ /**
10
+ * 获取存储项
11
+ * @param {string} key - 要获取的键名
12
+ * @returns {*|null} 存储值或null
13
+ */
14
+ get(key: string): any;
15
+ /**
16
+ * 获取原始存储数据(内部方法)
17
+ * @param {string} key - 要获取的键名
18
+ * @returns {Object|null} 包含值和过期时间的对象或null
19
+ */
20
+ getRaw(key: string): any;
21
+ /**
22
+ * 删除指定存储项
23
+ * @param {string} key - 要删除的键名
24
+ */
25
+ remove(key: string): void;
26
+ /**
27
+ * 清空所有存储项
28
+ */
29
+ clear(): void;
30
+ }
@@ -0,0 +1,41 @@
1
+ import { DialogProps } from 'element-plus';
2
+ /** 响应式数据对象 */
3
+ export declare class Data {
4
+ }
5
+ export interface Prop {
6
+ /** 应用id,平台提供*/
7
+ clientId: string;
8
+ /** 应用秘钥,平台提供*/
9
+ clientSecret: string;
10
+ /** 统一登陆页面的ip地址 */
11
+ loginPageBaseAddress: string;
12
+ /** 登陆服务的ip地址 */
13
+ loginServiceBaseAddress: string;
14
+ /** 路由对象 */
15
+ useRouter: any;
16
+ /** 强制登陆模式 */
17
+ forceMode?: boolean;
18
+ /** 传入token则使用外部token */
19
+ token?: string;
20
+ /** 是否启用组件,支持动态控制,非必填*/
21
+ isEnabled?: boolean;
22
+ /** 是否实时监听token状态,非必填*/
23
+ listenToken?: boolean;
24
+ /** 认证成功后的,非必填*/
25
+ redirectPath?: string;
26
+ /** local中保存token值的键名称,非必填*/
27
+ tokenName?: string;
28
+ /** token有效期,单位秒,非必填*/
29
+ tokenValidity?: number;
30
+ /** 租户id */
31
+ tenantId?: number | string;
32
+ /** 修改密码弹窗自定义设置 */
33
+ dialogConfig?: Partial<DialogProps>;
34
+ }
35
+ export interface Emits {
36
+ (e: 'loggingIn', token: string): void;
37
+ (e: 'loginFail', failInfo: any): void;
38
+ (e: 'loginSuccess', loginInfo: {
39
+ [x: string]: any;
40
+ }): void;
41
+ }
@@ -0,0 +1,46 @@
1
+ /** 退出登陆方法 */
2
+ export declare function logout(isGoLog?: boolean, success?: (res: any) => void, error?: (err: any) => void): void;
3
+ /** 获取统一登陆token */
4
+ export declare function getToken(): any;
5
+ /** 获取统一登陆token */
6
+ export declare function getRefreshToken(): string;
7
+ /** 方法 -- 跳转至登陆页 */
8
+ export declare function goLogin(): void;
9
+ /**
10
+ * @description 获取跳转至登录页的链接
11
+ * @param {string} loginPageBaseAddress 登录页ip地址
12
+ * @param {string} clientId 应用id
13
+ * @param {string} clientSecret 应用密钥
14
+ * @param {string} redirectUrl 重定向地址
15
+ * @returns {string}
16
+ */
17
+ export declare function getLoginUrl(loginPageBaseAddress: string, clientId: string, clientSecret: string, redirectUrl?: string): string;
18
+ export declare function generateUUID(): string;
19
+ export declare function getUserPermission(): any;
20
+ /** ----------------------- 登陆数据操作 ---------------------- */
21
+ interface LoginInfo {
22
+ tenantId: string | number;
23
+ refreshToken?: string;
24
+ userPermission: any;
25
+ props: any;
26
+ routerMode: string;
27
+ }
28
+ /** 登陆数据存储 */
29
+ export declare function setLoginInfo(dataInfo: LoginInfo): void;
30
+ /** 登陆数据删除 */
31
+ export declare function removeLoginInfo(): void;
32
+ /** 登陆数据数据 */
33
+ export declare function getLoginInfo(): LoginInfo;
34
+ /** 清除本组件所有缓存数据 */
35
+ export declare function clearLoginData(): void;
36
+ /** ----------------------- 密码修改 ---------------------- */
37
+ export declare function changePassword(newPassword: string, oldPassword: string): Promise<any>;
38
+ /**
39
+ * 移除URL中指定的参数,不刷新页面
40
+ * @param {string} routerMode - 路由模式,'hash' 或 'history'
41
+ * @param {string[]} paramsToRemove - 需要移除的参数名称数组
42
+ */
43
+ /** 检测当前路由模式 */
44
+ export declare function detectRouterMode(): 'hash' | 'history';
45
+ export declare function removeUrlParams(paramsToRemove: string[], routerMode?: string): void;
46
+ export {};
package/lib/index.d.ts CHANGED
@@ -1,33 +1,39 @@
1
1
  /** 导出组件 */
2
2
  export declare const qlfyEcologicalLogin: import('vue').DefineComponent<import('.').qlfyEcologicalLoginProps, {
3
- logout: typeof import('.').logout;
4
- getToken: typeof import('.').getToken;
5
- getUserPermission: typeof import('.').getUserPermission;
3
+ logout: () => Promise<void>;
4
+ getToken: () => Promise<string>;
5
+ getLoginInfo: () => Promise<import('./components/qlfyEcologicalLogin/data').LoginInfo>;
6
+ goLogin: () => Promise<void>;
6
7
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
7
- loggingIn: (token: string) => any;
8
- loginFail: (failInfo: any) => any;
8
+ loggingIn: (code: String, loginInfo?: any) => any;
9
9
  loginSuccess: (loginInfo: {
10
10
  [x: string]: any;
11
11
  }) => any;
12
+ loginFail: (failInfo: any) => any;
13
+ tokenRefresh: (loginInfo: {
14
+ [x: string]: any;
15
+ }) => any;
12
16
  }, string, import('vue').PublicProps, Readonly<import('.').qlfyEcologicalLoginProps> & Readonly<{
13
- onLoggingIn?: (token: string) => any;
14
- onLoginFail?: (failInfo: any) => any;
17
+ onLoggingIn?: (code: String, loginInfo?: any) => any;
15
18
  onLoginSuccess?: (loginInfo: {
16
19
  [x: string]: any;
17
20
  }) => any;
21
+ onLoginFail?: (failInfo: any) => any;
22
+ onTokenRefresh?: (loginInfo: {
23
+ [x: string]: any;
24
+ }) => any;
18
25
  }>, {
19
- tenantId: number | string;
20
26
  forceMode: boolean;
21
27
  isEnabled: boolean;
22
- listenToken: boolean;
23
28
  redirectPath: string;
24
- tokenName: string;
25
- tokenValidity: number;
29
+ tenantId: number | string;
30
+ showLog: boolean;
31
+ openDebugger: boolean;
26
32
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
27
33
  /** 组件参数、事件接口 */
28
34
  export type { Prop as qlfyEcologicalLoginProps, Emits } from './components/qlfyEcologicalLogin/data';
29
35
  /** 导出工具 */
30
- export { logout, getToken, getRefreshToken, getUserPermission } from './components/qlfyEcologicalLogin/tools';
36
+ export { logout, goLogin, getToken, getRefreshToken, getUserPermission } from './components/qlfyEcologicalLogin/tools';
31
37
  /** 默认导出install注册方法 */
32
38
  declare const _default: {
33
39
  install(app: any): void;