chanjs 1.1.7 → 1.1.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/core/lib/task.js +1 -1
- package/core/lib/view.js +13 -4
- package/package.json +1 -1
package/core/lib/task.js
CHANGED
package/core/lib/view.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import path from "path";
|
2
|
-
import dayjs from
|
3
|
-
import { createRequire } from
|
2
|
+
import dayjs from 'dayjs';
|
3
|
+
import { createRequire } from 'module';
|
4
4
|
const require = createRequire(import.meta.url);
|
5
5
|
|
6
6
|
const template = require("art-template");
|
@@ -22,10 +22,19 @@ template.defaults.imports.dateFormat = function (date, format) {
|
|
22
22
|
return date.format(format);
|
23
23
|
};
|
24
24
|
|
25
|
+
template.defaults.imports.truncate = (str, length = 10) => {
|
26
|
+
return str.length > length ? str.slice(0, length) + '...' : str;
|
27
|
+
};
|
28
|
+
|
29
|
+
// 注册安全序列化方法
|
30
|
+
template.defaults.imports.safeStringify = (obj) => {
|
31
|
+
return JSON.stringify(obj, null, 2);
|
32
|
+
};
|
33
|
+
|
25
34
|
export default (app, config) => {
|
26
35
|
const { APP_PATH, views, env } = config;
|
27
|
-
|
28
|
-
const all = [...views,
|
36
|
+
//合并插件中的view
|
37
|
+
const all = [...views, 'app/modules/web/view'];
|
29
38
|
|
30
39
|
app.set("view options", {
|
31
40
|
debug: env === "dev",
|