Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-4.1] feat:Support loading styles declared by extended components #4360

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions server/controllers/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const renderIndex = async (ctx, params) => {
const dllManifest = getDllManifest();
const localeManifest = getLocaleManifest();
const importMap = getImportMap();
const extStyles = params?.installedExtensions
?.filter(item => !!item.styleLink)
.map(ext => ext.styleLink);

await ctx.render('index', {
manifest,
Expand All @@ -49,6 +52,7 @@ const renderIndex = async (ctx, params) => {
title: useDefaultTheme ? defaultTheme?.tabTitle : title,
favicon,
background,
extStyles,
hostname: ctx.hostname,
importMap: JSON.stringify(importMap),
globals: JSON.stringify({
Expand Down
2 changes: 2 additions & 0 deletions server/services/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const getInstalledExtensions = async ctx => {
const extensionName = get(item, 'metadata.labels["kubesphere.io/extension-ref"]');
const resourceVersion = get(item, 'metadata.resourceVersion');
const { link, state } = item.status;
const styleLink = item.spec.assets?.style?.link;

if (state === 'Available') {
const entries = extensionEntries.find(record => record.extensionName === extensionName);
Expand All @@ -75,6 +76,7 @@ const getInstalledExtensions = async ctx => {
name,
extensionName,
link,
styleLink,
resourceVersion,
},
entries,
Expand Down
3 changes: 3 additions & 0 deletions server/views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<% } %> <% if (manifest && manifest.css && manifest.css.length > 0) { %> <%
manifest.css.forEach(function(item){ %>
<link href="<%= bundlePrefix %>/<%= item %>" rel="stylesheet" media="all" />
<% }) %> <% } %> <% if (!isDev && extStyles && extStyles.length > 0) { %> <%
extStyles.forEach(function(extstyle){ %>
<link href="/pstatic<%= extstyle %>" rel="stylesheet" media="all" />
<% }) %> <% } %>
</head>
<body>
Expand Down