feat: 迁移日汇总任务并修复商务菜单图标
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// 核验实际安装的图标组件及 SVG 输出,不启动浏览器、不检查页面交互。
|
||||
const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
const assert = require('node:assert/strict')
|
||||
const { createRequire } = require('node:module')
|
||||
const root = path.resolve(__dirname, '..')
|
||||
const localRequire = createRequire(path.join(root, 'web', 'package.json'))
|
||||
const icons = localRequire('@element-plus/icons-vue')
|
||||
const { createSSRApp, h } = localRequire('vue')
|
||||
const { renderToString } = localRequire('@vue/server-renderer')
|
||||
|
||||
;(async () => {
|
||||
const source = fs.readFileSync(path.join(root, 'internal/data/business/menu_icons.go'), 'utf8')
|
||||
const entries = [...source.matchAll(/"(sw_[^"]+)":\s*"([^"]+)"/g)].map(match => ({ name: match[1], icon: match[2] }))
|
||||
assert.equal(entries.length, 14)
|
||||
const sql = fs.readFileSync(path.join(root, 'docs/sw6-to-kra/sw_to_kra_migrate.sql'), 'utf8')
|
||||
const moduleSource = fs.readFileSync(path.join(root, 'internal/modules/business/definition.go'), 'utf8')
|
||||
for (const row of entries) {
|
||||
assert.ok(icons[row.icon], `${row.icon} 未注册`)
|
||||
assert.ok(sql.includes(`WHEN '${row.name}' THEN '${row.icon}'`), `${row.name} 缺少重复执行修复`)
|
||||
assert.ok(sql.includes(`WHEN '${row.name.slice(3)}' THEN '${row.icon}'`), `${row.name} 缺少首次迁移映射`)
|
||||
assert.ok(moduleSource.includes(`Icon: databusiness.MenuIcon("${row.name}")`))
|
||||
const rendered = await renderToString(createSSRApp({ render: () => h(icons[row.icon]) }))
|
||||
assert.match(rendered, /<svg[\s>]/)
|
||||
assert.match(rendered, /<(path|circle|rect|polygon|line)[\s>]/)
|
||||
row.svgRendered = true
|
||||
}
|
||||
assert.ok(icons.Menu, 'SQL 默认图标必须已注册')
|
||||
const result = { method: '本地已安装组件的 SSR SVG 验证,包含首次/重复迁移 SQL 与模块定义一致性检查', icons: entries, passed: true }
|
||||
fs.writeFileSync(path.join(root, 'docs/sw6-to-kra/menu-icons-components-2026-11-04.json'), JSON.stringify(result, null, 2) + '\n')
|
||||
console.log(JSON.stringify(result))
|
||||
})().catch(error => { console.error(error); process.exitCode = 1 })
|
||||
Reference in New Issue
Block a user