@dckj-npm/lowcode-plugin-code-generator 1.2.7 → 1.2.9
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/es/components/CodeGenActionBtn/CodeGenActionBtn.js +35 -25
- package/es/types/SyncCodeGenResult.d.ts +9 -0
- package/es/utils/utils.d.ts +26 -0
- package/es/utils/utils.js +99 -0
- package/lib/components/CodeGenActionBtn/CodeGenActionBtn.js +35 -25
- package/lib/types/SyncCodeGenResult.d.ts +9 -0
- package/lib/utils/utils.d.ts +26 -0
- package/lib/utils/utils.js +107 -0
- package/package.json +2 -2
|
@@ -6,8 +6,8 @@ import React, { useState } from 'react';
|
|
|
6
6
|
import * as CodeGenerator from '@dckj-npm/lowcode-code-generator/standalone-loader';
|
|
7
7
|
import { Button, Drawer, Loading, Message } from '@alifd/next';
|
|
8
8
|
import coerce from 'semver/functions/coerce';
|
|
9
|
-
import { project } from '@alilc/lowcode-engine';
|
|
10
9
|
import { CodeGenResult } from '../CodeGenResult';
|
|
10
|
+
import { getAllSchemaByResourceList, getProjectId, getResourceListFromLocalStorage } from "../../utils/utils";
|
|
11
11
|
export function CodeGenActionBtn(_ref) {
|
|
12
12
|
var ctx = _ref.ctx;
|
|
13
13
|
var _useState = useState({
|
|
@@ -23,7 +23,7 @@ export function CodeGenActionBtn(_ref) {
|
|
|
23
23
|
setState = _useState[1];
|
|
24
24
|
var handleClick = /*#__PURE__*/function () {
|
|
25
25
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
26
|
-
var
|
|
26
|
+
var name, resourceList, allSchema, resultSchema, result;
|
|
27
27
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
28
28
|
while (1) switch (_context.prev = _context.next) {
|
|
29
29
|
case 0:
|
|
@@ -38,38 +38,48 @@ export function CodeGenActionBtn(_ref) {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
// 获取 schema,并修正
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
// const originalSchema = await project.exportSchema();
|
|
42
|
+
name = getProjectId();
|
|
43
|
+
_context.next = 5;
|
|
44
|
+
return getResourceListFromLocalStorage(name);
|
|
45
|
+
case 5:
|
|
46
|
+
resourceList = _context.sent;
|
|
47
|
+
console.log('resourceList', resourceList);
|
|
48
|
+
_context.next = 9;
|
|
49
|
+
return getAllSchemaByResourceList(name, resourceList);
|
|
50
|
+
case 9:
|
|
51
|
+
allSchema = _context.sent;
|
|
52
|
+
_context.next = 12;
|
|
53
|
+
return Promise.all(allSchema.map(function (item) {
|
|
54
|
+
return fixSchema(item);
|
|
55
|
+
}));
|
|
56
|
+
case 12:
|
|
57
|
+
resultSchema = _context.sent;
|
|
58
|
+
console.log('allSchema', allSchema);
|
|
59
|
+
console.log('resultSchema', resultSchema);
|
|
60
|
+
// console.log('ctx ', ctx)
|
|
46
61
|
// console.log('isActive ', ctx.workspace.isActive)
|
|
47
62
|
// console.log('window.exportSchema ', ctx.workspace.window.exportSchema())
|
|
48
63
|
// console.log('skeleton ', ctx.workspace.skeleton)
|
|
49
64
|
// console.log('windows ', ctx.workspace.windows)
|
|
50
65
|
// const originalSchema2 = await ctx.project.exportSchema();
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
case 8:
|
|
54
|
-
schema = _context.sent;
|
|
55
|
-
console.log('got schema:222222 ', schema);
|
|
66
|
+
// const schema = await fixSchema(originalSchema);
|
|
67
|
+
// console.log('got schema:222222 ', schema);
|
|
56
68
|
// console.log('got schema:33333333 ', originalSchema2);
|
|
57
69
|
|
|
58
70
|
setState(function (prev) {
|
|
59
|
-
return _extends({}, prev
|
|
60
|
-
schema: schema,
|
|
61
|
-
originalSchema: originalSchema
|
|
62
|
-
});
|
|
71
|
+
return _extends({}, prev);
|
|
63
72
|
});
|
|
64
73
|
|
|
65
74
|
// 出码...
|
|
66
|
-
_context.next =
|
|
75
|
+
_context.next = 18;
|
|
67
76
|
return CodeGenerator.generateCode({
|
|
68
77
|
solution: 'vuejs3',
|
|
69
|
-
schema:
|
|
70
|
-
flattenResult: true
|
|
78
|
+
schema: resultSchema,
|
|
79
|
+
flattenResult: true,
|
|
80
|
+
resourceList: resourceList
|
|
71
81
|
});
|
|
72
|
-
case
|
|
82
|
+
case 18:
|
|
73
83
|
result = _context.sent;
|
|
74
84
|
console.log('generated: ', result);
|
|
75
85
|
setState(function (prev) {
|
|
@@ -78,10 +88,10 @@ export function CodeGenActionBtn(_ref) {
|
|
|
78
88
|
result: result
|
|
79
89
|
});
|
|
80
90
|
});
|
|
81
|
-
_context.next =
|
|
91
|
+
_context.next = 27;
|
|
82
92
|
break;
|
|
83
|
-
case
|
|
84
|
-
_context.prev =
|
|
93
|
+
case 23:
|
|
94
|
+
_context.prev = 23;
|
|
85
95
|
_context.t0 = _context["catch"](0);
|
|
86
96
|
console.error('failed to run code generator: ', _context.t0);
|
|
87
97
|
setState(function (prev) {
|
|
@@ -90,11 +100,11 @@ export function CodeGenActionBtn(_ref) {
|
|
|
90
100
|
error: _context.t0 instanceof Error ? _context.t0 : new Error("" + ((_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message) || _context.t0))
|
|
91
101
|
});
|
|
92
102
|
});
|
|
93
|
-
case
|
|
103
|
+
case 27:
|
|
94
104
|
case "end":
|
|
95
105
|
return _context.stop();
|
|
96
106
|
}
|
|
97
|
-
}, _callee, null, [[0,
|
|
107
|
+
}, _callee, null, [[0, 23]]);
|
|
98
108
|
}));
|
|
99
109
|
return function handleClick() {
|
|
100
110
|
return _ref2.apply(this, arguments);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ResourceListType } from "../types";
|
|
2
|
+
import { IPublicTypeProjectSchema } from "@alilc/lowcode-types";
|
|
3
|
+
/**
|
|
4
|
+
* 从缓存获取ResourceList
|
|
5
|
+
* @param scenarioName
|
|
6
|
+
*/
|
|
7
|
+
export declare const getResourceListFromLocalStorage: (scenarioName: string) => Promise<ResourceListType[]>;
|
|
8
|
+
/**
|
|
9
|
+
* 根据ResourceList获取所有schema
|
|
10
|
+
* @param scenarioName
|
|
11
|
+
* @param ResourceList
|
|
12
|
+
*/
|
|
13
|
+
export declare const getAllSchemaByResourceList: (scenarioName: string, ResourceList: ResourceListType[]) => Promise<IPublicTypeProjectSchema[]>;
|
|
14
|
+
export declare const getResourceName: (scenarioName: string, ns?: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* 获取项目id
|
|
17
|
+
*/
|
|
18
|
+
export declare function getProjectId(): string;
|
|
19
|
+
/**
|
|
20
|
+
* 获取地址栏参数值
|
|
21
|
+
* @param queryName
|
|
22
|
+
* @param defaultValue
|
|
23
|
+
* @returns {string}
|
|
24
|
+
*/
|
|
25
|
+
export declare function getValueFromQueryByName(queryName: string, defaultValue?: string): string;
|
|
26
|
+
export declare const getLSName: (scenarioName: string, id?: string, ns?: string) => string;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
/**
|
|
4
|
+
* 从缓存获取ResourceList
|
|
5
|
+
* @param scenarioName
|
|
6
|
+
*/
|
|
7
|
+
export var getResourceListFromLocalStorage = /*#__PURE__*/function () {
|
|
8
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(scenarioName) {
|
|
9
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
10
|
+
while (1) switch (_context.prev = _context.next) {
|
|
11
|
+
case 0:
|
|
12
|
+
if (scenarioName) {
|
|
13
|
+
_context.next = 3;
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
console.error('scenarioName is required!');
|
|
17
|
+
return _context.abrupt("return");
|
|
18
|
+
case 3:
|
|
19
|
+
return _context.abrupt("return", JSON.parse(window.localStorage.getItem(getResourceName(scenarioName)) || '[{"title":"首页","slug":"index","id": "index"}]'));
|
|
20
|
+
case 4:
|
|
21
|
+
case "end":
|
|
22
|
+
return _context.stop();
|
|
23
|
+
}
|
|
24
|
+
}, _callee);
|
|
25
|
+
}));
|
|
26
|
+
return function getResourceListFromLocalStorage(_x) {
|
|
27
|
+
return _ref.apply(this, arguments);
|
|
28
|
+
};
|
|
29
|
+
}();
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 根据ResourceList获取所有schema
|
|
33
|
+
* @param scenarioName
|
|
34
|
+
* @param ResourceList
|
|
35
|
+
*/
|
|
36
|
+
export var getAllSchemaByResourceList = /*#__PURE__*/function () {
|
|
37
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(scenarioName, ResourceList) {
|
|
38
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
39
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
40
|
+
case 0:
|
|
41
|
+
if (ResourceList) {
|
|
42
|
+
_context2.next = 3;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
console.error('ResourceList is required!');
|
|
46
|
+
return _context2.abrupt("return");
|
|
47
|
+
case 3:
|
|
48
|
+
return _context2.abrupt("return", ResourceList.map(function (item) {
|
|
49
|
+
console.log('ResourceList.map', item);
|
|
50
|
+
console.log('getLSName(scenarioName, item.id)', getLSName(scenarioName, item.id));
|
|
51
|
+
var localSchema = window.localStorage.getItem(getLSName(scenarioName, item.id)) || '{}';
|
|
52
|
+
console.log('localSchema', localSchema);
|
|
53
|
+
return JSON.parse(localSchema);
|
|
54
|
+
}));
|
|
55
|
+
case 4:
|
|
56
|
+
case "end":
|
|
57
|
+
return _context2.stop();
|
|
58
|
+
}
|
|
59
|
+
}, _callee2);
|
|
60
|
+
}));
|
|
61
|
+
return function getAllSchemaByResourceList(_x2, _x3) {
|
|
62
|
+
return _ref2.apply(this, arguments);
|
|
63
|
+
};
|
|
64
|
+
}();
|
|
65
|
+
export var getResourceName = function getResourceName(scenarioName, ns) {
|
|
66
|
+
if (ns === void 0) {
|
|
67
|
+
ns = 'resourceList';
|
|
68
|
+
}
|
|
69
|
+
return scenarioName + ":" + ns;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 获取项目id
|
|
74
|
+
*/
|
|
75
|
+
export function getProjectId() {
|
|
76
|
+
return getValueFromQueryByName('projectId', 'general');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 获取地址栏参数值
|
|
81
|
+
* @param queryName
|
|
82
|
+
* @param defaultValue
|
|
83
|
+
* @returns {string}
|
|
84
|
+
*/
|
|
85
|
+
export function getValueFromQueryByName(queryName, defaultValue) {
|
|
86
|
+
if (defaultValue === void 0) {
|
|
87
|
+
defaultValue = '';
|
|
88
|
+
}
|
|
89
|
+
if (location.search) {
|
|
90
|
+
return new URLSearchParams(location.search.slice(1)).get(queryName) || defaultValue;
|
|
91
|
+
}
|
|
92
|
+
return defaultValue;
|
|
93
|
+
}
|
|
94
|
+
export var getLSName = function getLSName(scenarioName, id, ns) {
|
|
95
|
+
if (ns === void 0) {
|
|
96
|
+
ns = 'projectSchema';
|
|
97
|
+
}
|
|
98
|
+
return scenarioName + ":" + id + ":" + ns;
|
|
99
|
+
};
|
|
@@ -12,8 +12,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var CodeGenerator = _interopRequireWildcard(require("@dckj-npm/lowcode-code-generator/standalone-loader"));
|
|
13
13
|
var _next = require("@alifd/next");
|
|
14
14
|
var _coerce = _interopRequireDefault(require("semver/functions/coerce"));
|
|
15
|
-
var _lowcodeEngine = require("@alilc/lowcode-engine");
|
|
16
15
|
var _CodeGenResult = require("../CodeGenResult");
|
|
16
|
+
var _utils = require("../../utils/utils");
|
|
17
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
18
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
19
19
|
function CodeGenActionBtn(_ref) {
|
|
@@ -31,7 +31,7 @@ function CodeGenActionBtn(_ref) {
|
|
|
31
31
|
setState = _useState[1];
|
|
32
32
|
var handleClick = /*#__PURE__*/function () {
|
|
33
33
|
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
34
|
-
var
|
|
34
|
+
var name, resourceList, allSchema, resultSchema, result;
|
|
35
35
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
36
36
|
while (1) switch (_context.prev = _context.next) {
|
|
37
37
|
case 0:
|
|
@@ -46,38 +46,48 @@ function CodeGenActionBtn(_ref) {
|
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
// 获取 schema,并修正
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
// const originalSchema = await project.exportSchema();
|
|
50
|
+
name = (0, _utils.getProjectId)();
|
|
51
|
+
_context.next = 5;
|
|
52
|
+
return (0, _utils.getResourceListFromLocalStorage)(name);
|
|
53
|
+
case 5:
|
|
54
|
+
resourceList = _context.sent;
|
|
55
|
+
console.log('resourceList', resourceList);
|
|
56
|
+
_context.next = 9;
|
|
57
|
+
return (0, _utils.getAllSchemaByResourceList)(name, resourceList);
|
|
58
|
+
case 9:
|
|
59
|
+
allSchema = _context.sent;
|
|
60
|
+
_context.next = 12;
|
|
61
|
+
return Promise.all(allSchema.map(function (item) {
|
|
62
|
+
return fixSchema(item);
|
|
63
|
+
}));
|
|
64
|
+
case 12:
|
|
65
|
+
resultSchema = _context.sent;
|
|
66
|
+
console.log('allSchema', allSchema);
|
|
67
|
+
console.log('resultSchema', resultSchema);
|
|
68
|
+
// console.log('ctx ', ctx)
|
|
54
69
|
// console.log('isActive ', ctx.workspace.isActive)
|
|
55
70
|
// console.log('window.exportSchema ', ctx.workspace.window.exportSchema())
|
|
56
71
|
// console.log('skeleton ', ctx.workspace.skeleton)
|
|
57
72
|
// console.log('windows ', ctx.workspace.windows)
|
|
58
73
|
// const originalSchema2 = await ctx.project.exportSchema();
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
case 8:
|
|
62
|
-
schema = _context.sent;
|
|
63
|
-
console.log('got schema:222222 ', schema);
|
|
74
|
+
// const schema = await fixSchema(originalSchema);
|
|
75
|
+
// console.log('got schema:222222 ', schema);
|
|
64
76
|
// console.log('got schema:33333333 ', originalSchema2);
|
|
65
77
|
|
|
66
78
|
setState(function (prev) {
|
|
67
|
-
return (0, _extends2["default"])({}, prev
|
|
68
|
-
schema: schema,
|
|
69
|
-
originalSchema: originalSchema
|
|
70
|
-
});
|
|
79
|
+
return (0, _extends2["default"])({}, prev);
|
|
71
80
|
});
|
|
72
81
|
|
|
73
82
|
// 出码...
|
|
74
|
-
_context.next =
|
|
83
|
+
_context.next = 18;
|
|
75
84
|
return CodeGenerator.generateCode({
|
|
76
85
|
solution: 'vuejs3',
|
|
77
|
-
schema:
|
|
78
|
-
flattenResult: true
|
|
86
|
+
schema: resultSchema,
|
|
87
|
+
flattenResult: true,
|
|
88
|
+
resourceList: resourceList
|
|
79
89
|
});
|
|
80
|
-
case
|
|
90
|
+
case 18:
|
|
81
91
|
result = _context.sent;
|
|
82
92
|
console.log('generated: ', result);
|
|
83
93
|
setState(function (prev) {
|
|
@@ -86,10 +96,10 @@ function CodeGenActionBtn(_ref) {
|
|
|
86
96
|
result: result
|
|
87
97
|
});
|
|
88
98
|
});
|
|
89
|
-
_context.next =
|
|
99
|
+
_context.next = 27;
|
|
90
100
|
break;
|
|
91
|
-
case
|
|
92
|
-
_context.prev =
|
|
101
|
+
case 23:
|
|
102
|
+
_context.prev = 23;
|
|
93
103
|
_context.t0 = _context["catch"](0);
|
|
94
104
|
console.error('failed to run code generator: ', _context.t0);
|
|
95
105
|
setState(function (prev) {
|
|
@@ -98,11 +108,11 @@ function CodeGenActionBtn(_ref) {
|
|
|
98
108
|
error: _context.t0 instanceof Error ? _context.t0 : new Error("" + ((_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message) || _context.t0))
|
|
99
109
|
});
|
|
100
110
|
});
|
|
101
|
-
case
|
|
111
|
+
case 27:
|
|
102
112
|
case "end":
|
|
103
113
|
return _context.stop();
|
|
104
114
|
}
|
|
105
|
-
}, _callee, null, [[0,
|
|
115
|
+
}, _callee, null, [[0, 23]]);
|
|
106
116
|
}));
|
|
107
117
|
return function handleClick() {
|
|
108
118
|
return _ref2.apply(this, arguments);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ResourceListType } from "../types";
|
|
2
|
+
import { IPublicTypeProjectSchema } from "@alilc/lowcode-types";
|
|
3
|
+
/**
|
|
4
|
+
* 从缓存获取ResourceList
|
|
5
|
+
* @param scenarioName
|
|
6
|
+
*/
|
|
7
|
+
export declare const getResourceListFromLocalStorage: (scenarioName: string) => Promise<ResourceListType[]>;
|
|
8
|
+
/**
|
|
9
|
+
* 根据ResourceList获取所有schema
|
|
10
|
+
* @param scenarioName
|
|
11
|
+
* @param ResourceList
|
|
12
|
+
*/
|
|
13
|
+
export declare const getAllSchemaByResourceList: (scenarioName: string, ResourceList: ResourceListType[]) => Promise<IPublicTypeProjectSchema[]>;
|
|
14
|
+
export declare const getResourceName: (scenarioName: string, ns?: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* 获取项目id
|
|
17
|
+
*/
|
|
18
|
+
export declare function getProjectId(): string;
|
|
19
|
+
/**
|
|
20
|
+
* 获取地址栏参数值
|
|
21
|
+
* @param queryName
|
|
22
|
+
* @param defaultValue
|
|
23
|
+
* @returns {string}
|
|
24
|
+
*/
|
|
25
|
+
export declare function getValueFromQueryByName(queryName: string, defaultValue?: string): string;
|
|
26
|
+
export declare const getLSName: (scenarioName: string, id?: string, ns?: string) => string;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.getLSName = exports.getAllSchemaByResourceList = void 0;
|
|
6
|
+
exports.getProjectId = getProjectId;
|
|
7
|
+
exports.getResourceName = exports.getResourceListFromLocalStorage = void 0;
|
|
8
|
+
exports.getValueFromQueryByName = getValueFromQueryByName;
|
|
9
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
/**
|
|
12
|
+
* 从缓存获取ResourceList
|
|
13
|
+
* @param scenarioName
|
|
14
|
+
*/
|
|
15
|
+
var getResourceListFromLocalStorage = exports.getResourceListFromLocalStorage = /*#__PURE__*/function () {
|
|
16
|
+
var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(scenarioName) {
|
|
17
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
18
|
+
while (1) switch (_context.prev = _context.next) {
|
|
19
|
+
case 0:
|
|
20
|
+
if (scenarioName) {
|
|
21
|
+
_context.next = 3;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
console.error('scenarioName is required!');
|
|
25
|
+
return _context.abrupt("return");
|
|
26
|
+
case 3:
|
|
27
|
+
return _context.abrupt("return", JSON.parse(window.localStorage.getItem(getResourceName(scenarioName)) || '[{"title":"首页","slug":"index","id": "index"}]'));
|
|
28
|
+
case 4:
|
|
29
|
+
case "end":
|
|
30
|
+
return _context.stop();
|
|
31
|
+
}
|
|
32
|
+
}, _callee);
|
|
33
|
+
}));
|
|
34
|
+
return function getResourceListFromLocalStorage(_x) {
|
|
35
|
+
return _ref.apply(this, arguments);
|
|
36
|
+
};
|
|
37
|
+
}();
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 根据ResourceList获取所有schema
|
|
41
|
+
* @param scenarioName
|
|
42
|
+
* @param ResourceList
|
|
43
|
+
*/
|
|
44
|
+
var getAllSchemaByResourceList = exports.getAllSchemaByResourceList = /*#__PURE__*/function () {
|
|
45
|
+
var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(scenarioName, ResourceList) {
|
|
46
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
47
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
48
|
+
case 0:
|
|
49
|
+
if (ResourceList) {
|
|
50
|
+
_context2.next = 3;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
console.error('ResourceList is required!');
|
|
54
|
+
return _context2.abrupt("return");
|
|
55
|
+
case 3:
|
|
56
|
+
return _context2.abrupt("return", ResourceList.map(function (item) {
|
|
57
|
+
console.log('ResourceList.map', item);
|
|
58
|
+
console.log('getLSName(scenarioName, item.id)', getLSName(scenarioName, item.id));
|
|
59
|
+
var localSchema = window.localStorage.getItem(getLSName(scenarioName, item.id)) || '{}';
|
|
60
|
+
console.log('localSchema', localSchema);
|
|
61
|
+
return JSON.parse(localSchema);
|
|
62
|
+
}));
|
|
63
|
+
case 4:
|
|
64
|
+
case "end":
|
|
65
|
+
return _context2.stop();
|
|
66
|
+
}
|
|
67
|
+
}, _callee2);
|
|
68
|
+
}));
|
|
69
|
+
return function getAllSchemaByResourceList(_x2, _x3) {
|
|
70
|
+
return _ref2.apply(this, arguments);
|
|
71
|
+
};
|
|
72
|
+
}();
|
|
73
|
+
var getResourceName = exports.getResourceName = function getResourceName(scenarioName, ns) {
|
|
74
|
+
if (ns === void 0) {
|
|
75
|
+
ns = 'resourceList';
|
|
76
|
+
}
|
|
77
|
+
return scenarioName + ":" + ns;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 获取项目id
|
|
82
|
+
*/
|
|
83
|
+
function getProjectId() {
|
|
84
|
+
return getValueFromQueryByName('projectId', 'general');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 获取地址栏参数值
|
|
89
|
+
* @param queryName
|
|
90
|
+
* @param defaultValue
|
|
91
|
+
* @returns {string}
|
|
92
|
+
*/
|
|
93
|
+
function getValueFromQueryByName(queryName, defaultValue) {
|
|
94
|
+
if (defaultValue === void 0) {
|
|
95
|
+
defaultValue = '';
|
|
96
|
+
}
|
|
97
|
+
if (location.search) {
|
|
98
|
+
return new URLSearchParams(location.search.slice(1)).get(queryName) || defaultValue;
|
|
99
|
+
}
|
|
100
|
+
return defaultValue;
|
|
101
|
+
}
|
|
102
|
+
var getLSName = exports.getLSName = function getLSName(scenarioName, id, ns) {
|
|
103
|
+
if (ns === void 0) {
|
|
104
|
+
ns = 'projectSchema';
|
|
105
|
+
}
|
|
106
|
+
return scenarioName + ":" + id + ":" + ns;
|
|
107
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dckj-npm/lowcode-plugin-code-generator",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
4
4
|
"description": "集团低代码引擎 - 浏览器出码插件",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@alilc/lowcode-code-generator": "^1.0.4",
|
|
36
36
|
"@alilc/lowcode-plugin-base-monaco-editor": "^1.0.0",
|
|
37
37
|
"@alilc/lowcode-types": "^1.0.0",
|
|
38
|
-
"@dckj-npm/lowcode-code-generator": "^1.2.
|
|
38
|
+
"@dckj-npm/lowcode-code-generator": "^1.2.13",
|
|
39
39
|
"@types/file-saver": "^2.0.4",
|
|
40
40
|
"@types/js-base64": "^3.3.1",
|
|
41
41
|
"@types/string-natural-compare": "^3.0.2",
|