render-core 1.0.0 → 1.0.1

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.
File without changes
File without changes
package/index.d.ts CHANGED
@@ -1,9 +1,12 @@
1
1
  import { Component } from "./class/component";
2
+ import routerController from "render-security-tpyescript/class/Router";
2
3
  export declare class RenderJS {
3
4
  readonly version: string;
4
5
  readonly tagLib: Map<string, Component>;
6
+ private routerC;
5
7
  constructor();
6
8
  addTag(component: Component | Component[]): void;
9
+ addRouter(router: routerController): void;
7
10
  run(): void;
8
11
  }
9
12
  export declare class EmbedRenderJs {
package/index.js CHANGED
@@ -33,10 +33,35 @@ var RenderJS = /** @class */ (function () {
33
33
  });
34
34
  }
35
35
  };
36
+ RenderJS.prototype.addRouter = function (router) {
37
+ this.routerC = router;
38
+ };
36
39
  //运行renderJs
37
40
  RenderJS.prototype.run = function () {
38
- Reflect.set(window, "tagLib", this.tagLib);
39
- renderHtml(document.body.children, this.tagLib);
41
+ if (this.routerC) {
42
+ if (this.routerC.data.beforeRouter()) {
43
+ if (typeof this.routerC.getRule(location.href) === "boolean") {
44
+ Reflect.set(window, "tagLib", this.tagLib);
45
+ renderHtml(document.body.children, this.tagLib);
46
+ }
47
+ else {
48
+ if (this.routerC.getRule(location.href).beforeRouter()) {
49
+ Reflect.set(window, "tagLib", this.tagLib);
50
+ renderHtml(document.body.children, this.tagLib);
51
+ }
52
+ else {
53
+ location.href = "/http/error/404.html";
54
+ }
55
+ }
56
+ }
57
+ else {
58
+ location.href = "/http/error/404.html";
59
+ }
60
+ }
61
+ else {
62
+ Reflect.set(window, "tagLib", this.tagLib);
63
+ renderHtml(document.body.children, this.tagLib);
64
+ }
40
65
  };
41
66
  return RenderJS;
42
67
  }());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "render-core",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "The router for render-js",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",