feat: 增加友链申请、独立页面、投票/悬赏/抽奖帖与侧栏签到,并统一开发数据目录

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-27 06:23:54 +08:00
parent df19752a1e
commit 2208af7070
80 changed files with 9620 additions and 641 deletions

View File

@@ -0,0 +1,38 @@
import type { FriendLinkApply } from '../api/types';
/** 解析友链 LOGO 为可加载的 URL相对路径补全为当前站点 origin */
export function resolveFriendLinkLogo(logo?: string, siteURL?: string): string {
const raw = logo?.trim() || '';
if (!raw) return '';
if (/^https?:\/\//i.test(raw)) return raw;
if (raw.startsWith('/')) {
const base = siteURL?.trim() || (typeof window !== 'undefined' ? window.location.origin : '');
return base ? `${base.replace(/\/$/, '')}${raw}` : raw;
}
return raw;
}
/** 回链检测是否仍在后台进行中 */
export function isReciprocalChecking(apply: FriendLinkApply): boolean {
if (apply.status !== 'pending') return false;
if (apply.reciprocal_checked_at) return false;
if (apply.reciprocal_verified) return false;
if (apply.reciprocal_check_note?.trim()) return false;
return true;
}
export function reciprocalStatusLabel(apply: FriendLinkApply): {
text: string;
variant: 'green' | 'orange' | 'secondary';
} {
if (isReciprocalChecking(apply)) {
return { text: '检测中…', variant: 'secondary' };
}
if (apply.reciprocal_verified) {
return { text: '回链已检测到', variant: 'green' };
}
if (apply.reciprocal_check_note?.trim()) {
return { text: apply.reciprocal_check_note, variant: 'orange' };
}
return { text: '未检测', variant: 'secondary' };
}