render-core 1.0.14 → 1.0.16

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/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { Component } from "./class/component";
2
2
  import meta from "./meta/meta";
3
- import { renderHtml } from "./runtime/runtime";
3
+ import { reloadPage, renderHtml } from "./runtime/runtime";
4
4
  import { themeStyle } from "./core/utility/styleUtility";
5
5
  // @ts-ignore
6
6
  import { redirect } from "render-security/utility/redirect";
7
7
  import { PageController } from "./class/pageController";
8
+ import { App } from "./meta/app";
8
9
  //页面RenderJs
9
10
  var RenderJS = /** @class */ (function () {
10
11
  //构造函数
@@ -71,8 +72,10 @@ var RenderJS = /** @class */ (function () {
71
72
  themeStyle(component, styleLib);
72
73
  });
73
74
  Reflect.set(window, "styleLib", styleLib);
75
+ Reflect.set(window, "context", new App());
76
+ //开始渲染
74
77
  renderHtml(document.body.children, this.page);
75
- window.onload = this.run;
78
+ window.onload = reloadPage.bind(this);
76
79
  };
77
80
  return RenderJS;
78
81
  }());
@@ -1 +1,2 @@
1
1
  export declare function styleResolve(tag: string): void;
2
+ export declare function reloadStyle(theme: string): void;
@@ -10,3 +10,19 @@ export function styleResolve(tag) {
10
10
  loadStyle(tag, theme, Reflect.get(window, "styleLib").get(tag.toUpperCase()).get(theme));
11
11
  }
12
12
  }
13
+ export function reloadStyle(theme) {
14
+ Reflect.get(window, "styleLib").forEach(function (value, key) {
15
+ var styles = document.getElementsByTagName("style");
16
+ for (var i = 0; i < styles.length; i++) {
17
+ if (styles[i].getAttribute("tag") === key) {
18
+ var style = document.createElement('style');
19
+ var text = document.createTextNode(value[theme]);
20
+ style.appendChild(text);
21
+ style.setAttribute("tag", key.toUpperCase());
22
+ style.setAttribute("theme", theme);
23
+ var head = document.getElementsByTagName('head')[0];
24
+ head.replaceChild(styles[i], style);
25
+ }
26
+ }
27
+ });
28
+ }
package/meta/app.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare class App {
2
+ constructor();
3
+ setTheme(theme: string): void;
4
+ }
package/meta/app.js ADDED
@@ -0,0 +1,19 @@
1
+ // @ts-ignore
2
+ import { status_write } from "render-status";
3
+ import { reloadStyle } from "../library/style/style";
4
+ var App = /** @class */ (function () {
5
+ function App() {
6
+ }
7
+ //更改会话样式
8
+ App.prototype.setTheme = function (theme) {
9
+ status_write({
10
+ type: "session",
11
+ fields: {
12
+ theme: theme
13
+ }
14
+ });
15
+ reloadStyle(theme);
16
+ };
17
+ return App;
18
+ }());
19
+ export { App };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "render-core",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "The router for render-js",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,2 +1,3 @@
1
1
  import { PageController } from "../class/pageController";
2
2
  export declare function renderHtml(collection: HTMLCollection, link: PageController): void;
3
+ export declare function reloadPage(): void;
@@ -14,3 +14,6 @@ export function renderHtml(collection, link) {
14
14
  }
15
15
  }
16
16
  }
17
+ export function reloadPage() {
18
+ this.run();
19
+ }