import { request, cachedRequest } from './api'; /** 资讯中心类别 */ export const CONTENT_CATS = [ { key: 'policy', label: '政策' }, { key: 'news', label: '资讯' }, { key: 'skill', label: '技能' }, { key: 'dynamic', label: '动态' }, ]; /** 获取某类别已发布资讯(公开浏览) */ export async function listContent(type) { const r = await request('GET', `/opc/content?type=${type}`, {}, false); return Array.isArray(r?.items) ? r.items : []; } /** 带短缓存的资讯列表(切换分类时避免跳变) */ export function cachedContent(type) { return cachedRequest('GET', `/opc/content?type=${type}`, 30000, {}, false); } /** 资讯详情 */ export async function getContent(id) { const r = await request('GET', `/opc/content/${id}`, {}, false); return r || null; } /** 资讯留言列表(公开) */ export async function getComments(id) { const r = await request('GET', `/opc/content/${id}/comments`, {}, false); return Array.isArray(r?.items) ? r.items : []; } /** 发表留言(需登录) */ export async function addComment(id, content) { const r = await request('POST', `/opc/content/${id}/comments`, { content }, true); return r?.comment || null; }