render-core 1.0.15 → 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 +3 -0
- package/library/style/style.d.ts +1 -0
- package/library/style/style.js +16 -0
- package/meta/app.d.ts +4 -0
- package/meta/app.js +19 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -5,6 +5,7 @@ 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,6 +72,8 @@ 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
78
|
window.onload = reloadPage.bind(this);
|
|
76
79
|
};
|
package/library/style/style.d.ts
CHANGED
package/library/style/style.js
CHANGED
|
@@ -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
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 };
|