feat(miniprogram): 禁止小程序发帖,移除发帖页与帖子详情页
- 删除 community-post(发帖/编辑)与 community-post-detail(帖子详情)页面 - app.config.js 移除对应页面注册 - hall 大厅页:社区 tab 移除"+ 发布"入口,帖子不再跳详情,空态文案更新 - utils/hall.js 删除未引用的 communityCreatePost/communityCommentPost
This commit is contained in:
@@ -18,7 +18,7 @@ export default {
|
||||
'my-cert/index', 'compute/index', 'pay/index', 'pay-qr/index',
|
||||
'event-edit/index', 'my-events/index', 'event-bookings/index', 'hall-talents/index', 'hall-talent-detail/index',
|
||||
'hall-jobs/index', 'hall-job-detail/index', 'hall-services/index', 'hall-service-detail/index',
|
||||
'community/index', 'community-post/index', 'community-post-detail/index',
|
||||
'community/index',
|
||||
'hall-task-publish/index', 'hall-service-publish/index', 'hall-job-publish/index',
|
||||
'talent-edit/index'
|
||||
]
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export default { navigationBarTitleText: '详情', navigationStyle: 'custom' };
|
||||
@@ -1,84 +0,0 @@
|
||||
import { View, Text, Input, Button } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { getCurrentInstance } from '@tarojs/taro';
|
||||
import { communityLikePost, communityCommentPost } from '@/utils/hall';
|
||||
import { request } from '@/utils/api';
|
||||
import { isAuthed } from '@/utils/auth';
|
||||
import { PageHeader } from '@/components/TopInset';
|
||||
import Skeleton from '@/components/skeleton';
|
||||
import './index.scss';
|
||||
|
||||
/* 帖子详情:正文 + 评论列表 + 发评论 */
|
||||
export default function CommunityPostDetail() {
|
||||
const id = (getCurrentInstance().router || {}).params?.id;
|
||||
const [data, setData] = useState(null);
|
||||
const [content, setContent] = useState('');
|
||||
const [busy, setBusy] = useState(false);
|
||||
const load = useCallback(() => {
|
||||
request('GET', `/community/posts/${encodeURIComponent(id)}`).then(setData).catch(() => {});
|
||||
}, [id]);
|
||||
useEffect(load, [load]);
|
||||
|
||||
if (!data) return <View className="cpd page-in"><PageHeader back no="COMM" title="帖子" sub="社区帖子详情"/><Skeleton /></View>;
|
||||
const { post, comments } = data;
|
||||
const like = async () => {
|
||||
if (!isAuthed()) { Taro.showToast({ title: '请先登录', icon: 'none' }); return; }
|
||||
try {
|
||||
const r = await communityLikePost(post.id);
|
||||
setData((d) => ({ ...d, post: { ...d.post, likeCount: Math.max(0, (d.post.likeCount || 0) + (r.liked ? 1 : -1)) } }));
|
||||
} catch { /* 忽略 */ }
|
||||
};
|
||||
const comment = async () => {
|
||||
if (!isAuthed()) { Taro.showToast({ title: '请先登录', icon: 'none' }); return; }
|
||||
if (!content.trim()) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
await communityCommentPost(post.id, { content });
|
||||
setContent('');
|
||||
load();
|
||||
} catch (e) { Taro.showToast({ title: (e && e.message) || '评论失败', icon: 'none' }); }
|
||||
finally { setBusy(false); }
|
||||
};
|
||||
return (
|
||||
<View className="cpd page-in">
|
||||
<PageHeader back no="COMM" title={post.topic || '帖子'} sub="社区帖子详情"/>
|
||||
|
||||
{/* 帖子正文卡片 */}
|
||||
<View className="cpd-post">
|
||||
<View className="cpd-post-head">
|
||||
<View className="cpd-avatar"><Text>{(post.authorName || '·').slice(0, 1)}</Text></View>
|
||||
<View>
|
||||
<Text className="cpd-author">{post.authorName}</Text>
|
||||
<View className="cpd-meta">{post.topic}{post.pinned ? ' · 置顶' : ''} · {(post.createdAt || '').slice(0, 10)}</View>
|
||||
</View>
|
||||
</View>
|
||||
<Text className="cpd-title">{post.title}</Text>
|
||||
<Text className="cpd-content">{post.content}</Text>
|
||||
<View className="cpd-foot">
|
||||
<View className="cpd-foot-item" onClick={like}><Text>赞 {post.likeCount || 0}</Text></View>
|
||||
<View className="cpd-foot-item"><Text>评论 {post.commentCount || 0}</Text></View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
{/* 评论区 */}
|
||||
<Text className="cpd-sec">评论({(comments || []).length})</Text>
|
||||
{(comments || []).length === 0 && <Text className="cpd-empty">还没有评论</Text>}
|
||||
{(comments || []).map((c) => (
|
||||
<View key={c.id} className="cpd-comment">
|
||||
<View className="cpd-comment-head">
|
||||
<Text className="cpd-comment-author">{c.authorName}</Text>
|
||||
<Text className="cpd-comment-time">{(c.createdAt || '').slice(0, 10)}</Text>
|
||||
</View>
|
||||
<Text className="cpd-comment-content">{c.content}</Text>
|
||||
</View>
|
||||
))}
|
||||
|
||||
{/* 评论输入 */}
|
||||
<View className="cpd-input-row">
|
||||
<Input className="cpd-input" placeholder="写下你的评论…" value={content} onInput={(e) => setContent(e.detail.value)} />
|
||||
<Button className="cpd-send" loading={busy} onClick={comment}>发送</Button>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/* 社区帖子详情 · 参考任务详情 Soft UI 风格 */
|
||||
.cpd { position: relative; z-index: 2; padding: 32rpx 24rpx 60rpx; min-height: 100vh;
|
||||
background: linear-gradient(165deg, #edf2ff 0%, #f6eefc 34%, #ecf7f6 68%, #eaf4ff 100%); }
|
||||
.cpd-empty { display: block; padding: 120rpx 0; text-align: center; color: #9aa4c6; font-size: 26rpx; }
|
||||
|
||||
/* 帖子正文卡片 */
|
||||
.cpd-post { background: rgba(255,255,255,.82); border: 1rpx solid rgba(99,132,255,.12); border-radius: 22rpx; padding: 24rpx; margin-bottom: 16rpx; box-shadow: 0 8rpx 24rpx rgba(59,79,125,.08); }
|
||||
.cpd-post-head { display: flex; align-items: center; gap: 16rpx; }
|
||||
.cpd-avatar { width: 72rpx; height: 72rpx; border-radius: 50%; background: linear-gradient(135deg, #4d7cfe, #7a5ff0);
|
||||
color: #fff; display: flex; align-items: center; justify-content: center; font-size: 30rpx; font-weight: 700; flex: none; }
|
||||
.cpd-author { font-size: 27rpx; font-weight: 600; color: #2b3a66; }
|
||||
.cpd-meta { font-size: 22rpx; color: #8a94c0; margin-top: 2rpx; }
|
||||
.cpd-title { display: block; margin-top: 16rpx; font-size: 34rpx; font-weight: 800; color: #2b3a66; line-height: 1.35; }
|
||||
.cpd-content { display: block; margin-top: 12rpx; font-size: 27rpx; color: #4a5580; line-height: 1.75; white-space: pre-wrap; }
|
||||
.cpd-foot { display: flex; gap: 36rpx; margin-top: 18rpx; font-size: 24rpx; color: #8a94c0; }
|
||||
.cpd-foot-item { display: flex; align-items: center; gap: 6rpx; }
|
||||
|
||||
/* 评论区 */
|
||||
.cpd-sec { display: block; font-size: 28rpx; font-weight: 700; color: #2b3a66; margin: 8rpx 4rpx 14rpx; }
|
||||
.cpd-comment { background: rgba(255,255,255,.6); border: 1rpx solid rgba(99,132,255,.08); border-radius: 18rpx; padding: 20rpx 22rpx; margin-bottom: 12rpx; }
|
||||
.cpd-comment-head { display: flex; align-items: center; gap: 12rpx; }
|
||||
.cpd-comment-author { font-size: 25rpx; font-weight: 600; color: #2b3a66; }
|
||||
.cpd-comment-time { font-size: 22rpx; color: #8a94c0; }
|
||||
.cpd-comment-content { display: block; margin-top: 8rpx; font-size: 25rpx; color: #4a5580; line-height: 1.65; }
|
||||
|
||||
/* 评论输入区 */
|
||||
.cpd-input-row { display: flex; gap: 14rpx; margin-top: 16rpx; }
|
||||
.cpd-input { flex: 1; min-width: 0; height: 72rpx; line-height: 72rpx; padding: 0 22rpx;
|
||||
border-radius: 16rpx; background: rgba(255,255,255,.8); font-size: 25rpx; border: 1rpx solid rgba(99,132,255,.12); }
|
||||
.cpd-send { flex: none; width: 140rpx; height: 72rpx; line-height: 72rpx; border-radius: 999rpx;
|
||||
background: linear-gradient(135deg, #4d7cfe, #7a5ff0); color: #fff; font-size: 25rpx; font-weight: 600; padding: 0; border: none; }
|
||||
.cpd-send::after { border: none; }
|
||||
@@ -1 +0,0 @@
|
||||
export default { navigationStyle: 'custom' };
|
||||
@@ -1,43 +0,0 @@
|
||||
import { View, Text, Input, Textarea, Button } from '@tarojs/components';
|
||||
import Taro from '@tarojs/taro';
|
||||
import { useState } from 'react';
|
||||
import { communityCreatePost } from '@/utils/hall';
|
||||
import { isAuthed } from '@/utils/auth';
|
||||
import { PageHeader } from '@/components/TopInset';
|
||||
import '@/styles/hall.scss';
|
||||
|
||||
const TOPICS = ['交流', '求助', '资源', '经验', '公告'];
|
||||
|
||||
export default function CommunityPost() {
|
||||
const [f, setF] = useState({ topic: '交流', title: '', content: '' });
|
||||
const [msg, setMsg] = useState('');
|
||||
const [busy, setBusy] = useState(false);
|
||||
const submit = async () => {
|
||||
if (!isAuthed()) { Taro.showToast({ title: '请先登录', icon: 'none' }); return; }
|
||||
setBusy(true); setMsg('');
|
||||
try {
|
||||
await communityCreatePost(f);
|
||||
Taro.showToast({ title: '发布成功', icon: 'success' });
|
||||
setTimeout(() => Taro.navigateBack(), 800);
|
||||
} catch (e) { setMsg((e && e.message) || '发布失败'); }
|
||||
finally { setBusy(false); }
|
||||
};
|
||||
return (
|
||||
<View className="hl-pad page-in">
|
||||
<PageHeader back no="COMM" title="发帖" sub="分享你的想法" />
|
||||
<View className="hl-detail">
|
||||
<View className="hl-chips" style={{ padding: 0 }}>
|
||||
{TOPICS.map((t) => (
|
||||
<Text key={t} className={`hl-chip${f.topic === t ? ' on' : ''}`} onClick={() => setF((s) => ({ ...s, topic: t }))}>{t}</Text>
|
||||
))}
|
||||
</View>
|
||||
<Input className="hl-input" placeholder="标题" value={f.title} onInput={(e) => setF((s) => ({ ...s, title: e.detail.value }))} />
|
||||
<Textarea className="hl-textarea" style={{ minHeight: 240 }} placeholder="正文…" value={f.content} onInput={(e) => setF((s) => ({ ...s, content: e.detail.value }))} />
|
||||
{msg && <Text className="hl-err">{msg}</Text>}
|
||||
<View className="hl-actions">
|
||||
<Button className="hl-btn" loading={busy} onClick={submit}>发布</Button>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
@import '@/styles/hall.scss';
|
||||
@@ -41,7 +41,6 @@ const salary = (a, b) => (!a && !b ? '面议' : a && b && a !== b ? `${a}–${b}
|
||||
const PUBLISH_URL = {
|
||||
tasks: '/pages-extra/hall-task-publish/index',
|
||||
services: '/pages-extra/hall-service-publish/index',
|
||||
community: '/pages-extra/community-post/index',
|
||||
};
|
||||
|
||||
export default function Hall() {
|
||||
@@ -264,9 +263,9 @@ function CommunityPane({ topic, onTopic }) {
|
||||
return (
|
||||
<>
|
||||
{!posts && <Skeleton />}
|
||||
{posts && posts.length === 0 && <Text className="hl-empty">还没有帖子,来发第一帖</Text>}
|
||||
{posts && posts.length === 0 && <Text className="hl-empty">暂无社区内容</Text>}
|
||||
{(posts || []).map((p) => (
|
||||
<View key={p.id} className="hl-post" onClick={() => Taro.navigateTo({ url: `/pages-extra/community-post-detail/index?id=${p.id}` })}>
|
||||
<View key={p.id} className="hl-post">
|
||||
<View className="hl-post-head">
|
||||
<View className="hl-avatar" style={{ width: 64, height: 64, fontSize: 26 }}><Text>{(p.authorName || '·').slice(0, 1)}</Text></View>
|
||||
<View>
|
||||
|
||||
@@ -59,6 +59,4 @@ export const communityPosts = (params = {}) => {
|
||||
const qs = Object.entries(params).filter(([, v]) => v).map(([k, v]) => `${k}=${encodeURIComponent(v)}`).join('&');
|
||||
return cachedRequest('GET', `/community/posts${qs ? `?${qs}` : ''}`, 15000);
|
||||
};
|
||||
export const communityCreatePost = (body) => request('POST', '/community/posts', body, true);
|
||||
export const communityLikePost = (id) => request('POST', `/community/posts/${encodeURIComponent(id)}/like`, {}, true);
|
||||
export const communityCommentPost = (id, body) => request('POST', `/community/posts/${encodeURIComponent(id)}/comments`, body, true);
|
||||
|
||||
Reference in New Issue
Block a user