修复Action打包问题与渲染层过滤问题

This commit is contained in:
cc
2026-03-25 20:09:48 +08:00
parent 64995c25a8
commit 011e2ff37a
2 changed files with 59 additions and 17 deletions

View File

@@ -226,7 +226,7 @@ jobs:
## macOS 安装提示(未知来源) ## macOS 安装提示(未知来源)
- 若打开时提示“来自未知开发者”或“无法验证开发者”,请到「系统设置 -> 隐私与安全性」中允许打开该应用。 - 若打开时提示“来自未知开发者”或“无法验证开发者”,请到「系统设置 -> 隐私与安全性」中允许打开该应用。
- 如果仍被系统拦截,请在终端执行以下命令去除隔离标记: - 如果仍被系统拦截,请在终端执行以下命令去除隔离标记:
- `xattr -dr com.apple.quarantine "/Applications/WeFlow.app"` - xattr -rd com.apple.quarantine /Applications/WeFlow.app
- 执行后重新打开 WeFlow。 - 执行后重新打开 WeFlow。
> 如果某个平台链接暂时未生成,可进入完整发布页查看全部资源:$RELEASE_PAGE > 如果某个平台链接暂时未生成,可进入完整发布页查看全部资源:$RELEASE_PAGE

View File

@@ -146,27 +146,67 @@ const normalizeReleaseNotes = (rawReleaseNotes: unknown): string => {
if (!merged.trim()) return '' if (!merged.trim()) return ''
const shouldStripReleaseSection = (headingRaw: string): boolean => { const normalizeHeadingText = (raw: string): string => {
const heading = headingRaw.trim().toLowerCase() return raw
if (heading === '下载' || heading === 'download') return true .replace(/<[^>]*>/g, ' ')
.replace(/&nbsp;/gi, ' ')
.replace(/&amp;/gi, '&')
.replace(/&lt;/gi, '<')
.replace(/&gt;/gi, '>')
.replace(/&quot;/gi, '"')
.replace(/&#39;/gi, '\'')
.replace(/&#x27;/gi, '\'')
.toLowerCase()
.replace(/[:]/g, '')
.replace(/\s+/g, '')
.trim()
}
const compactHeading = heading.replace(/\s+/g, '') const shouldStripReleaseSection = (headingRaw: string): boolean => {
if (compactHeading.startsWith('macos安装提示')) return true const heading = normalizeHeadingText(headingRaw)
if (compactHeading.startsWith('mac安装提示')) return true if (!heading) return false
if (heading.startsWith('下载') || heading.startsWith('download')) return true
if ((heading.includes('macos') || heading.startsWith('mac')) && heading.includes('安装提示')) return true
return false return false
} }
// 兼容 electron-updater 直接返回 HTML 的场景 // 兼容 electron-updater 直接返回 HTML 的场景(含 dir/anchor 等标签嵌套)
const removeDownloadSectionFromHtml = (input: string): string => { const removeDownloadSectionFromHtml = (input: string): string => {
return input const headingPattern = /<h([1-6])\b[^>]*>([\s\S]*?)<\/h\1>/gi
.replace( const headings: Array<{ start: number; end: number; headingText: string }> = []
/<h[1-6][^>]*>\s*(?:下载|download)\s*<\/h[1-6]>\s*[\s\S]*?(?=<h[1-6]\b|$)/gi, let match: RegExpExecArray | null
''
) while ((match = headingPattern.exec(input)) !== null) {
.replace( const full = match[0]
/<h[1-6][^>]*>\s*(?:mac\s*os|mac)\s*安装提示(?:\s*[(]\s*未知来源\s*[)])?\s*<\/h[1-6]>\s*[\s\S]*?(?=<h[1-6]\b|$)/gi, headings.push({
'' start: match.index,
) end: match.index + full.length,
headingText: match[2] || ''
})
}
if (headings.length === 0) return input
const rangesToRemove: Array<{ start: number; end: number }> = []
for (let i = 0; i < headings.length; i += 1) {
const current = headings[i]
if (!shouldStripReleaseSection(current.headingText)) continue
const nextStart = i + 1 < headings.length ? headings[i + 1].start : input.length
rangesToRemove.push({ start: current.start, end: nextStart })
}
if (rangesToRemove.length === 0) return input
let output = ''
let cursor = 0
for (const range of rangesToRemove) {
output += input.slice(cursor, range.start)
cursor = range.end
}
output += input.slice(cursor)
return output
} }
// 兼容 Markdown 场景Action 最终 release note 模板) // 兼容 Markdown 场景Action 最终 release note 模板)
@@ -195,6 +235,8 @@ const normalizeReleaseNotes = (rawReleaseNotes: unknown): string => {
} }
const cleaned = removeDownloadSectionFromMarkdown(removeDownloadSectionFromHtml(merged)) const cleaned = removeDownloadSectionFromMarkdown(removeDownloadSectionFromHtml(merged))
// 兜底:即使没有匹配到标题,也不在弹窗展示 macOS 隔离标记清理命令
.replace(/^[ \t>*-]*`?\s*xattr\s+-[a-z]*d[a-z]*\s+com\.apple\.quarantine[^\n]*`?\s*$/gim, '')
.replace(/\n{3,}/g, '\n\n') .replace(/\n{3,}/g, '\n\n')
.trim() .trim()