feat: initial commit - oncology literature search platform
OncoLit: a multi-tenant oncology literature search, feed, and collaboration platform. Built with FastAPI + Vue 3 + PostgreSQL. Includes PubMed pipeline, drug approvals, AI summaries, and systematic review tools.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
/** 安全复制到剪贴板,HTTP 下降级到 textarea + execCommand('copy') */
|
||||
export async function copyToClipboard(text: string): Promise<boolean> {
|
||||
if (navigator.clipboard) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text)
|
||||
return true
|
||||
} catch {
|
||||
// fall through to fallback
|
||||
}
|
||||
}
|
||||
const ta = document.createElement('textarea')
|
||||
ta.value = text
|
||||
ta.style.position = 'fixed'
|
||||
ta.style.opacity = '0'
|
||||
document.body.appendChild(ta)
|
||||
ta.select()
|
||||
try {
|
||||
document.execCommand('copy')
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
} finally {
|
||||
document.body.removeChild(ta)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 将 UTC ISO 字符串转换为北京时间(UTC+8)的日期/日期时间字符串
|
||||
*/
|
||||
|
||||
const BJ_OFFSET = 8 * 60 * 60 * 1000 // UTC+8
|
||||
|
||||
function _parse(iso: string | null | undefined): Date | null {
|
||||
if (!iso) return null
|
||||
const d = new Date(iso)
|
||||
return isNaN(d.getTime()) ? null : d
|
||||
}
|
||||
|
||||
/** "2026-07-11" */
|
||||
export function toBeijingDate(iso: string | null | undefined): string {
|
||||
const d = _parse(iso)
|
||||
if (!d) return ''
|
||||
return new Date(d.getTime() + BJ_OFFSET).toISOString().slice(0, 10)
|
||||
}
|
||||
|
||||
/** "2026-07-11 20:30" */
|
||||
export function toBeijingDateTime(iso: string | null | undefined): string {
|
||||
const d = _parse(iso)
|
||||
if (!d) return ''
|
||||
return new Date(d.getTime() + BJ_OFFSET).toISOString().slice(0, 16).replace('T', ' ')
|
||||
}
|
||||
|
||||
/** "2026-07-11 20:30" (别名) */
|
||||
export const formatDateTime = toBeijingDateTime
|
||||
|
||||
/** 相对时间:刚刚 / N 分钟前 / N 小时前 / N 天前 */
|
||||
export function relativeTime(iso: string | null | undefined): string {
|
||||
if (!iso) return ''
|
||||
const diff = Math.floor((Date.now() - new Date(iso).getTime()) / 1000)
|
||||
if (diff < 60) return '刚刚'
|
||||
if (diff < 3600) return `${Math.floor(diff / 60)} 分钟前`
|
||||
if (diff < 86400) return `${Math.floor(diff / 3600)} 小时前`
|
||||
if (diff < 2592000) return `${Math.floor(diff / 86400)} 天前`
|
||||
return iso.slice(0, 10)
|
||||
}
|
||||
Reference in New Issue
Block a user