|
@@ -161,12 +161,32 @@
|
|
|
{% endblock %}
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block extra_js %}
|
|
{% block extra_js %}
|
|
|
|
|
+<!-- 优先使用本地 D3.js -->
|
|
|
<script src="{{ url_for('static', filename='js/d3.min.js') }}"></script>
|
|
<script src="{{ url_for('static', filename='js/d3.min.js') }}"></script>
|
|
|
|
|
+<!-- fallback to CDN if local fails -->
|
|
|
<script>
|
|
<script>
|
|
|
- (function() {
|
|
|
|
|
- if (typeof d3 === 'undefined') {
|
|
|
|
|
|
|
+ if (typeof d3 === 'undefined') {
|
|
|
|
|
+ var script = document.createElement('script');
|
|
|
|
|
+ script.src = 'https://cdn.jsdelivr.net/npm/d3@7.8.5/dist/d3.min.js';
|
|
|
|
|
+ script.onload = function() {
|
|
|
|
|
+ if (typeof d3 !== 'undefined') {
|
|
|
|
|
+ loadTree();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ var container = document.getElementById('tree-container');
|
|
|
|
|
+ if (container) container.innerHTML = '<div class="h-100 d-flex align-items-center justify-content-center text-danger small">D3.js 未加载,请检查网络或稍后重试。</div>';
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ script.onerror = function() {
|
|
|
var container = document.getElementById('tree-container');
|
|
var container = document.getElementById('tree-container');
|
|
|
if (container) container.innerHTML = '<div class="h-100 d-flex align-items-center justify-content-center text-danger small">D3.js 未加载,请检查网络或稍后重试。</div>';
|
|
if (container) container.innerHTML = '<div class="h-100 d-flex align-items-center justify-content-center text-danger small">D3.js 未加载,请检查网络或稍后重试。</div>';
|
|
|
|
|
+ };
|
|
|
|
|
+ document.head.appendChild(script);
|
|
|
|
|
+ }
|
|
|
|
|
+</script>
|
|
|
|
|
+<script>
|
|
|
|
|
+ (function() {
|
|
|
|
|
+ if (typeof d3 === 'undefined') {
|
|
|
|
|
+ // CDN will handle loading and initialization
|
|
|
}
|
|
}
|
|
|
})();
|
|
})();
|
|
|
let currentData = null;
|
|
let currentData = null;
|