mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: support incremental UserContext
This commit is contained in:
2 files changed
+6
-1
No files matched your search
@@ -48,6 +48,7 @@ const prefetch = Promise.all([
|
|||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', async () => {
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
Object.assign(window.UiContext, JSON.parse(window.UiContextNew));
|
Object.assign(window.UiContext, JSON.parse(window.UiContextNew));
|
||||||
|
Object.assign(window.UserContext, JSON.parse(window.UserContextNew));
|
||||||
const [data, HydroExports] = await prefetch;
|
const [data, HydroExports] = await prefetch;
|
||||||
Object.assign(window, { HydroExports });
|
Object.assign(window, { HydroExports });
|
||||||
eval(data); // eslint-disable-line no-eval
|
eval(data); // eslint-disable-line no-eval
|
||||||
|
|||||||
@@ -64,6 +64,7 @@
|
|||||||
var UserContext = '{{ UserContext|json|jsesc|safe }}';
|
var UserContext = '{{ UserContext|json|jsesc|safe }}';
|
||||||
</script>
|
</script>
|
||||||
{% set UiContext = Object.create(UiContext) %}
|
{% set UiContext = Object.create(UiContext) %}
|
||||||
|
{% set UserContext = Object.create(UserContext) %}
|
||||||
{% if process.env.DEV %}
|
{% if process.env.DEV %}
|
||||||
<script type="text/javascript" src="/resource/hash/lang-{{ _('__id') }}.js?version={{ global.Hydro.version['ui-default'] }}"></script>
|
<script type="text/javascript" src="/resource/hash/lang-{{ _('__id') }}.js?version={{ global.Hydro.version['ui-default'] }}"></script>
|
||||||
<script type="text/javascript" src="/hydro.js?version={{ global.Hydro.version['ui-default'] }}"></script>
|
<script type="text/javascript" src="/hydro.js?version={{ global.Hydro.version['ui-default'] }}"></script>
|
||||||
@@ -75,7 +76,10 @@
|
|||||||
{% block body %}{% endblock %}
|
{% block body %}{% endblock %}
|
||||||
{% block script %}{% endblock %}
|
{% block script %}{% endblock %}
|
||||||
{% if not isIE(handler.request.headers['user-agent']) and not handler.session.legacy %}
|
{% if not isIE(handler.request.headers['user-agent']) and not handler.session.legacy %}
|
||||||
<script>var UiContextNew = '{{ UiContext|json|jsesc|safe }}';</script>
|
<script>
|
||||||
|
var UiContextNew = '{{ UiContext|json|jsesc|safe }}';
|
||||||
|
var UserContextNew = '{{ UserContext|json|jsesc|safe }}';
|
||||||
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in new issue
Block a user