@pubinfo/module-auth 2.0.0-beta.27 → 2.0.0-beta.29
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/dist/index.d.ts +2 -2
- package/dist/index.js +9 -3
- package/dist/{interface-BStwVrS7.d.ts → interface-XUOeLcLn.d.ts} +5 -0
- package/dist/providers/4A.d.ts +1 -1
- package/dist/providers/credentials.d.ts +1 -1
- package/dist/providers/ding-zj.d.ts +1 -1
- package/package.json +4 -4
- package/src/index.ts +11 -5
- package/src/interface.ts +6 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ModuleOptions } from 'pubinfo';
|
|
2
|
-
import { A as AuthConfig, T as ThirdParty, R as Recordable, a as AuthOptions } from './interface-
|
|
3
|
-
export { d as Authorization, F as Fn, b as FnApi, c as ProviderConfig, P as ProviderUserConfig } from './interface-
|
|
2
|
+
import { A as AuthConfig, T as ThirdParty, R as Recordable, a as AuthOptions } from './interface-XUOeLcLn.js';
|
|
3
|
+
export { d as Authorization, F as Fn, b as FnApi, c as ProviderConfig, P as ProviderUserConfig } from './interface-XUOeLcLn.js';
|
|
4
4
|
import 'vue-router';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/index.js
CHANGED
|
@@ -127,7 +127,13 @@ function createUrl(provider) {
|
|
|
127
127
|
// src/index.ts
|
|
128
128
|
function withModule(auth, options = {}) {
|
|
129
129
|
const { authentication, redirect } = auth;
|
|
130
|
-
const {
|
|
130
|
+
const {
|
|
131
|
+
redirectTo = "/",
|
|
132
|
+
pages = {}
|
|
133
|
+
} = options;
|
|
134
|
+
const {
|
|
135
|
+
signIn = "/login"
|
|
136
|
+
} = pages;
|
|
131
137
|
return {
|
|
132
138
|
name: "pubinfo:auth",
|
|
133
139
|
enforce: "pre",
|
|
@@ -144,7 +150,7 @@ function withModule(auth, options = {}) {
|
|
|
144
150
|
props: (route) => ({
|
|
145
151
|
type: route.params.type,
|
|
146
152
|
redirectTo() {
|
|
147
|
-
router.push(redirectTo
|
|
153
|
+
router.push(redirectTo);
|
|
148
154
|
},
|
|
149
155
|
authentication
|
|
150
156
|
})
|
|
@@ -157,7 +163,7 @@ function withModule(auth, options = {}) {
|
|
|
157
163
|
if (to.name === ROUTE_AUTH.name) {
|
|
158
164
|
cleanup();
|
|
159
165
|
}
|
|
160
|
-
if (to.
|
|
166
|
+
if (to.path === signIn) {
|
|
161
167
|
redirect();
|
|
162
168
|
}
|
|
163
169
|
});
|
|
@@ -6,6 +6,11 @@ type FnApi<T = any> = (params: Recordable & T, baseURL: string) => Promise<any>;
|
|
|
6
6
|
interface AuthOptions {
|
|
7
7
|
/** 登录后重定向至 */
|
|
8
8
|
redirectTo?: RouteLocationRaw;
|
|
9
|
+
/** 页面配置 */
|
|
10
|
+
pages?: {
|
|
11
|
+
/** 默认登录页 */
|
|
12
|
+
signIn?: RouteLocationRaw;
|
|
13
|
+
};
|
|
9
14
|
}
|
|
10
15
|
interface AuthConfig {
|
|
11
16
|
/** 接口的baseURL */
|
package/dist/providers/4A.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubinfo/module-auth",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.29",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"src"
|
|
21
21
|
],
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"pubinfo": "2.0.0-beta.
|
|
23
|
+
"pubinfo": "2.0.0-beta.29"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"tsup": "^8.
|
|
27
|
-
"pubinfo": "2.0.0-beta.
|
|
26
|
+
"tsup": "^8.5.0",
|
|
27
|
+
"pubinfo": "2.0.0-beta.29"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"dev": "tsup --watch src",
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,13 @@ import { PageAuth } from './pages/auth';
|
|
|
7
7
|
|
|
8
8
|
export function withModule(auth: ReturnType<typeof createAuth>, options: AuthOptions = {}): ModuleOptions {
|
|
9
9
|
const { authentication, redirect } = auth;
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
redirectTo = '/',
|
|
12
|
+
pages = {},
|
|
13
|
+
} = options;
|
|
14
|
+
const {
|
|
15
|
+
signIn = '/login',
|
|
16
|
+
} = pages;
|
|
11
17
|
|
|
12
18
|
return {
|
|
13
19
|
name: 'pubinfo:auth',
|
|
@@ -23,16 +29,16 @@ export function withModule(auth: ReturnType<typeof createAuth>, options: AuthOpt
|
|
|
23
29
|
whiteList: true,
|
|
24
30
|
title: '授权登录',
|
|
25
31
|
},
|
|
26
|
-
props:
|
|
32
|
+
props: route => ({
|
|
27
33
|
type: route.params.type,
|
|
28
34
|
redirectTo() {
|
|
29
|
-
router.push(redirectTo
|
|
35
|
+
router.push(redirectTo);
|
|
30
36
|
},
|
|
31
37
|
authentication,
|
|
32
38
|
}),
|
|
33
39
|
};
|
|
34
40
|
|
|
35
|
-
router.beforeEach(to => {
|
|
41
|
+
router.beforeEach((to) => {
|
|
36
42
|
// 注册静态页面
|
|
37
43
|
if (!router.hasRoute(ROUTE_AUTH.name!)) {
|
|
38
44
|
router.addRoute(ROUTE_AUTH);
|
|
@@ -45,7 +51,7 @@ export function withModule(auth: ReturnType<typeof createAuth>, options: AuthOpt
|
|
|
45
51
|
}
|
|
46
52
|
|
|
47
53
|
// 前往登录前,重定向至统一登录页(若有)
|
|
48
|
-
if (to.
|
|
54
|
+
if (to.path === signIn) {
|
|
49
55
|
redirect();
|
|
50
56
|
}
|
|
51
57
|
});
|
package/src/interface.ts
CHANGED
|
@@ -7,6 +7,12 @@ export type FnApi<T = any> = (params: Recordable & T, baseURL: string) => Promis
|
|
|
7
7
|
export interface AuthOptions {
|
|
8
8
|
/** 登录后重定向至 */
|
|
9
9
|
redirectTo?: RouteLocationRaw
|
|
10
|
+
|
|
11
|
+
/** 页面配置 */
|
|
12
|
+
pages?: {
|
|
13
|
+
/** 默认登录页 */
|
|
14
|
+
signIn?: RouteLocationRaw
|
|
15
|
+
}
|
|
10
16
|
}
|
|
11
17
|
|
|
12
18
|
export interface AuthConfig {
|