@@ -4,8 +4,11 @@ import { CoaRouter } from '../service/CoaRouter'
44export interface CoaSwaggerConfig {
55 swaggerFilter : boolean
66 swaggerDocExpansion : 'full' | 'list' | 'none'
7+ swaggerLibrarySite : string
78}
89
10+ const DEFAULT_LIBRARY_SITE = 'https://cdn.jsdelivr.net/npm/[email protected] ' 11+
912export class CoaSwagger {
1013 private data = {
1114 openapi : '3.0.0' ,
@@ -39,7 +42,8 @@ export class CoaSwagger {
3942
4043 constructor ( router : CoaRouter < any > , config : CoaSwaggerConfig ) {
4144 this . router = router
42- this . config = Object . assign ( { swaggerFilter : false , swaggerDocExpansion : 'list' } , config )
45+ this . config = Object . assign ( { swaggerFilter : false , swaggerDocExpansion : 'list' , swaggerLibrarySite : DEFAULT_LIBRARY_SITE } , config )
46+ this . config . swaggerLibrarySite = this . config . swaggerLibrarySite . replace ( / \/ + $ / , '' )
4347 }
4448
4549 getData ( matchGroup : string , serverUrl : string , codeUrl : string , version : string ) {
@@ -203,9 +207,9 @@ const getHtml = (urls: object[], config: CoaSwaggerConfig) => `
203207<head>
204208 <meta charset="UTF-8">
205209 <title>接口文档</title>
206- <link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/npm/[email protected] /favicon-32x32.png" sizes="32x32"/> 207- <link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/npm/[email protected] /favicon-16x16.png" sizes="16x16"/> 208- <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected] /swagger-ui.css"> 210+ <link rel="icon" type="image/png" href="${ config . swaggerLibrarySite } /favicon-32x32.png" sizes="32x32"/>
211+ <link rel="icon" type="image/png" href="${ config . swaggerLibrarySite } /favicon-16x16.png" sizes="16x16"/>
212+ <link rel="stylesheet" type="text/css" href="${ config . swaggerLibrarySite } /swagger-ui.css">
209213 <style>
210214 html {
211215 box-sizing: border-box;
@@ -290,9 +294,14 @@ const getHtml = (urls: object[], config: CoaSwaggerConfig) => `
290294 padding: 0 20px 0 10px;
291295 margin-bottom: 0;
292296 }
297+
298+ /* 标题框轮廓 */
299+ .swagger-ui .opblock-summary-control {
300+ outline: none !important;
301+ }
293302
294303 /* 接口标题上下间距 */
295- .opblock-tag-section > div {
304+ .swagger-ui . opblock-tag-section > div {
296305 margin-top: 15px !important;
297306 }
298307
@@ -350,8 +359,8 @@ const getHtml = (urls: object[], config: CoaSwaggerConfig) => `
350359</head>
351360<body>
352361<div id="swagger-ui"></div>
353- <script src="https://cdn.jsdelivr.net/npm/[email protected] /swagger-ui-bundle.js"></script> 354- <script src="https://cdn.jsdelivr.net/npm/[email protected] /swagger-ui-standalone-preset.js"></script> 362+ <script src="${ config . swaggerLibrarySite } /swagger-ui-bundle.js"></script>
363+ <script src="${ config . swaggerLibrarySite } /swagger-ui-standalone-preset.js"></script>
355364<script>
356365 window.onload = function () {
357366
0 commit comments