@vtj/renderer 0.8.163 → 0.8.165

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/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@vtj/renderer",
3
3
  "private": false,
4
- "version": "0.8.163",
4
+ "version": "0.8.165",
5
5
  "type": "module",
6
6
  "dependencies": {
7
7
  "mockjs": "~1.1.0",
8
- "@vtj/core": "~0.8.163",
9
- "@vtj/ui": "~0.8.163",
10
- "@vtj/icons": "~0.8.163",
11
- "@vtj/utils": "~0.8.163"
8
+ "@vtj/core": "~0.8.165",
9
+ "@vtj/icons": "~0.8.165",
10
+ "@vtj/ui": "~0.8.165",
11
+ "@vtj/utils": "~0.8.165"
12
12
  },
13
13
  "devDependencies": {
14
14
  "vue": "~3.5.5",
package/types/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export * from './provider';
5
5
  export * from './render';
6
6
  export * from './services';
7
7
  export * from './hooks';
8
+ export * from './plugins';
@@ -0,0 +1,104 @@
1
+ import { InjectionKey, App } from 'vue';
2
+ import { Router, RouteLocationNormalized } from 'vue-router';
3
+ import { Request } from '@vtj/utils';
4
+ import { ContextMode } from '../constants';
5
+ export interface AccessOptions {
6
+ /**
7
+ * 开启session, token 储存到cookie,关闭浏览器将登录失效
8
+ */
9
+ session: boolean;
10
+ /**
11
+ * 请求头和cookie记录token名称
12
+ */
13
+ authKey: string;
14
+ /**
15
+ * 本地缓存key前缀
16
+ */
17
+ storagePrefix: string;
18
+ /**
19
+ * 本地缓存key
20
+ */
21
+ storageKey: string;
22
+ /**
23
+ * 路由拦截白名单
24
+ */
25
+ whiteList?: string[] | ((to: RouteLocationNormalized) => boolean);
26
+ /**
27
+ * 未授权页面路由路径
28
+ */
29
+ unauthorized?: string | (() => void);
30
+ /**
31
+ * 授权登录页面 pathname
32
+ */
33
+ auth?: string | ((search: string) => void);
34
+ /**
35
+ * 判断是否登录页面
36
+ * @param path
37
+ * @returns
38
+ */
39
+ isAuth?: (to: RouteLocationNormalized) => boolean;
40
+ /**
41
+ * 重定向参数名
42
+ */
43
+ redirectParam?: string;
44
+ /**
45
+ * 未登录响应状态码
46
+ */
47
+ unauthorizedCode?: number;
48
+ /**
49
+ * 提示信息方法
50
+ * @param message
51
+ * @returns
52
+ */
53
+ alert?: (message: string, options: Record<string, any>) => Promise<any>;
54
+ unauthorizedMessage?: string;
55
+ }
56
+ export interface AccessData {
57
+ token: string;
58
+ permissions: Record<string, boolean>;
59
+ [index: string]: any;
60
+ }
61
+ export interface AccessConnectParams {
62
+ /**
63
+ * 请求类
64
+ */
65
+ request?: Request | null;
66
+ /**
67
+ * 路由
68
+ */
69
+ router?: Router | null;
70
+ /**
71
+ * 模式
72
+ */
73
+ mode?: ContextMode;
74
+ }
75
+ export declare const ACCESS_KEY: InjectionKey<Access>;
76
+ export declare class Access {
77
+ private options;
78
+ private data;
79
+ constructor(options: Partial<AccessOptions>);
80
+ connect(params: AccessConnectParams): void;
81
+ login(data: AccessData): void;
82
+ clear(): void;
83
+ logout(): void;
84
+ getData(): AccessData | null;
85
+ can(code: string | string[]): boolean;
86
+ some(code: string | string[]): boolean;
87
+ install(app: App): void;
88
+ private isAuthPath;
89
+ private toLogin;
90
+ private loadData;
91
+ private isLogined;
92
+ private setGuard;
93
+ private guard;
94
+ private isWhiteList;
95
+ private isUnauthorized;
96
+ private showUnauthorizedAlert;
97
+ private setRequest;
98
+ }
99
+ export declare function useAccess(): Access;
100
+ declare module 'vue' {
101
+ interface ComponentCustomProperties {
102
+ $access: Access;
103
+ }
104
+ }
@@ -0,0 +1 @@
1
+ export * from './access';
@@ -2,6 +2,7 @@ import { App, InjectionKey } from 'vue';
2
2
  import { Router } from 'vue-router';
3
3
  import { ProjectSchema, PageFile, BlockFile, Service, BlockSchema, NodeFromPlugin, Base } from '@vtj/core';
4
4
  import { IStaticRequest, Jsonp } from '@vtj/utils';
5
+ import { Access } from '../plugins';
5
6
  import { ContextMode } from '../constants';
6
7
  import { CreateRendererOptions } from '../render';
7
8
  import { Context } from '..';
@@ -28,6 +29,7 @@ export interface ProvideAdapter {
28
29
  request: IStaticRequest;
29
30
  jsonp: Jsonp;
30
31
  metaQuery?: (...args: any[]) => Promise<any>;
32
+ access?: Access;
31
33
  [index: string]: any;
32
34
  }
33
35
  export declare class Provider extends Base {
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2024, VTJ.PRO All rights reserved.
3
3
  * @name @vtj/renderer
4
4
  * @author CHC chenhuachun1549@dingtalk.com
5
- * @version 0.8.162
5
+ * @version 0.8.164
6
6
  * @license <a href="https://vtj.pro/license.html">MIT License</a>
7
7
  */
8
- export declare const version = "0.8.162";
8
+ export declare const version = "0.8.164";