vap1 0.6.4 → 0.6.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.
@@ -104,6 +104,13 @@ export type DRootProps = {
104
104
  * 子组件
105
105
  */
106
106
  children?: ReactNode;
107
+ /**
108
+ * 国际化
109
+ * @param key
110
+ * @param param
111
+ * @returns
112
+ */
113
+ txtLang?: (key: string, ...param: any[]) => string;
107
114
  };
108
115
  /**
109
116
  *
@@ -149,7 +149,7 @@ exports.Box = (0, react_1.forwardRef)(function (props, ref) {
149
149
  }
150
150
  }, [state === null || state === void 0 ? void 0 : state.height]);
151
151
  var resize = (0, react_1.useCallback)(function () {
152
- if (mode == 'common' || app == null) {
152
+ if (mode == 'common') {
153
153
  if (state === null)
154
154
  setState({});
155
155
  return;
@@ -11,7 +11,6 @@ export declare const ApiTable: React.ForwardRefExoticComponent<import("./index")
11
11
  rowKey?: string;
12
12
  select?: true | "DEFAULT" | "QUERY";
13
13
  selectDisabled?: (record: any) => boolean;
14
- actionBar?: Array<import("./Components/ActionBar").TableActionButton[]> | React.ReactNode;
14
+ actionBar?: Array<import("./Components/ActionBar").TableActionButton> | React.ReactNode;
15
15
  autoLoad?: false;
16
- fixHeader?: boolean;
17
16
  } & Pick<ApiOption, "api" | "tipField" | "tipDisabled" | "aop"> & React.RefAttributes<ApiModel>>;
@@ -11,9 +11,8 @@ export declare const ApiTableModal: React.ForwardRefExoticComponent<import(".").
11
11
  rowKey?: string;
12
12
  select?: true | "DEFAULT" | "QUERY";
13
13
  selectDisabled?: (record: any) => boolean;
14
- actionBar?: Array<import("./Components/ActionBar").TableActionButton[]> | React.ReactNode;
14
+ actionBar?: Array<import("./Components/ActionBar").TableActionButton> | React.ReactNode;
15
15
  autoLoad?: false;
16
- fixHeader?: boolean;
17
16
  } & Pick<import("../../hooks/useApiBase").ApiOption, "api" | "tipField" | "tipDisabled" | "aop"> & Omit<import("antd/es/modal").ModalProps, "visible" | "onCancel" | "onOk"> & {
18
17
  open?: boolean;
19
18
  onOk?: (data?: import("../..").PlainObject) => void;
@@ -35,9 +35,8 @@ export declare const VTable: React.ForwardRefExoticComponent<import("./index").T
35
35
  rowKey?: string;
36
36
  select?: true | "DEFAULT" | "QUERY";
37
37
  selectDisabled?: (record: any) => boolean;
38
- actionBar?: Array<TableActionButton[]> | React.ReactNode;
38
+ actionBar?: Array<TableActionButton> | React.ReactNode;
39
39
  autoLoad?: false;
40
- fixHeader?: boolean;
41
40
  } & {
42
41
  /**
43
42
  * 列表模型,可以使用系统提供的 useApi/useArray 等,也可自行实现列表模型
@@ -54,19 +54,11 @@ export type BaseTableProps = TableDefine & Pick<BoxProps, 'mode' | 'selectBar' |
54
54
  /**
55
55
  * 表格操作区域
56
56
  */
57
- actionBar?: Array<TableActionButton[]> | ReactNode;
57
+ actionBar?: Array<TableActionButton> | ReactNode;
58
58
  /**
59
59
  * 是否自动查询,默认为TRUE
60
60
  */
61
61
  autoLoad?: false;
62
- /**
63
- * @experimental
64
- * 说明: 1.5 版本才有此属性
65
- * 2.0版本会自动锁定表头
66
- * 1.5版本有问题: http://192.168.119.213:9999/vap2/why-not/#%E4%B8%BA%E4%BB%80%E4%B9%881-5%E7%89%88%E6%9C%AC%E7%9A%84vtable%E4%B8%8D%E6%94%AF%E6%8C%81%E9%94%81%E5%AE%9A%E8%A1%A8%E5%A4%B4
67
- * 传此参数后,会试验性的计算,可能会有BUG
68
- */
69
- fixHeader?: boolean;
70
62
  };
71
63
  import type { ApiTableProps } from './ApiTable';
72
64
  export type ApiTable = ForwardRefExoticComponent<ApiTableProps & RefAttributes<ApiModel>> & TableDefined;
package/hooks/index.d.ts CHANGED
@@ -13,4 +13,5 @@ export { useOpenState } from './useOpenState';
13
13
  export { useFirstMountState } from './useFirstMountState';
14
14
  export { useToggle } from './useToggle';
15
15
  export { useUpdate } from './useUpdate';
16
+ export { usePreference } from './usePreference';
16
17
  export { useSyncExternalStore } from './useSyncExternalStore';
package/hooks/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useSyncExternalStore = exports.useUpdate = exports.useToggle = exports.useFirstMountState = exports.useOpenState = exports.useAjaxAction = exports.useAjaxQuery = exports.useEffectFunction = exports.useModals = exports.useGlobal = exports.useDoLoad = exports.useSetState = exports.useArray = exports.useApiGlobal = exports.useApi = exports.useApp = void 0;
3
+ exports.useSyncExternalStore = exports.usePreference = exports.useUpdate = exports.useToggle = exports.useFirstMountState = exports.useOpenState = exports.useAjaxAction = exports.useAjaxQuery = exports.useEffectFunction = exports.useModals = exports.useGlobal = exports.useDoLoad = exports.useSetState = exports.useArray = exports.useApiGlobal = exports.useApi = exports.useApp = void 0;
4
4
  // export type { GlobalApp } from './useApp';
5
5
  var useApp_1 = require("./useApp");
6
6
  Object.defineProperty(exports, "useApp", { enumerable: true, get: function () { return useApp_1.useApp; } });
@@ -46,6 +46,8 @@ Object.defineProperty(exports, "useToggle", { enumerable: true, get: function ()
46
46
  var useUpdate_1 = require("./useUpdate");
47
47
  Object.defineProperty(exports, "useUpdate", { enumerable: true, get: function () { return useUpdate_1.useUpdate; } });
48
48
  // export { useUpdateEffect } from './useUpdateEffect';
49
+ var usePreference_1 = require("./usePreference");
50
+ Object.defineProperty(exports, "usePreference", { enumerable: true, get: function () { return usePreference_1.usePreference; } });
49
51
  var useSyncExternalStore_1 = require("./useSyncExternalStore");
50
52
  Object.defineProperty(exports, "useSyncExternalStore", { enumerable: true, get: function () { return useSyncExternalStore_1.useSyncExternalStore; } });
51
53
  // 说明: 主要从以下两个库中提取常用hooks 集成至VAP
@@ -0,0 +1,9 @@
1
+ type UsePreferenceConfig = {
2
+ module: string;
3
+ key: string;
4
+ defaultValue?: string;
5
+ allowValue?: Array<string>;
6
+ };
7
+ type UsePreferenceResult = [boolean, string, (val: string) => void];
8
+ export declare const usePreference: (config: UsePreferenceConfig) => UsePreferenceResult;
9
+ export {};
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __read = (this && this.__read) || function (o, n) {
39
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
40
+ if (!m) return o;
41
+ var i = m.call(o), r, ar = [], e;
42
+ try {
43
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
+ }
45
+ catch (error) { e = { error: error }; }
46
+ finally {
47
+ try {
48
+ if (r && !r.done && (m = i["return"])) m.call(i);
49
+ }
50
+ finally { if (e) throw e.error; }
51
+ }
52
+ return ar;
53
+ };
54
+ var __importDefault = (this && this.__importDefault) || function (mod) {
55
+ return (mod && mod.__esModule) ? mod : { "default": mod };
56
+ };
57
+ Object.defineProperty(exports, "__esModule", { value: true });
58
+ exports.usePreference = void 0;
59
+ var lodash_1 = __importDefault(require("lodash"));
60
+ var react_1 = require("react");
61
+ var useApp_1 = require("./useApp");
62
+ var usePreference = function (config) {
63
+ var _a = (0, useApp_1.useApp)().user, getConfig = _a.getConfig, setConfig = _a.setConfig;
64
+ var _b = __read((0, react_1.useState)(null), 2), value = _b[0], setValue = _b[1];
65
+ var allowValue = (0, react_1.useCallback)(function (value) {
66
+ if (lodash_1.default.isArray(config.allowValue) && config.allowValue.length > 0) {
67
+ return lodash_1.default.includes(config.allowValue, value);
68
+ }
69
+ return true;
70
+ }, []);
71
+ var set = (0, react_1.useCallback)(function (value) { return __awaiter(void 0, void 0, void 0, function () {
72
+ var isOk;
73
+ return __generator(this, function (_a) {
74
+ switch (_a.label) {
75
+ case 0:
76
+ if (!allowValue(value))
77
+ return [2 /*return*/];
78
+ return [4 /*yield*/, setConfig(config.module, config.key, value)];
79
+ case 1:
80
+ isOk = _a.sent();
81
+ if (isOk) {
82
+ setValue(value);
83
+ }
84
+ return [2 /*return*/];
85
+ }
86
+ });
87
+ }); }, []);
88
+ (0, react_1.useEffect)(function () {
89
+ getConfig(config.module, config.key).then(function (result) {
90
+ var value = result || config.defaultValue || '';
91
+ if (allowValue(value)) {
92
+ setValue(value);
93
+ }
94
+ else {
95
+ setValue(config.defaultValue || '');
96
+ }
97
+ });
98
+ }, []);
99
+ return [value === null, value === null ? config.defaultValue : value, set];
100
+ };
101
+ exports.usePreference = usePreference;
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"vap1","version":"0.6.4","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
1
+ {"name":"vap1","version":"0.6.6","description":"vap1, Both support MicroService and SAP FrameWork, Support IE>9","main":"index.js","author":"Xiang da","license":"ISC"}
@@ -39,10 +39,10 @@ export type Menu = {
39
39
  *
40
40
  * 1 :菜单组
41
41
  * 2 : 链接
42
- * 3 : 权限码
43
- * 4 : 小组件
42
+ * 3 : 权限码 - 无效
43
+ * 4 : 小组件 -无效
44
44
  */
45
- type: 1 | 2 | 3 | 4;
45
+ type: 1 | 2;
46
46
  /**
47
47
  * 图标
48
48
  */
@@ -72,12 +72,21 @@ export type Menu = {
72
72
  * type = 1 时存在
73
73
  * 其它 type 也可存在,但只能放置权限码
74
74
  */
75
- children?: Menu[];
75
+ children?: Array<Menu>;
76
76
  };
77
77
  type CustomAppMenu = {
78
+ /**
79
+ * none: (默认)无菜单模式
80
+ * 一般情况下,注册一个 '/' 路由即可
81
+ * list: 自定义菜单模式
82
+ * 使用 list 模式时,必须指定 list , 为已经整理好结构的 Menu 结构
83
+ * parent: 向上找一个菜单
84
+ * 使用 parent 模式时,必须指定 parent
85
+ * 使用资源里面的菜单
86
+ */
78
87
  mode?: 'none' | 'list' | 'parent';
79
88
  parent?: string;
80
- list?: Menu[];
89
+ list?: Array<Menu>;
81
90
  };
82
91
  export type CustomAppTheme = {
83
92
  /**
package/utils/index.d.ts CHANGED
@@ -11,7 +11,6 @@ export * as i18n from './i18n';
11
11
  export * as GLOBAL from './Global';
12
12
  export * as Renders from './Renders';
13
13
  export * as Const from './Const';
14
- export * as BitModeUtil from './ModeUtil';
15
14
  export { default as VAP } from './VAP';
16
15
  /**
17
16
  * 路由信息
package/utils/index.js CHANGED
@@ -61,7 +61,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
61
61
  return (mod && mod.__esModule) ? mod : { "default": mod };
62
62
  };
63
63
  Object.defineProperty(exports, "__esModule", { value: true });
64
- exports.renderRoot = exports.VAP = exports.BitModeUtil = exports.Const = exports.Renders = exports.GLOBAL = exports.i18n = exports.Ajax = exports.Format = exports.TipUtil = exports.CacheUtil = exports.EventUtil = exports.ArrayUtil = exports.PageUtil = exports.TreeUtil = exports.StringUtil = void 0;
64
+ exports.renderRoot = exports.VAP = exports.Const = exports.Renders = exports.GLOBAL = exports.i18n = exports.Ajax = exports.Format = exports.TipUtil = exports.CacheUtil = exports.EventUtil = exports.ArrayUtil = exports.PageUtil = exports.TreeUtil = exports.StringUtil = void 0;
65
65
  exports.registerRoute = registerRoute;
66
66
  var lodash_1 = __importDefault(require("lodash"));
67
67
  // 全局 UTILS 定义
@@ -78,7 +78,6 @@ exports.i18n = __importStar(require("./i18n"));
78
78
  exports.GLOBAL = __importStar(require("./Global"));
79
79
  exports.Renders = __importStar(require("./Renders"));
80
80
  exports.Const = __importStar(require("./Const"));
81
- exports.BitModeUtil = __importStar(require("./ModeUtil"));
82
81
  // export * as logger from './Logger';
83
82
  var VAP_1 = require("./VAP");
84
83
  Object.defineProperty(exports, "VAP", { enumerable: true, get: function () { return __importDefault(VAP_1).default; } });
package/utils/py.js CHANGED
@@ -89,7 +89,7 @@ var matchKeywordByIndex = function (key, index) {
89
89
  /**
90
90
  * 4. 如果原文本已经遍历完成 ,不管关键字有没有完成 ,都直接中段
91
91
  */
92
- if (textCursor >= (textLen - 1))
92
+ if (textCursor >= textLen)
93
93
  break;
94
94
  keywordCursor++;
95
95
  }