feat: 整合rapi-doc文档主题
This commit is contained in:
@@ -21,7 +21,7 @@ func TestNewServer(t *testing.T) {
|
|||||||
|
|
||||||
s := NewServer(9087, WithRateLimitInstance(rate_limit.MemoryClient), WithDocConfig(&DocConfig{
|
s := NewServer(9087, WithRateLimitInstance(rate_limit.MemoryClient), WithDocConfig(&DocConfig{
|
||||||
Enable: true,
|
Enable: true,
|
||||||
UiTheme: consts.SwaggerUIThemeRedocFree.String(),
|
UiTheme: consts.SwaggerUIThemeRapiDoc.String(),
|
||||||
BaseUri: "",
|
BaseUri: "",
|
||||||
Flag: "test-server",
|
Flag: "test-server",
|
||||||
ServerList: &openapi3.Servers{
|
ServerList: &openapi3.Servers{
|
||||||
|
|||||||
@@ -46,7 +46,12 @@ func (su *SwaggerUI) Handler() func(ctx *gin.Context) {
|
|||||||
return su.HandleKnife4goUI()
|
return su.HandleKnife4goUI()
|
||||||
case consts.SwaggerUIThemeDefault:
|
case consts.SwaggerUIThemeDefault:
|
||||||
return su.HandleSwaggerDefaultUI()
|
return su.HandleSwaggerDefaultUI()
|
||||||
case consts.SwaggerUIThemeYDocLucky, consts.SwaggerUIThemeElements, consts.SwaggerUIThemeSwaggerUI, consts.SwaggerUIThemeScalar, consts.SwaggerUIThemeRedocFree:
|
case consts.SwaggerUIThemeYDocLucky,
|
||||||
|
consts.SwaggerUIThemeElements,
|
||||||
|
consts.SwaggerUIThemeSwaggerUI,
|
||||||
|
consts.SwaggerUIThemeScalar,
|
||||||
|
consts.SwaggerUIThemeRedocFree,
|
||||||
|
consts.SwaggerUIThemeRapiDoc:
|
||||||
// YDoc-Lucky-UI 主题处理
|
// YDoc-Lucky-UI 主题处理
|
||||||
return su.renderWebPage(su.uiTheme)
|
return su.renderWebPage(su.uiTheme)
|
||||||
default:
|
default:
|
||||||
|
|||||||
1
router/theme/rapi-doc/default.min.css
vendored
Normal file
1
router/theme/rapi-doc/default.min.css
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.hljs{display:block;overflow-x:auto;padding:.5em;background:#F0F0F0}.hljs,.hljs-subst{color:#444}.hljs-comment{color:#888888}.hljs-keyword,.hljs-attribute,.hljs-selector-tag,.hljs-meta-keyword,.hljs-doctag,.hljs-name{font-weight:bold}.hljs-type,.hljs-string,.hljs-number,.hljs-selector-id,.hljs-selector-class,.hljs-quote,.hljs-template-tag,.hljs-deletion{color:#880000}.hljs-title,.hljs-section{color:#880000;font-weight:bold}.hljs-regexp,.hljs-symbol,.hljs-variable,.hljs-template-variable,.hljs-link,.hljs-selector-attr,.hljs-selector-pseudo{color:#BC6060}.hljs-literal{color:#78A960}.hljs-built_in,.hljs-bullet,.hljs-code,.hljs-addition{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta-string{color:#4d99bf}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:bold}
|
||||||
2
router/theme/rapi-doc/highlight.min.js
vendored
Normal file
2
router/theme/rapi-doc/highlight.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
24
router/theme/rapi-doc/index.html
Normal file
24
router/theme/rapi-doc/index.html
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta content="width=device-width,minimum-scale=1,initial-scale=1,user-scalable=yes" name="viewport">
|
||||||
|
<title>RapiDoc</title>
|
||||||
|
<link href="default.min.css" rel="stylesheet">
|
||||||
|
<script src="highlight.min.js"></script>
|
||||||
|
<script defer="defer" src="rapidoc-min.js"></script>
|
||||||
|
</head>
|
||||||
|
<script>window.addEventListener('DOMContentLoaded', (event) => {
|
||||||
|
const docEl = document.getElementById('thedoc');
|
||||||
|
docEl.addEventListener('before-try', (e) => {
|
||||||
|
e.detail.request.headers.append('AAA-BBB', 'CCC DDDD');
|
||||||
|
});
|
||||||
|
});</script>
|
||||||
|
<body>
|
||||||
|
<rapi-doc allow-advanced-search="true" allow-authentication="true" allow-search="false" allow-server-selection="true" allow-spec-file-download="true"
|
||||||
|
allow-spec-url-load="false" id="thedoc" match-type="regex" persist-auth="true"
|
||||||
|
render-style="read" schema-style="tree" scroll-behavior="smooth" show-components="true"
|
||||||
|
show-header="true" show-info="true" show-method-in-nav-bar="true" spec-url="{{DOC_PATH}}"
|
||||||
|
theme="dark" update-route="false" use-path-in-nav-bar="true"></rapi-doc>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
3917
router/theme/rapi-doc/rapidoc-min.js
vendored
Normal file
3917
router/theme/rapi-doc/rapidoc-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user