feat(search): 图标搜索支持源中文名匹配(圣诞/毛绒/动漫/奢华/可爱等风格词可命中)

This commit is contained in:
sgp
2026-11-05 01:20:59 +08:00
parent 899a592c95
commit d785d5d503
5 changed files with 10 additions and 9 deletions
+5 -4
View File
@@ -507,9 +507,9 @@ function search(sources, opts) {
for (const src of sources) {
if (opts.source && src.id !== opts.source) continue;
if (opts.commercial === true && !src.commercial) continue;
// 海报源级中文匹配:字体等素材的 name 是文件名,中文名/描述在源上
const srcText = opts.includeSourceText && q
? [src.name, src.nameCn, src.desc].join(' ').toLowerCase()
// 源级中文匹配:图标/字体等素材名可能是英文,中文名在源上
const srcText = (opts.includeSourceName || opts.includeSourceText)
? [src.name, src.nameCn, opts.includeSourceText ? src.desc : ''].join(' ').toLowerCase()
: '';
const srcHit = srcText && srcText.indexOf(q) !== -1;
// 「无衬线」包含「衬线」:否定前缀命中降权,避免压过真正的衬线字体
@@ -719,7 +719,8 @@ async function handle(req, res) {
const r = search(store.icons, {
q: q.get('q'), source: q.get('source'), type: q.get('type'),
commercial: q.get('commercial') === '1', limit: q.get('limit'), offset: q.get('offset'),
dedupe: q.get('dedupe') === '1', includeNegative: q.get('include_negative') === '1'
dedupe: q.get('dedupe') === '1', includeNegative: q.get('include_negative') === '1',
includeSourceName: true
});
return ok(res, r.items, { total: r.total, limit: r.limit, offset: r.offset }, rateHeaders);
}
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1790,7 +1790,7 @@
{ id: 'withicons-sticker', type: 'emoji', name: 'With Icons Sticker', nameCn: '贴纸图标', desc: '白边贴纸风格图标,轻松活泼,适合社媒、活动与潮流视觉', style: '贴纸', license: 'MIT', licenseNote: 'MIT 协议,可商用', home: 'https://withicons.com', github: '', npm: '@iconify-json/withicons-sticker', format: 'iconify', scaleMode: 'body', coordText: '24 坐标归一化', variants: '多色 1 套', added: '2026-11-05' },
{ id: 'withicons-suite', type: 'emoji', name: 'With Icons Suite', nameCn: '办公套件图标', desc: '办公软件套件风格图标,规整统一,适合 SaaS 与效率工具', style: '扁平', license: 'MIT', licenseNote: 'MIT 协议,可商用', home: 'https://withicons.com', github: '', npm: '@iconify-json/withicons-suite', format: 'iconify', scaleMode: 'body', coordText: '24 坐标归一化', variants: '多色 1 套', added: '2026-11-05' },
{ id: 'withicons-dock', type: 'emoji', name: 'With Icons Dock', nameCn: 'Dock 图标', desc: 'macOS Dock 风格的圆角方形图标,精致拟物,适合应用图标与产品展示', style: '拟物', license: 'MIT', licenseNote: 'MIT 协议,可商用', home: 'https://withicons.com', github: '', npm: '@iconify-json/withicons-dock', format: 'iconify', scaleMode: 'body', coordText: '24 坐标归一化', variants: '多色 1 套', added: '2026-11-05' },
{ id: 'withicons-kawaii', type: 'emoji', name: 'With Icons Kawaii', nameCn: '卡哇伊图标', desc: '日系可爱风图标,圆润表情化,适合二次元、文创与年轻消费品牌', style: '卡哇伊', license: 'MIT', licenseNote: 'MIT 协议,可商用', home: 'https://withicons.com', github: '', npm: '@iconify-json/withicons-kawaii', format: 'iconify', scaleMode: 'body', coordText: '24 坐标归一化', variants: '多色 1 套', added: '2026-11-05' },
{ id: 'withicons-kawaii', type: 'emoji', name: 'With Icons Kawaii', nameCn: '可爱(卡哇伊)图标', desc: '日系可爱风图标,圆润表情化,适合二次元、文创与年轻消费品牌', style: '卡哇伊', license: 'MIT', licenseNote: 'MIT 协议,可商用', home: 'https://withicons.com', github: '', npm: '@iconify-json/withicons-kawaii', format: 'iconify', scaleMode: 'body', coordText: '24 坐标归一化', variants: '多色 1 套', added: '2026-11-05' },
{ id: 'withicons-anime', type: 'emoji', name: 'With Icons Anime', nameCn: '动漫图标', desc: '动漫风格图标,色彩鲜明、线条动感,适合游戏、番剧与二次元活动', style: '动漫', license: 'MIT', licenseNote: 'MIT 协议,可商用', home: 'https://withicons.com', github: '', npm: '@iconify-json/withicons-anime', format: 'iconify', scaleMode: 'body', coordText: '24 坐标归一化', variants: '多色 1 套', added: '2026-11-05' },
{ id: 'withicons-gothic', type: 'emoji', name: 'With Icons Gothic', nameCn: '哥特图标', desc: '暗黑哥特风格图标,锐利神秘,适合音乐、潮牌与万圣节主题', style: '哥特', license: 'MIT', licenseNote: 'MIT 协议,可商用', home: 'https://withicons.com', github: '', npm: '@iconify-json/withicons-gothic', format: 'iconify', scaleMode: 'body', coordText: '24 坐标归一化', variants: '多色 1 套', added: '2026-11-05' },
{ id: 'withicons-bauhaus', type: 'emoji', name: 'With Icons Bauhaus', nameCn: '包豪斯图标', desc: '包豪斯几何构成图标,原色块面,适合建筑、设计与艺术展览', style: '几何', license: 'MIT', licenseNote: 'MIT 协议,可商用', home: 'https://withicons.com', github: '', npm: '@iconify-json/withicons-bauhaus', format: 'iconify', scaleMode: 'body', coordText: '24 坐标归一化', variants: '多色 1 套', added: '2026-11-05' },
+2 -2
View File
@@ -1,7 +1,7 @@
{
"kind": "icons",
"total": 443168,
"builtAt": "2026-11-04T17:03:54.644Z",
"builtAt": "2026-11-04T17:20:41.111Z",
"guide": "js/data/manifest/README.md",
"idRule": "「源:名称」,如 lucide:graduation-cap",
"dicebear": {
@@ -5694,7 +5694,7 @@
"id": "withicons-kawaii",
"type": "emoji",
"name": "With Icons Kawaii",
"nameCn": "卡哇伊图标",
"nameCn": "可爱(卡哇伊)图标",
"desc": "日系可爱风图标,圆润表情化,适合二次元、文创与年轻消费品牌",
"style": "卡哇伊",
"license": "MIT",
File diff suppressed because one or more lines are too long