Skip to content

Commit c9e521a

Browse files
authored
Merge pull request #1543 from easyops-cn/steve/fix-lucide-icons
fix(): Lucide icons don't support range request yet
2 parents 590d3db + 37e6e7c commit c9e521a

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

bricks/icons/src/shared/RangeRequest.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import { getRuntime } from "@next-core/runtime";
44
import antdIcons from "../antd-icon/generated/icons.json";
55
import easyopsIcons from "../easyops-icon/generated/icons.json";
66
import faIcons from "../fa-icon/generated/icons.json";
7-
import lucideIcons from "../lucide-icon/generated/icons.json";
87
import antdRanges from "../antd-icon/generated/ranges.json";
98
import faRanges from "../fa-icon/generated/ranges.json";
109
import easyopsRanges from "../easyops-icon/generated/ranges.json";
11-
import lucideRanges from "../lucide-icon/generated/ranges.json";
1210

1311
const publicPath =
1412
process.env.NODE_ENV === "test" ? "" : __webpack_public_path__;
@@ -29,11 +27,6 @@ const SETTINGS_MAP = {
2927
icons: easyopsIcons,
3028
ranges: easyopsRanges,
3129
},
32-
lucide: {
33-
url: `${publicPath}chunks/lucide-icons/all.${lucideRanges._hash}.svg`,
34-
icons: lucideIcons,
35-
ranges: lucideRanges,
36-
},
3730
} as unknown as Record<string, Settings>;
3831

3932
const TEST_URL = `${publicPath}manifest.json`;
@@ -99,7 +92,7 @@ export async function supportsMultipartRangeRequest() {
9992
return await supportsPromise;
10093
}
10194

102-
type Lib = "antd" | "fa" | "easyops" | "lucide";
95+
type Lib = "antd" | "fa" | "easyops";
10396

10497
interface Settings {
10598
url: string;
@@ -141,7 +134,7 @@ const dbPromise = new Promise<IDBDatabase | null>((resolve) => {
141134
const db = (event.target as IDBOpenDBRequest).result;
142135
// These transactions maybe the same.
143136
const transactions = new Set<IDBTransaction>();
144-
for (const lib of ["antd", "fa", "easyops", "lucide"]) {
137+
for (const lib of ["antd", "fa", "easyops"]) {
145138
if (!db.objectStoreNames.contains(lib)) {
146139
transactions.add(db.createObjectStore(lib).transaction);
147140
}
@@ -177,7 +170,7 @@ const dbPromise = new Promise<IDBDatabase | null>((resolve) => {
177170
return;
178171
}
179172
Promise.all(
180-
["antd", "fa", "easyops", "lucide"].map(
173+
["antd", "fa", "easyops"].map(
181174
async (lib) =>
182175
new Promise<void>((libResolve, libReject) => {
183176
new Promise<string | null>((hashResolve) => {

bricks/icons/src/shared/SvgCache.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const REGEX_MICRO_APPS_WITH_VERSION = /\/micro-apps\/v([23])\//;
2121

2222
const antdRangeRequest = new RangeRequest("antd");
2323
const easyopsRangeRequest = new RangeRequest("easyops");
24-
const lucideRangeRequest = new RangeRequest("lucide");
2524

2625
/** Given a URL, this function returns the resulting SVG element or an appropriate error symbol. */
2726
async function resolveIcon(
@@ -33,13 +32,13 @@ async function resolveIcon(
3332

3433
// istanbul ignore next: experimental
3534
try {
36-
if (options?.id && (await supportsMultipartRangeRequest())) {
35+
if (
36+
options?.id &&
37+
options?.lib !== "lucide" &&
38+
(await supportsMultipartRangeRequest())
39+
) {
3740
const rangeRequest =
38-
options.lib === "easyops"
39-
? easyopsRangeRequest
40-
: options.lib === "lucide"
41-
? lucideRangeRequest
42-
: antdRangeRequest;
41+
options.lib === "easyops" ? easyopsRangeRequest : antdRangeRequest;
4342
content = await rangeRequest.fetch(options.id);
4443
}
4544
} catch {

0 commit comments

Comments
 (0)