feat(icons): 新增微软 Fluent Emoji 3D 位图图标源(1586 个,MIT),支持位图图标渲染与导出内联

This commit is contained in:
sgp
2026-11-05 11:33:36 +08:00
parent 07d2a79a60
commit fcb70e8c7f
1606 changed files with 266 additions and 55 deletions
+13 -6
View File
@@ -220,9 +220,13 @@ const HGB_Exporter = (function () {
* @param {string|null} bgColor 背景色;null 表示透明
*/
function renderCanvas(size, bgColor, svgOverride) {
return new Promise((resolve, reject) => {
const svgStr = svgOverride ||
buildExportSvg(bgColor === undefined ? null : bgColor);
const raw = svgOverride ||
buildExportSvg(bgColor === undefined ? null : bgColor);
// 位图图标(3D PNG)以相对 href 引用,转 blob 后相对路径失效 → 先内联为 data URI
const ready = (typeof HGB_IconLib !== 'undefined' && HGB_IconLib.inlineRasters)
? HGB_IconLib.inlineRasters(raw)
: Promise.resolve(raw);
return ready.then((svgStr) => new Promise((resolve, reject) => {
const blob = new Blob([svgStr], { type: 'image/svg+xml;charset=utf-8' });
const url = URL.createObjectURL(blob);
@@ -245,12 +249,15 @@ const HGB_Exporter = (function () {
reject(new Error('SVG 渲染失败,请检查元素内容'));
};
img.src = url;
});
}));
}
/* ============ 导出:SVG ============ */
function exportSvg(svgOverride, bgColor) {
const svgStr = svgOverride || buildExportSvg(bgColor || HGB_Store.get().bg || '#FFFFFF');
async function exportSvg(svgOverride, bgColor) {
let svgStr = svgOverride || buildExportSvg(bgColor || HGB_Store.get().bg || '#FFFFFF');
if (typeof HGB_IconLib !== 'undefined' && HGB_IconLib.inlineRasters) {
svgStr = await HGB_IconLib.inlineRasters(svgStr);
}
download(svgStr, 'image/svg+xml', safeName() + '.svg');
return svgStr;
}