perf: foot_js

This commit is contained in:
feng 2025-08-15 16:34:00 +08:00 committed by ZhaoJiSen
parent 92b20fe2ef
commit 7d06819bbe

View File

@ -1,6 +1,15 @@
{% load i18n %} {% load i18n %}
{% load static %} {% load static %}
<script src="{% static "js/plugins/metisMenu/jquery.metisMenu.3.0.7.js" %}"></script>
<script src="{% static "js/plugins/toastr/toastr.min.js" %}"></script>
<script src="{% static "js/inspinia.js" %}"></script>
<script src="{% static "js/jumpserver.js" %}?v=10"></script>
<script src="{% static 'js/plugins/select2/select2.full.min.js' %}"></script>
<script src="{% static 'js/plugins/select2/i18n/zh-CN.js' %}"></script>
<script src="{% static 'js/plugins/markdown-it.min.js' %}"></script>
{% if INTERFACE.footer_content %} {% if INTERFACE.footer_content %}
<style> <style>
.markdown-footer{ .markdown-footer{
@ -21,15 +30,20 @@
<div id="markdown-output" class="markdown-footer" role="contentinfo" aria-label="{% trans 'Page footer' %}"></div> <div id="markdown-output" class="markdown-footer" role="contentinfo" aria-label="{% trans 'Page footer' %}"></div>
{% endif %} {% endif %}
<script src="{% static 'js/plugins/markdown-it.min.js' %}"></script> <script type="text/markdown"> {{ INTERFACE.footer_content }} </script>
<script> <script>
(function () { activeNav("{{ FORCE_SCRIPT_NAME }}");
var container = document.getElementById('markdown-output');
if (!container) return;
var src = `{{ INTERFACE.footer_content|default:''|escapejs }}`.replace(/\r\n?/g, '\n').trim(); $(document).ready(function () {
if (!src) { container.remove(); return; } setAjaxCSRFToken();
$('textarea').attr('rows', 5);
if ($('.tooltip')[0]) {
$('.tooltip').tooltip();
}
$.fn.select2.defaults.set('language', getUserLang());
var md = window.markdownit({ var md = window.markdownit({
html: false, html: false,
@ -38,17 +52,17 @@
breaks: true breaks: true
}); });
var html = md.render(src); const markdownContent = `{{ INTERFACE.footer_content|default:''|escapejs }}`.replace(/\r\n?/g, '\n').trim();;
const markdownRef = document.getElementById('markdown-output');
if (window.DOMPurify) { if (markdownRef && markdownContent) {
html = window.DOMPurify.sanitize(html); const renderedContent = md.render(markdownContent.trim());
}
container.innerHTML = html; markdownRef.innerHTML = renderedContent;
markdownRef.querySelectorAll('a').forEach(link => {
container.querySelectorAll('a').forEach(function (a) { link.setAttribute('target', '_blank');
a.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer');
a.setAttribute('rel', 'noopener noreferrer'); });
}
}); });
})();
</script> </script>