@nocobase/plugin-client 0.7.0-alpha.9 → 0.7.1-alpha.4
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/lib/index.d.ts +1 -1
- package/lib/index.js +14 -8
- package/{esm/plugin.d.ts → lib/server.d.ts} +0 -0
- package/lib/server.js +221 -0
- package/package.json +4 -9
- package/esm/index.d.ts +0 -1
- package/esm/index.js +0 -2
- package/esm/index.js.map +0 -1
- package/esm/plugin.js +0 -76
- package/esm/plugin.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/plugin.d.ts +0 -7
- package/lib/plugin.js +0 -83
- package/lib/plugin.js.map +0 -1
- package/tsconfig.build.json +0 -9
package/lib/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './
|
|
1
|
+
export { default } from './server';
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _server.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _server = _interopRequireDefault(require("./server"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
File without changes
|
package/lib/server.js
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.ClientPlugin = void 0;
|
|
7
|
+
|
|
8
|
+
function _server() {
|
|
9
|
+
const data = require("@nocobase/server");
|
|
10
|
+
|
|
11
|
+
_server = function _server() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _koaSend() {
|
|
19
|
+
const data = _interopRequireDefault(require("koa-send"));
|
|
20
|
+
|
|
21
|
+
_koaSend = function _koaSend() {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _koaStatic() {
|
|
29
|
+
const data = _interopRequireDefault(require("koa-static"));
|
|
30
|
+
|
|
31
|
+
_koaStatic = function _koaStatic() {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function _path() {
|
|
39
|
+
const data = require("path");
|
|
40
|
+
|
|
41
|
+
_path = function _path() {
|
|
42
|
+
return data;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
49
|
+
|
|
50
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
51
|
+
|
|
52
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
53
|
+
|
|
54
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
55
|
+
|
|
56
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
57
|
+
|
|
58
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
59
|
+
|
|
60
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
61
|
+
|
|
62
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
63
|
+
|
|
64
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
65
|
+
|
|
66
|
+
class ClientPlugin extends _server().Plugin {
|
|
67
|
+
beforeLoad() {
|
|
68
|
+
var _this = this;
|
|
69
|
+
|
|
70
|
+
return _asyncToGenerator(function* () {
|
|
71
|
+
// const cmd = this.app.findCommand('install');
|
|
72
|
+
// if (cmd) {
|
|
73
|
+
// cmd.option('--import-demo');
|
|
74
|
+
// }
|
|
75
|
+
_this.app.on('afterInstall', /*#__PURE__*/function () {
|
|
76
|
+
var _ref = _asyncToGenerator(function* (app, options) {
|
|
77
|
+
const _ref2 = (options === null || options === void 0 ? void 0 : options.cliArgs) || [{}],
|
|
78
|
+
_ref3 = _slicedToArray(_ref2, 1),
|
|
79
|
+
opts = _ref3[0];
|
|
80
|
+
|
|
81
|
+
if (opts === null || opts === void 0 ? void 0 : opts.importDemo) {//
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
return function (_x, _x2) {
|
|
86
|
+
return _ref.apply(this, arguments);
|
|
87
|
+
};
|
|
88
|
+
}());
|
|
89
|
+
})();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
load() {
|
|
93
|
+
var _this2 = this;
|
|
94
|
+
|
|
95
|
+
return _asyncToGenerator(function* () {
|
|
96
|
+
_this2.app.acl.allow('app', 'getLang');
|
|
97
|
+
|
|
98
|
+
_this2.app.acl.allow('app', 'getInfo');
|
|
99
|
+
|
|
100
|
+
_this2.app.acl.allow('plugins', 'getPinned', 'loggedIn');
|
|
101
|
+
|
|
102
|
+
_this2.app.resource({
|
|
103
|
+
name: 'app',
|
|
104
|
+
actions: {
|
|
105
|
+
getInfo(ctx, next) {
|
|
106
|
+
return _asyncToGenerator(function* () {
|
|
107
|
+
const SystemSetting = ctx.db.getRepository('systemSettings');
|
|
108
|
+
const systemSetting = yield SystemSetting.findOne();
|
|
109
|
+
const enabledLanguages = systemSetting.get('enabledLanguages') || [];
|
|
110
|
+
const currentUser = ctx.state.currentUser;
|
|
111
|
+
let lang = (systemSetting === null || systemSetting === void 0 ? void 0 : systemSetting.appLang) || process.env.APP_LANG || 'en-US';
|
|
112
|
+
|
|
113
|
+
if (enabledLanguages.includes(currentUser === null || currentUser === void 0 ? void 0 : currentUser.appLang)) {
|
|
114
|
+
lang = currentUser === null || currentUser === void 0 ? void 0 : currentUser.appLang;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
ctx.body = {
|
|
118
|
+
version: yield ctx.app.version.get(),
|
|
119
|
+
lang
|
|
120
|
+
};
|
|
121
|
+
yield next();
|
|
122
|
+
})();
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
getLang(ctx, next) {
|
|
126
|
+
return _asyncToGenerator(function* () {
|
|
127
|
+
const SystemSetting = ctx.db.getRepository('systemSettings');
|
|
128
|
+
const systemSetting = yield SystemSetting.findOne();
|
|
129
|
+
const enabledLanguages = systemSetting.get('enabledLanguages') || [];
|
|
130
|
+
const currentUser = ctx.state.currentUser;
|
|
131
|
+
let lang = (systemSetting === null || systemSetting === void 0 ? void 0 : systemSetting.appLang) || process.env.APP_LANG || 'en-US';
|
|
132
|
+
|
|
133
|
+
if (enabledLanguages.includes(currentUser === null || currentUser === void 0 ? void 0 : currentUser.appLang)) {
|
|
134
|
+
lang = currentUser === null || currentUser === void 0 ? void 0 : currentUser.appLang;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
ctx.body = {
|
|
138
|
+
lang
|
|
139
|
+
};
|
|
140
|
+
yield next();
|
|
141
|
+
})();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
_this2.app.resource({
|
|
148
|
+
name: 'plugins',
|
|
149
|
+
actions: {
|
|
150
|
+
// TODO: 临时
|
|
151
|
+
getPinned(ctx, next) {
|
|
152
|
+
return _asyncToGenerator(function* () {
|
|
153
|
+
ctx.body = [{
|
|
154
|
+
component: 'DesignableSwitch',
|
|
155
|
+
pin: true
|
|
156
|
+
}, {
|
|
157
|
+
component: 'CollectionManagerShortcut',
|
|
158
|
+
pin: true
|
|
159
|
+
}, {
|
|
160
|
+
component: 'ACLShortcut'
|
|
161
|
+
}, {
|
|
162
|
+
component: 'WorkflowShortcut'
|
|
163
|
+
}, {
|
|
164
|
+
component: 'SchemaTemplateShortcut'
|
|
165
|
+
}, {
|
|
166
|
+
component: 'SystemSettingsShortcut'
|
|
167
|
+
}, {
|
|
168
|
+
component: 'FileStorageShortcut'
|
|
169
|
+
}];
|
|
170
|
+
yield next();
|
|
171
|
+
})();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
let root = _this2.options.dist || `./packages/app/client/dist`;
|
|
178
|
+
|
|
179
|
+
if (!(0, _path().isAbsolute)(root)) {
|
|
180
|
+
root = (0, _path().resolve)(process.cwd(), root);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
_this2.app.middleware.unshift( /*#__PURE__*/function () {
|
|
184
|
+
var _ref4 = _asyncToGenerator(function* (ctx, next) {
|
|
185
|
+
if (process.env.APP_ENV === 'production') {
|
|
186
|
+
return next();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (!root) {
|
|
190
|
+
return next();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (ctx.path.startsWith(_this2.app.resourcer.options.prefix)) {
|
|
194
|
+
return next();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
yield (0, _koaStatic().default)(root)(ctx, next); // console.log('koa-send', root, ctx.status);
|
|
198
|
+
|
|
199
|
+
if (ctx.status == 404) {
|
|
200
|
+
return (0, _koaSend().default)(ctx, 'index.html', {
|
|
201
|
+
root
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
return function (_x3, _x4) {
|
|
207
|
+
return _ref4.apply(this, arguments);
|
|
208
|
+
};
|
|
209
|
+
}());
|
|
210
|
+
})();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
getName() {
|
|
214
|
+
return this.getPackageName(__dirname);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
exports.ClientPlugin = ClientPlugin;
|
|
220
|
+
var _default = ClientPlugin;
|
|
221
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-client",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1-alpha.4",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"licenses": [
|
|
@@ -9,16 +9,11 @@
|
|
|
9
9
|
"url": "http://www.apache.org/licenses/LICENSE-2.0"
|
|
10
10
|
}
|
|
11
11
|
],
|
|
12
|
-
"scripts": {
|
|
13
|
-
"build": "rimraf -rf lib esm dist && npm run build:cjs && npm run build:esm",
|
|
14
|
-
"build:cjs": "tsc --project tsconfig.build.json",
|
|
15
|
-
"build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm"
|
|
16
|
-
},
|
|
17
12
|
"dependencies": {
|
|
18
|
-
"@nocobase/server": "0.7.
|
|
13
|
+
"@nocobase/server": "0.7.1-alpha.4"
|
|
19
14
|
},
|
|
20
15
|
"devDependencies": {
|
|
21
|
-
"@nocobase/test": "0.7.
|
|
16
|
+
"@nocobase/test": "0.7.1-alpha.4"
|
|
22
17
|
},
|
|
23
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "570d039f1904a041729c1967c0637b1109c278a8"
|
|
24
19
|
}
|
package/esm/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './plugin';
|
package/esm/index.js
DELETED
package/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC","sourcesContent":["export { default } from './plugin';\n"]}
|
package/esm/plugin.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { skip } from '@nocobase/acl';
|
|
11
|
-
import { Plugin } from '@nocobase/server';
|
|
12
|
-
import send from 'koa-send';
|
|
13
|
-
import serve from 'koa-static';
|
|
14
|
-
import { resolve } from 'path';
|
|
15
|
-
export class ClientPlugin extends Plugin {
|
|
16
|
-
beforeLoad() {
|
|
17
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
const cmd = this.app.findCommand('install');
|
|
19
|
-
if (cmd) {
|
|
20
|
-
cmd.option('--import-demo');
|
|
21
|
-
}
|
|
22
|
-
this.app.on('afterInstall', (app, options) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const [opts] = (options === null || options === void 0 ? void 0 : options.cliArgs) || [{}];
|
|
24
|
-
if (opts === null || opts === void 0 ? void 0 : opts.importDemo) {
|
|
25
|
-
//
|
|
26
|
-
}
|
|
27
|
-
}));
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
load() {
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
this.app.acl.use(skip({
|
|
33
|
-
resourceName: 'app',
|
|
34
|
-
actionName: 'getLang',
|
|
35
|
-
}));
|
|
36
|
-
this.app.resource({
|
|
37
|
-
name: 'app',
|
|
38
|
-
actions: {
|
|
39
|
-
getLang(ctx, next) {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
const SystemSetting = ctx.db.getRepository('systemSettings');
|
|
42
|
-
const systemSetting = yield SystemSetting.findOne();
|
|
43
|
-
const currentUser = ctx.state.currentUser;
|
|
44
|
-
ctx.body = {
|
|
45
|
-
lang: (currentUser === null || currentUser === void 0 ? void 0 : currentUser.appLang) || (systemSetting === null || systemSetting === void 0 ? void 0 : systemSetting.appLang) || process.env.APP_LANG || 'en-US',
|
|
46
|
-
};
|
|
47
|
-
yield next();
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
let root = this.options.dist;
|
|
53
|
-
if (root && !root.startsWith('/')) {
|
|
54
|
-
root = resolve(process.cwd(), root);
|
|
55
|
-
}
|
|
56
|
-
this.app.middleware.unshift((ctx, next) => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
if (process.env.NOCOBASE_ENV === 'production') {
|
|
58
|
-
return next();
|
|
59
|
-
}
|
|
60
|
-
if (!root) {
|
|
61
|
-
return next();
|
|
62
|
-
}
|
|
63
|
-
yield serve(root)(ctx, next);
|
|
64
|
-
// console.log('koa-send', root, ctx.status);
|
|
65
|
-
if (ctx.status == 404) {
|
|
66
|
-
return send(ctx, 'index.html', { root });
|
|
67
|
-
}
|
|
68
|
-
}));
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
getName() {
|
|
72
|
-
return this.getPackageName(__dirname);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
export default ClientPlugin;
|
|
76
|
-
//# sourceMappingURL=plugin.js.map
|
package/esm/plugin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,IAAI,MAAM,UAAU,CAAC;AAC5B,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,MAAM,OAAO,YAAa,SAAQ,MAAM;IAChC,UAAU;;YACd,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;YAC5C,IAAI,GAAG,EAAE;gBACP,G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AI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;gBACjC,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;aACrC;YACD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAO,GAAG,EAAE,IAAI,EAAE,EAAE;gBAC9C,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,YAAY,EAAE;oBAC7C,OAAO,IAAI,EAAE,CAAC;iBACf;gBACD,IAAI,CAAC,IAAI,EAAE;oBACT,OAAO,IAAI,EAAE,CAAC;iBACf;gBACD,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;gBAC7B,6CAA6C;gBAC7C,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,EAAE;oBACrB,OAAO,IAAI,CAAC,GAAG,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;iBAC1C;YACH,CAAC,CAAA,CAAC,CAAC;QACL,CAAC;KAAA;IAED,OAAO;QACL,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;CACF;AAED,eAAe,YAAY,CAAC","sourcesContent":["import { skip } from '@nocobase/acl';\nimport { Plugin } from '@nocobase/server';\nimport send from 'koa-send';\nimport serve from 'koa-static';\nimport { resolve } from 'path';\n\nexport class ClientPlugin extends Plugin {\n async beforeLoad() {\n const cmd = this.app.findCommand('install');\n if (cmd) {\n cmd.option('--import-demo');\n }\n this.app.on('afterInstall', async (app, options) => {\n const [opts] = options?.cliArgs || [{}];\n if (opts?.importDemo) {\n //\n }\n });\n }\n\n async load() {\n this.app.acl.use(\n skip({\n resourceName: 'app',\n actionName: 'getLang',\n }),\n );\n this.app.resource({\n name: 'app',\n actions: {\n async getLang(ctx, next) {\n const SystemSetting = ctx.db.getRepository('systemSettings');\n const systemSetting = await SystemSetting.findOne();\n const currentUser = ctx.state.currentUser;\n ctx.body = {\n lang: currentUser?.appLang || systemSetting?.appLang || process.env.APP_LANG || 'en-US',\n };\n await next();\n },\n },\n });\n let root = this.options.dist;\n if (root && !root.startsWith('/')) {\n root = resolve(process.cwd(), root);\n }\n this.app.middleware.unshift(async (ctx, next) => {\n if (process.env.NOCOBASE_ENV === 'production') {\n return next();\n }\n if (!root) {\n return next();\n }\n await serve(root)(ctx, next);\n // console.log('koa-send', root, ctx.status);\n if (ctx.status == 404) {\n return send(ctx, 'index.html', { root });\n }\n });\n }\n\n getName(): string {\n return this.getPackageName(__dirname);\n }\n}\n\nexport default ClientPlugin;\n"]}
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAmC;AAA1B,kHAAA,OAAO,OAAA","sourcesContent":["export { default } from './plugin';\n"]}
|
package/lib/plugin.d.ts
DELETED
package/lib/plugin.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.ClientPlugin = void 0;
|
|
16
|
-
const acl_1 = require("@nocobase/acl");
|
|
17
|
-
const server_1 = require("@nocobase/server");
|
|
18
|
-
const koa_send_1 = __importDefault(require("koa-send"));
|
|
19
|
-
const koa_static_1 = __importDefault(require("koa-static"));
|
|
20
|
-
const path_1 = require("path");
|
|
21
|
-
class ClientPlugin extends server_1.Plugin {
|
|
22
|
-
beforeLoad() {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
const cmd = this.app.findCommand('install');
|
|
25
|
-
if (cmd) {
|
|
26
|
-
cmd.option('--import-demo');
|
|
27
|
-
}
|
|
28
|
-
this.app.on('afterInstall', (app, options) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const [opts] = (options === null || options === void 0 ? void 0 : options.cliArgs) || [{}];
|
|
30
|
-
if (opts === null || opts === void 0 ? void 0 : opts.importDemo) {
|
|
31
|
-
//
|
|
32
|
-
}
|
|
33
|
-
}));
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
load() {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
this.app.acl.use((0, acl_1.skip)({
|
|
39
|
-
resourceName: 'app',
|
|
40
|
-
actionName: 'getLang',
|
|
41
|
-
}));
|
|
42
|
-
this.app.resource({
|
|
43
|
-
name: 'app',
|
|
44
|
-
actions: {
|
|
45
|
-
getLang(ctx, next) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
const SystemSetting = ctx.db.getRepository('systemSettings');
|
|
48
|
-
const systemSetting = yield SystemSetting.findOne();
|
|
49
|
-
const currentUser = ctx.state.currentUser;
|
|
50
|
-
ctx.body = {
|
|
51
|
-
lang: (currentUser === null || currentUser === void 0 ? void 0 : currentUser.appLang) || (systemSetting === null || systemSetting === void 0 ? void 0 : systemSetting.appLang) || process.env.APP_LANG || 'en-US',
|
|
52
|
-
};
|
|
53
|
-
yield next();
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
let root = this.options.dist;
|
|
59
|
-
if (root && !root.startsWith('/')) {
|
|
60
|
-
root = (0, path_1.resolve)(process.cwd(), root);
|
|
61
|
-
}
|
|
62
|
-
this.app.middleware.unshift((ctx, next) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
if (process.env.NOCOBASE_ENV === 'production') {
|
|
64
|
-
return next();
|
|
65
|
-
}
|
|
66
|
-
if (!root) {
|
|
67
|
-
return next();
|
|
68
|
-
}
|
|
69
|
-
yield (0, koa_static_1.default)(root)(ctx, next);
|
|
70
|
-
// console.log('koa-send', root, ctx.status);
|
|
71
|
-
if (ctx.status == 404) {
|
|
72
|
-
return (0, koa_send_1.default)(ctx, 'index.html', { root });
|
|
73
|
-
}
|
|
74
|
-
}));
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
getName() {
|
|
78
|
-
return this.getPackageName(__dirname);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.ClientPlugin = ClientPlugin;
|
|
82
|
-
exports.default = ClientPlugin;
|
|
83
|
-
//# sourceMappingURL=plugin.js.map
|
package/lib/plugin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAqC;AACrC,6CAA0C;AAC1C,wDAA4B;AAC5B,4DAA+B;AAC/B,+BAA+B;AAE/B,MAAa,YAAa,SAAQ,eAAM;IAChC,UAAU;;YACd,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;YAC5C,IAAI,GAAG,EAAE;gBACP,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;aAC7B;YACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,cAAc,EAAE,CAAO,GAAG,EAAE,OAAO,EAAE,EAAE;gBACjD,MAAM,CAAC,IAA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CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAO,GAAG,EAAE,IAAI,EAAE,EAAE;gBAC9C,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,YAAY,EAAE;oBAC7C,OAAO,IAAI,EAAE,CAAC;iBACf;gBACD,IAAI,CAAC,IAAI,EAAE;oBACT,OAAO,IAAI,EAAE,CAAC;iBACf;gBACD,MAAM,IAAA,oBAAK,EAAC,IAAI,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;gBAC7B,6CAA6C;gBAC7C,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,EAAE;oBACrB,OAAO,IAAA,kBAAI,EAAC,GAAG,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;iBAC1C;YACH,CAAC,CAAA,CAAC,CAAC;QACL,CAAC;KAAA;IAED,OAAO;QACL,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;CACF;AAzDD,oCAyDC;AAED,kBAAe,YAAY,CAAC","sourcesContent":["import { skip } from '@nocobase/acl';\nimport { Plugin } from '@nocobase/server';\nimport send from 'koa-send';\nimport serve from 'koa-static';\nimport { resolve } from 'path';\n\nexport class ClientPlugin extends Plugin {\n async beforeLoad() {\n const cmd = this.app.findCommand('install');\n if (cmd) {\n cmd.option('--import-demo');\n }\n this.app.on('afterInstall', async (app, options) => {\n const [opts] = options?.cliArgs || [{}];\n if (opts?.importDemo) {\n //\n }\n });\n }\n\n async load() {\n this.app.acl.use(\n skip({\n resourceName: 'app',\n actionName: 'getLang',\n }),\n );\n this.app.resource({\n name: 'app',\n actions: {\n async getLang(ctx, next) {\n const SystemSetting = ctx.db.getRepository('systemSettings');\n const systemSetting = await SystemSetting.findOne();\n const currentUser = ctx.state.currentUser;\n ctx.body = {\n lang: currentUser?.appLang || systemSetting?.appLang || process.env.APP_LANG || 'en-US',\n };\n await next();\n },\n },\n });\n let root = this.options.dist;\n if (root && !root.startsWith('/')) {\n root = resolve(process.cwd(), root);\n }\n this.app.middleware.unshift(async (ctx, next) => {\n if (process.env.NOCOBASE_ENV === 'production') {\n return next();\n }\n if (!root) {\n return next();\n }\n await serve(root)(ctx, next);\n // console.log('koa-send', root, ctx.status);\n if (ctx.status == 404) {\n return send(ctx, 'index.html', { root });\n }\n });\n }\n\n getName(): string {\n return this.getPackageName(__dirname);\n }\n}\n\nexport default ClientPlugin;\n"]}
|
package/tsconfig.build.json
DELETED