将 Markdown 编辑器替换为 TipTap WYSIWYG,新增帖子修订记录与 diff 展示;首页支持最新/回复排序与本地缓存;后台可配置编辑时限与锁定帖子;侧边栏整合板块导航并优化 Feed 布局。 Co-authored-by: Cursor <cursoragent@cursor.com>
4 lines
1.2 KiB
JavaScript
4 lines
1.2 KiB
JavaScript
function o(t){return t.replace(/\r\n/g,`
|
|
`).replace(/\r/g,`
|
|
`).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br>")}function s(t,e){return o(t).replace(/@([\w\u4e00-\u9fa5_-]+)/g,'<span class="mention">@$1</span>')}function c(t){const e=new Date(t);if(Number.isNaN(e.getTime()))return t;const a=new Date,n=(a.getTime()-e.getTime())/1e3;if(n<60)return"刚刚";if(n<3600)return`${Math.floor(n/60)}分钟前`;if(n<86400)return`${Math.floor(n/3600)}小时前`;const g=u=>String(u).padStart(2,"0"),i=`${g(e.getHours())}:${g(e.getMinutes())}`,r=new Date(a);return r.setDate(r.getDate()-1),e.getFullYear()===r.getFullYear()&&e.getMonth()===r.getMonth()&&e.getDate()===r.getDate()?`昨天 ${i}`:e.getFullYear()===a.getFullYear()?`${e.getMonth()+1}月${e.getDate()}日 ${i}`:`${e.getFullYear()}年${e.getMonth()+1}月${e.getDate()}日 ${i}`}function l(t){const e=new Date(t);if(Number.isNaN(e.getTime()))return t;const a=n=>String(n).padStart(2,"0");return`${e.getFullYear()}年${e.getMonth()+1}月${e.getDate()}日 ${a(e.getHours())}:${a(e.getMinutes())}`}function f(t,e){const a=new Date(t).getTime(),n=new Date(e).getTime();return Number.isNaN(a)||Number.isNaN(n)?!1:Math.abs(a-n)>6e4}export{l as a,c as f,s as h,f as i};
|