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 CHANGED
@@ -1,4 +1,4 @@
1
- const schedule = require('node-schedule');
1
+ import schedule from 'node-schedule
2
2
 
3
3
  export default class Task {
4
4
  constructor(config = {}) {
package/core/lib/view.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
- import dayjs from "dayjs";
3
- import { createRequire } from "module";
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
- //合并插件中的view
28
- const all = [...views, "app/modules/web/view"];
36
+ //合并插件中的view
37
+ const all = [...views, 'app/modules/web/view'];
29
38
 
30
39
  app.set("view options", {
31
40
  debug: env === "dev",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "chanjs",
4
- "version": "1.1.7",
4
+ "version": "1.1.9",
5
5
  "description": "chanjs基于express5 纯js研发的轻量级mvc框架。",
6
6
  "main": "index.js",
7
7
  "module": "index.js",