♻️ refactor(vscode): 代码阅读的种类图标改成插件自己定义的一组(契约里的封闭名字集合),webview 只带这些图标,不再打包 lucide 全套

This commit is contained in:
cruldra committed 2026-09-27 20:23:44 +08:00
1 parent c1d0dd3753
commit b186b007a4
11 files changed
+139 -47

No files matched your search

@@ -1,8 +1,7 @@
import type { BlockView } from './types'
import { Database, SquareDashed, SquareFunction } from 'lucide-react'
import type { BlockView, KindIconName } from './types'
import { renderToStaticMarkup } from 'react-dom/server'
import { describe, expect, it } from 'vitest'
import { KIND_ICONS, KindIcon, lucideIcon } from './kindIcons'
import { KIND_ICON_COMPONENTS, KIND_ICONS, KindIcon } from './kindIcons'
function render(block: Pick<BlockView, 'kind' | 'badge'>, name: string): string {
return renderToStaticMarkup(<KindIcon block={block} name={name} />)
@@ -33,14 +32,13 @@ describe('块的种类图标', () => {
statement: 'code',
comment: 'message-square-text',
})
for (const name of Object.values(KIND_ICONS))
expect(lucideIcon(name), name).not.toBe(SquareDashed)
})
it('lucide 图标名按 kebab-case 认;认不出的名字画虚线方块', () => {
expect(lucideIcon('square-function')).toBe(SquareFunction)
expect(lucideIcon('database')).toBe(Database)
expect(lucideIcon('no-such-icon')).toBe(SquareDashed)
it('这组图标里每个名字画的就是 lucide 里同名的图标', () => {
for (const name of Object.keys(KIND_ICON_COMPONENTS) as KindIconName[]) {
const html = render({ kind: 'sqlalchemy.table', badge: { label: name, color: { dark: '#fff', light: '#000' }, icon: name } }, name)
expect(html, name).toContain(`class="lucide lucide-${name}"`)
}
})
it('只画图标不带字,名字在悬停提示和 aria-label 里;20px 的框、16px 的图形', () => {