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 () => {
|
||||
Object.assign(window.UiContext, JSON.parse(window.UiContextNew));
|
||||
Object.assign(window.UserContext, JSON.parse(window.UserContextNew));
|
||||
const [data, HydroExports] = await prefetch;
|
||||
Object.assign(window, { HydroExports });
|
||||
eval(data); // eslint-disable-line no-eval
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
var UserContext = '{{ UserContext|json|jsesc|safe }}';
|
||||
</script>
|
||||
{% set UiContext = Object.create(UiContext) %}
|
||||
{% set UserContext = Object.create(UserContext) %}
|
||||
{% 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="/hydro.js?version={{ global.Hydro.version['ui-default'] }}"></script>
|
||||
@@ -75,7 +76,10 @@
|
||||
{% block body %}{% endblock %}
|
||||
{% block script %}{% endblock %}
|
||||
{% 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 %}
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user