@workopilot/webapp-sdk 0.1.1 → 0.1.2

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 CHANGED
@@ -106,7 +106,7 @@ const menus = await sdk.getRoutePermissions();
106
106
  默认调用:
107
107
 
108
108
  ```text
109
- GET {netBasePath}/app/menu/getRouters
109
+ GET {netBasePath}/api/PluginApp/GetRouters?appCode={appCode}
110
110
  ```
111
111
 
112
112
  返回路由菜单权限数据,宿主项目可以根据结果生成左侧菜单和受保护路由。
package/dist/http.js CHANGED
@@ -107,7 +107,8 @@ export class WiseAiFrontSdk {
107
107
  this.tokenKey = options.tokenKey || 'accessToken';
108
108
  this.tokenStorageKey = options.tokenStorageKey || 'accessToken';
109
109
  this.uploadPath = options.uploadPath || '/api/file/upload';
110
- this.routePermissionPath = options.routePermissionPath || '/app/menu/getRouters';
110
+ this.routePermissionPath =
111
+ options.routePermissionPath || '/api/PluginApp/GetRouters';
111
112
  this.loginRequest = options.loginRequest;
112
113
  }
113
114
  get state() {
@@ -339,12 +340,15 @@ export class WiseAiFrontSdk {
339
340
  });
340
341
  }
341
342
  async getRoutePermissions() {
342
- const response = await this.get(this.routePermissionPath, undefined, {
343
+ const response = await this.get(this.routePermissionPath, { appCode: this.appCode }, {
343
344
  base: 'net',
344
345
  });
345
346
  if (Array.isArray(response)) {
346
347
  return response;
347
348
  }
349
+ if (response.code !== undefined && response.code !== 200) {
350
+ throw new Error(response.msg || 'WiseAiFrontSDK: failed to get route permissions');
351
+ }
348
352
  return response.data || response.rows || [];
349
353
  }
350
354
  clearToken() {
package/dist/index.d.ts CHANGED
@@ -2,6 +2,6 @@ export { decodeJwtPayload, isJwtExpired } from './jwt';
2
2
  export { notifyReloginRequired } from './bridge';
3
3
  import { WiseAiFrontSdk } from './http';
4
4
  export { persistToken, resolveTokenFromStorage } from './storage';
5
- export type { ApiBase, HttpMethod, JwtPayload, LoginCredentials, LoginModalOptions, LoginResult, MenuPermissionNode, RequestBodyType, RequestOptions, UploadOptions, WiseAiEnvironment, WiseAiFrontSdkOptions, WiseAiFrontSdkState, } from './types';
5
+ export type { ApiBase, HttpMethod, JwtPayload, LoginCredentials, LoginModalOptions, LoginResult, MenuPermissionNode, MenuRouteMeta, RequestBodyType, RequestOptions, UploadOptions, WiseAiEnvironment, WiseAiFrontSdkOptions, WiseAiFrontSdkState, } from './types';
6
6
  export { WiseAiFrontSdk } from './http';
7
7
  export declare function createWiseAiFrontSdk(options: import('./types').WiseAiFrontSdkOptions): WiseAiFrontSdk;
package/dist/types.d.ts CHANGED
@@ -34,11 +34,22 @@ export interface JwtPayload {
34
34
  [key: string]: unknown;
35
35
  }
36
36
  export interface MenuPermissionNode {
37
+ alwaysShow?: boolean;
37
38
  children?: MenuPermissionNode[];
39
+ component?: string;
38
40
  hidden?: boolean;
39
41
  icon?: string;
42
+ meta?: MenuRouteMeta;
40
43
  name?: string;
41
44
  path: string;
45
+ query?: string;
46
+ redirect?: string;
47
+ }
48
+ export interface MenuRouteMeta {
49
+ activeMenu?: string;
50
+ icon?: string;
51
+ link?: string;
52
+ noCache?: boolean;
42
53
  title?: string;
43
54
  }
44
55
  export interface RequestOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workopilot/webapp-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "WiseAI front-end SDK for iframe-hosted third-party apps",
5
5
  "keywords": "wiseai,workopilot",
6
6
  "author": "workopilot",