| 1234567891011121314151617181920 |
- import { readFileSync } from 'node:fs'
- import { fileURLToPath } from 'node:url'
- import { dirname, resolve } from 'node:path'
- const HERE = dirname(fileURLToPath(import.meta.url))
- const portal = resolve(HERE, '../../../release/web/portal')
- let s = readFileSync(portal + '/shell.html', 'utf8')
- const ids = Array.from(s.matchAll(/<!--@TEMPLATE:([^>]+?)-->/g)).map((m) => m[1])
- for (const id of ids) s = s.replace('<!--@TEMPLATE:' + id + '-->', '<template id="' + id + '">' + readFileSync(portal + '/templates/' + id + '.html', 'utf8') + '</template>')
- const T = [
- [/<a([^>]*?)href="#cms"/g, '<a$1target="_top" href="/detail/v2#tab=vibration"'],
- [/<a([^>]*?)href="#documents"/g, '<a$1target="_top" href="/detail/v2#tab=documents"'],
- [/<a([^>]*?)href="#recalc"/g, '<a$1target="_top" href="/detail/v2#tab=recalc"'],
- [/<a([^>]*?)href="(?:https?:\/\/[^"]*)?\/(?:detail\/v2|v2)[^"]*"/g, '<a$1target="_top" href="/detail/v2#workbench"'],
- ]
- for (const [re, to] of T) s = s.replace(re, to)
- for (const k of ['tab=vibration', 'tab=documents', 'tab=recalc', 'detail/v2#workbench']) {
- console.log(k + ' → ' + (s.includes(k) ? '已写入' : '缺失'))
- }
- console.log('target_top 次数 ' + (s.match(/target="_top"/g) || []).length)
|