feat: ship blog platform admin and deploy stack

This commit is contained in:
2026-03-31 21:48:39 +08:00
parent a9a05aa105
commit 313f174fbc
210 changed files with 25476 additions and 5803 deletions

View File

@@ -41,6 +41,76 @@ export function formatCommentScope(value: string | null | undefined) {
}
}
export function formatPostStatus(value: string | null | undefined) {
switch (value) {
case 'draft':
return '草稿'
case 'published':
return '已发布'
case 'scheduled':
return '定时发布'
case 'expired':
return '已下线'
case 'offline':
return '离线'
default:
return value || '已发布'
}
}
export function formatPostVisibility(value: string | null | undefined) {
switch (value) {
case 'unlisted':
return '不公开'
case 'private':
return '私有'
case 'public':
return '公开'
default:
return value || '公开'
}
}
function matchBrowserVersion(userAgent: string, marker: RegExp) {
const matched = userAgent.match(marker)
return matched?.[1] ?? null
}
export function formatBrowserName(userAgent: string | null | undefined) {
if (!userAgent) {
return '未知浏览器'
}
const ua = userAgent.toLowerCase()
if (ua.includes('edg/')) {
const version = matchBrowserVersion(userAgent, /edg\/([\d.]+)/i)
return version ? `Edge ${version}` : 'Edge'
}
if (ua.includes('opr/') || ua.includes('opera')) {
const version = matchBrowserVersion(userAgent, /(?:opr|opera)\/([\d.]+)/i)
return version ? `Opera ${version}` : 'Opera'
}
if (ua.includes('firefox/')) {
const version = matchBrowserVersion(userAgent, /firefox\/([\d.]+)/i)
return version ? `Firefox ${version}` : 'Firefox'
}
if (ua.includes('chrome/') && !ua.includes('chromium/')) {
const version = matchBrowserVersion(userAgent, /chrome\/([\d.]+)/i)
return version ? `Chrome ${version}` : 'Chrome'
}
if (ua.includes('safari/') && !ua.includes('chrome/')) {
const version = matchBrowserVersion(userAgent, /version\/([\d.]+)/i)
return version ? `Safari ${version}` : 'Safari'
}
return '其他浏览器'
}
export function formatFriendLinkStatus(value: string | null | undefined) {
switch (value) {
case 'approved':