mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-13 02:25:40 +02:00
Avoid top-level await (#37272)
This commit is contained in:
parent
d5831b9385
commit
cf3f8e807a
@ -1,9 +1,5 @@
|
|||||||
@import "../../node_modules/swagger-ui-dist/swagger-ui.css";
|
@import "../../node_modules/swagger-ui-dist/swagger-ui.css";
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
html,
|
html,
|
||||||
html body,
|
html body,
|
||||||
html .swagger-ui,
|
html .swagger-ui,
|
||||||
@ -15,27 +11,3 @@ html .swagger-ui .scheme-container {
|
|||||||
html.dark-mode .swagger-ui table.headers td {
|
html.dark-mode .swagger-ui table.headers td {
|
||||||
color: var(--color-text) !important;
|
color: var(--color-text) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.swagger-back-link {
|
|
||||||
color: var(--color-primary);
|
|
||||||
text-decoration: none;
|
|
||||||
position: absolute;
|
|
||||||
top: 1rem;
|
|
||||||
right: 1.5rem;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.swagger-back-link:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
.swagger-back-link svg {
|
|
||||||
color: inherit;
|
|
||||||
fill: currentcolor;
|
|
||||||
margin-right: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.swagger-spec-content {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
29
web_src/css/swagger-standalone.css
Normal file
29
web_src/css/swagger-standalone.css
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
@import "swagger-render.css";
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.swagger-back-link {
|
||||||
|
color: var(--color-primary);
|
||||||
|
text-decoration: none;
|
||||||
|
position: absolute;
|
||||||
|
top: 1rem;
|
||||||
|
right: 1.5rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.swagger-back-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.swagger-back-link svg {
|
||||||
|
color: inherit;
|
||||||
|
fill: currentcolor;
|
||||||
|
margin-right: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.swagger-spec-content {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
@ -2,12 +2,14 @@ import type {FrontendRenderFunc} from '../plugin.ts';
|
|||||||
import {initSwaggerUI} from '../swagger.ts';
|
import {initSwaggerUI} from '../swagger.ts';
|
||||||
|
|
||||||
// HINT: SWAGGER-CSS-IMPORT: this import is also necessary when swagger is used as a frontend external render
|
// HINT: SWAGGER-CSS-IMPORT: this import is also necessary when swagger is used as a frontend external render
|
||||||
// It must be on top-level, doesn't work in a function
|
// But it can't share the same CSS file with the standalone page: it triggers our Vite manifest parser's bug
|
||||||
// Static import doesn't work (it needs to use manifest.json to manually add the CSS file)
|
// Although single top-level "await import(css)" can work, it requires es2022.
|
||||||
await import('../../../css/swagger.css');
|
// Otherwise, single function-level "await import(css)" can't work due to Vite's dependency analysis and bundling.
|
||||||
|
import '../../../css/swagger-render.css';
|
||||||
|
|
||||||
export const frontendRender: FrontendRenderFunc = async (opts): Promise<boolean> => {
|
export const frontendRender: FrontendRenderFunc = async (opts): Promise<boolean> => {
|
||||||
try {
|
try {
|
||||||
|
await import('../../../css/swagger-render.css');
|
||||||
await initSwaggerUI(opts.container, {specText: opts.contentString()});
|
await initSwaggerUI(opts.container, {specText: opts.contentString()});
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// FIXME: INCORRECT-VITE-MANIFEST-PARSER: it just happens to work for current dependencies
|
// FIXME: INCORRECT-VITE-MANIFEST-PARSER: it just happens to work for current dependencies
|
||||||
// If this module depends on another one and that one imports "swagger.css", then {{AssetURI "css/swagger.css"}} won't work
|
// If this module depends on another one and that one imports "swagger.css", then {{AssetURI "css/swagger.css"}} won't work
|
||||||
import '../css/swagger.css';
|
import '../css/swagger-standalone.css';
|
||||||
import {initSwaggerUI} from './render/swagger.ts';
|
import {initSwaggerUI} from './render/swagger.ts';
|
||||||
|
|
||||||
async function initGiteaAPIViewer() {
|
async function initGiteaAPIViewer() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user