mirror of
https://github.com/langgenius/dify.git
synced 2026-05-13 08:57:28 +08:00
- add the integrations page sidebar with collapsible icon-only navigation and Figma-aligned marketplace card - move custom integration SVGs into the iconify collection and document the Tailwind i-custom workflow - preserve source SVG collection dimensions when flattening generated icon data so existing main nav icons keep their 20x20 viewBox - add an icon dimension guard for layout-sensitive generated icons - update model provider routing, i18n, and focused frontend tests
95 lines
2.3 KiB
TypeScript
95 lines
2.3 KiB
TypeScript
import { readFile } from 'node:fs/promises'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
type IconData = {
|
|
width?: number
|
|
height?: number
|
|
}
|
|
|
|
type IconCollection = {
|
|
icons: Record<string, IconData>
|
|
width?: number
|
|
height?: number
|
|
}
|
|
|
|
type DimensionRule = {
|
|
collection: 'custom-vender'
|
|
icons: string[]
|
|
width: number
|
|
height: number
|
|
}
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
const packageDir = path.resolve(__dirname, '..')
|
|
|
|
const dimensionRules: DimensionRule[] = [
|
|
{
|
|
collection: 'custom-vender',
|
|
icons: [
|
|
'main-nav-home',
|
|
'main-nav-home-active',
|
|
'main-nav-integrations',
|
|
'main-nav-integrations-active',
|
|
'main-nav-knowledge',
|
|
'main-nav-knowledge-active',
|
|
'main-nav-marketplace',
|
|
'main-nav-marketplace-active',
|
|
'main-nav-studio',
|
|
'main-nav-studio-active',
|
|
],
|
|
width: 20,
|
|
height: 20,
|
|
},
|
|
]
|
|
|
|
const readCollection = async (collection: DimensionRule['collection']): Promise<IconCollection> => {
|
|
return JSON.parse(
|
|
await readFile(path.resolve(packageDir, collection, 'icons.json'), 'utf8'),
|
|
) as IconCollection
|
|
}
|
|
|
|
const main = async () => {
|
|
const collections = new Map<string, IconCollection>()
|
|
const failures: string[] = []
|
|
|
|
for (const rule of dimensionRules) {
|
|
if (!collections.has(rule.collection))
|
|
collections.set(rule.collection, await readCollection(rule.collection))
|
|
|
|
const collection = collections.get(rule.collection)!
|
|
|
|
for (const iconName of rule.icons) {
|
|
const icon = collection.icons[iconName]
|
|
const width = icon?.width ?? collection.width ?? 16
|
|
const height = icon?.height ?? collection.height ?? 16
|
|
|
|
if (!icon) {
|
|
failures.push(`${rule.collection}:${iconName} is missing`)
|
|
continue
|
|
}
|
|
|
|
if (width !== rule.width || height !== rule.height) {
|
|
failures.push(
|
|
`${rule.collection}:${iconName} expected ${rule.width}x${rule.height}, got ${width}x${height}`,
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
if (failures.length) {
|
|
console.error('Icon dimension check failed:')
|
|
for (const failure of failures)
|
|
console.error(`- ${failure}`)
|
|
process.exitCode = 1
|
|
return
|
|
}
|
|
|
|
console.log('Icon dimension check passed.')
|
|
}
|
|
|
|
main().catch((error: unknown) => {
|
|
console.error(error)
|
|
process.exitCode = 1
|
|
})
|