feat: 调整swagger-ui主题

This commit is contained in:
2026-01-09 22:48:56 +08:00
parent 67c992cd78
commit 4150a1ffe4

View File

@@ -9,8 +9,8 @@
<style> <style>
.theme-selector { .theme-selector {
position: fixed; position: fixed;
top: 20px; top: 70px;
right: 20px; right: 0px;
z-index: 100; z-index: 100;
background: white; background: white;
padding: 10px; padding: 10px;
@@ -25,6 +25,7 @@
</style> </style>
</head> </head>
<body> <body>
<!--
<div class="theme-selector"> <div class="theme-selector">
<label for="theme-select">选择主题: </label> <label for="theme-select">选择主题: </label>
<select id="theme-select" onchange="changeTheme(this.value)"> <select id="theme-select" onchange="changeTheme(this.value)">
@@ -44,6 +45,7 @@
<option value="2.x-theme-outline.css">2.x-theme-outline.css</option> <option value="2.x-theme-outline.css">2.x-theme-outline.css</option>
</select> </select>
</div> </div>
-->
<div id="swagger-ui"></div> <div id="swagger-ui"></div>
@@ -53,7 +55,7 @@
<script> <script>
// 主题映射表 // 主题映射表
const themes = { const themes = {
'theme-default': '', 'theme-default': '3.x/theme-material.css',
'3.x-theme-material': '3.x/theme-material.css', '3.x-theme-material': '3.x/theme-material.css',
'3.x-theme-monokai': '3.x/theme-monokai.css', '3.x-theme-monokai': '3.x/theme-monokai.css',
'3.x-theme-feeling-blue': '3.x/theme-feeling-blue.css', '3.x-theme-feeling-blue': '3.x/theme-feeling-blue.css',
@@ -87,7 +89,7 @@
window.onload = function() { window.onload = function() {
// 从本地存储恢复主题 // 从本地存储恢复主题
const savedTheme = localStorage.getItem('swagger-theme') || 'theme-material'; const savedTheme = localStorage.getItem('swagger-theme') || 'theme-material';
document.getElementById('theme-select').value = savedTheme; // document.getElementById('theme-select').value = savedTheme;
if (savedTheme !== 'theme-default') { if (savedTheme !== 'theme-default') {
document.getElementById('swagger-theme').href = themes[savedTheme]; document.getElementById('swagger-theme').href = themes[savedTheme];