@pubinfo/module-auth 2.0.4 → 2.0.6

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.
@@ -1,11 +1,11 @@
1
- export declare const LoginWithFourA: import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').DefineComponent<globalThis.ExtractPropTypes<{
1
+ export declare const LoginWithFourA: import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').DefineComponent<import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ExtractPropTypes<{
2
2
  color: {
3
3
  type: StringConstructor;
4
4
  default: string;
5
5
  };
6
- }>, () => globalThis.VNode<import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').RendererNode, import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').RendererElement, {
6
+ }>, () => import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').VNode<import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').RendererNode, import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').RendererElement, {
7
7
  [key: string]: any;
8
- }>, {}, {}, {}, import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ComponentOptionsMixin, import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ComponentOptionsMixin, {}, string, import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').PublicProps, Readonly<globalThis.ExtractPropTypes<{
8
+ }>, {}, {}, {}, import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ComponentOptionsMixin, import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ComponentOptionsMixin, {}, string, import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').PublicProps, Readonly<import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ExtractPropTypes<{
9
9
  color: {
10
10
  type: StringConstructor;
11
11
  default: string;
@@ -1,10 +1,10 @@
1
- export declare const RedirectLogin: import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').DefineComponent<globalThis.ExtractPropTypes<{
1
+ export declare const RedirectLogin: import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').DefineComponent<import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ExtractPropTypes<{
2
2
  id: StringConstructor;
3
3
  src: StringConstructor;
4
4
  color: StringConstructor;
5
- }>, () => globalThis.VNode<import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').RendererNode, import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').RendererElement, {
5
+ }>, () => import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').VNode<import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').RendererNode, import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').RendererElement, {
6
6
  [key: string]: any;
7
- }>, {}, {}, {}, import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ComponentOptionsMixin, import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ComponentOptionsMixin, {}, string, import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').PublicProps, Readonly<globalThis.ExtractPropTypes<{
7
+ }>, {}, {}, {}, import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ComponentOptionsMixin, import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ComponentOptionsMixin, {}, string, import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').PublicProps, Readonly<import('../../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ExtractPropTypes<{
8
8
  id: StringConstructor;
9
9
  src: StringConstructor;
10
10
  color: StringConstructor;
package/dist/index.js CHANGED
@@ -129,10 +129,14 @@ function x(t) {
129
129
  },
130
130
  props: (e) => ({
131
131
  type: e.params.type,
132
+ authentication: h,
132
133
  redirectTo() {
134
+ if (typeof n == "function") {
135
+ n();
136
+ return;
137
+ }
133
138
  r.push(n);
134
- },
135
- authentication: h
139
+ }
136
140
  })
137
141
  };
138
142
  r.beforeEach((t) => {
@@ -4,7 +4,7 @@ export type Fn<T = any, K = any> = (params?: Recordable & T) => Promise<K> | K;
4
4
  export type FnApi<T = any> = (params: Recordable & T, baseURL: string) => Promise<any>;
5
5
  export interface AuthOptions {
6
6
  /** 登录后重定向至 */
7
- redirectTo?: RouteLocationRaw;
7
+ redirectTo?: RouteLocationRaw | Fn;
8
8
  /** 页面配置 */
9
9
  pages?: {
10
10
  /** 默认登录页 */
@@ -1,10 +1,10 @@
1
- export declare const PageAuth: import('../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').DefineComponent<globalThis.ExtractPropTypes<{
1
+ export declare const PageAuth: import('../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').DefineComponent<import('../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ExtractPropTypes<{
2
2
  type: StringConstructor;
3
3
  redirectTo: FunctionConstructor;
4
4
  authentication: FunctionConstructor;
5
- }>, () => globalThis.VNode<import('../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').RendererNode, import('../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').RendererElement, {
5
+ }>, () => import('../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').VNode<import('../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').RendererNode, import('../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').RendererElement, {
6
6
  [key: string]: any;
7
- }>, {}, {}, {}, import('../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ComponentOptionsMixin, import('../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ComponentOptionsMixin, {}, string, import('../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').PublicProps, Readonly<globalThis.ExtractPropTypes<{
7
+ }>, {}, {}, {}, import('../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ComponentOptionsMixin, import('../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ComponentOptionsMixin, {}, string, import('../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').PublicProps, Readonly<import('../../../../node_modules/.pnpm/vue@3.5.17_typescript@5.8.3/node_modules/vue').ExtractPropTypes<{
8
8
  type: StringConstructor;
9
9
  redirectTo: FunctionConstructor;
10
10
  authentication: FunctionConstructor;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pubinfo/module-auth",
3
3
  "type": "module",
4
- "version": "2.0.4",
4
+ "version": "2.0.6",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
@@ -23,10 +23,10 @@
23
23
  "node": "^20.19.0 || >=22.12.0"
24
24
  },
25
25
  "peerDependencies": {
26
- "pubinfo": "2.0.4"
26
+ "pubinfo": "2.0.6"
27
27
  },
28
28
  "devDependencies": {
29
- "pubinfo": "2.0.4"
29
+ "pubinfo": "2.0.6"
30
30
  },
31
31
  "scripts": {
32
32
  "dev": "pubinfo build --watch",
package/src/index.ts CHANGED
@@ -16,7 +16,6 @@ export function auth(options: AuthOptions): ModuleOptions {
16
16
  const { signIn = '/login' } = pages;
17
17
 
18
18
  ctx.set({ baseURL, providers });
19
- // ctx.set 会自动缓存以便 HMR 恢复
20
19
 
21
20
  return {
22
21
  name: 'pubinfo:auth',
@@ -34,10 +33,15 @@ export function auth(options: AuthOptions): ModuleOptions {
34
33
  },
35
34
  props: route => ({
36
35
  type: route.params.type,
36
+ authentication,
37
37
  redirectTo() {
38
+ if (typeof redirectTo === 'function') {
39
+ redirectTo();
40
+ return;
41
+ }
42
+
38
43
  router.push(redirectTo);
39
44
  },
40
- authentication,
41
45
  }),
42
46
  };
43
47
 
package/src/interface.ts CHANGED
@@ -6,7 +6,7 @@ export type FnApi<T = any> = (params: Recordable & T, baseURL: string) => Promis
6
6
 
7
7
  export interface AuthOptions {
8
8
  /** 登录后重定向至 */
9
- redirectTo?: RouteLocationRaw
9
+ redirectTo?: RouteLocationRaw | Fn
10
10
 
11
11
  /** 页面配置 */
12
12
  pages?: {