perf(templates): 优化前端资源加载性能
- 添加 DNS 预取和关键字体预加载 - 内联关键 CSS 以减少渲染阻塞 - 为非关键资源添加异步加载与 defer 属性 - 增加加载遮罩层以提升用户体验
This commit is contained in:
1 parent
0155960626
commit
517f5adbb8
1 file changed
+43
-3
+43
-3
@@ -5,11 +5,51 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{{ title or '数据处理平台' }}</title>
|
||||
|
||||
<!-- DNS Prefetch -->
|
||||
<link rel="dns-prefetch" href="//cdn.jsdelivr.net">
|
||||
<link rel="dns-prefetch" href="//cdnjs.cloudflare.com">
|
||||
|
||||
<!-- Preload Critical Fonts -->
|
||||
<link rel="preload" href="{{ url_for('static', filename='fonts/HarmonyOS_Sans_SC/HarmonyOS_Sans_SC_Regular.ttf') }}" as="font" type="font/ttf" crossorigin>
|
||||
|
||||
<!-- Critical CSS Inline -->
|
||||
<style>
|
||||
:root {
|
||||
--primary-color: #4f46e5;
|
||||
--bg-color: #f8fafc;
|
||||
--text-main: #1e293b;
|
||||
}
|
||||
[data-bs-theme="dark"] {
|
||||
--bg-color: #0f172a;
|
||||
--text-main: #f1f5f9;
|
||||
}
|
||||
body {
|
||||
background-color: var(--bg-color);
|
||||
color: var(--text-main);
|
||||
font-family: 'HarmonyOS Sans SC', system-ui, -apple-system, sans-serif;
|
||||
margin: 0;
|
||||
}
|
||||
#loadingOverlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 9999;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Font Awesome Icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" media="print" onload="this.media='all'">
|
||||
<noscript><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css"></noscript>
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
||||
@@ -142,9 +182,9 @@
|
||||
</div>
|
||||
|
||||
<!-- Bootstrap JavaScript Bundle -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" defer></script>
|
||||
|
||||
<!-- Custom Main JS -->
|
||||
<script src="{{ url_for('static', filename='js/main.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/main.js') }}" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user