feat: Refactor service management scripts to use a unified dev script
- Added package.json to manage development scripts. - Updated restart-services.ps1 to call the new dev script for starting services. - Refactored start-admin.ps1, start-backend.ps1, start-frontend.ps1, and start-mcp.ps1 to utilize the dev script for starting respective services. - Enhanced stop-services.ps1 to improve process termination logic by matching command patterns.
This commit is contained in:
@@ -17,7 +17,7 @@ import {
|
||||
TableRow,
|
||||
} from '@/components/ui/table'
|
||||
import { adminApi, ApiError } from '@/lib/api'
|
||||
import { formatDateTime } from '@/lib/admin-format'
|
||||
import { formatCommentScope, formatDateTime } from '@/lib/admin-format'
|
||||
import type { CommentRecord } from '@/lib/types'
|
||||
|
||||
function moderationBadgeVariant(approved: boolean | null) {
|
||||
@@ -49,13 +49,13 @@ export function CommentsPage() {
|
||||
})
|
||||
|
||||
if (showToast) {
|
||||
toast.success('Comments refreshed.')
|
||||
toast.success('评论列表已刷新。')
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof ApiError && error.status === 401) {
|
||||
return
|
||||
}
|
||||
toast.error(error instanceof ApiError ? error.message : 'Unable to load comments.')
|
||||
toast.error(error instanceof ApiError ? error.message : '无法加载评论列表。')
|
||||
} finally {
|
||||
setLoading(false)
|
||||
setRefreshing(false)
|
||||
@@ -106,59 +106,58 @@ export function CommentsPage() {
|
||||
<div className="space-y-6">
|
||||
<div className="flex flex-col gap-4 xl:flex-row xl:items-end xl:justify-between">
|
||||
<div className="space-y-3">
|
||||
<Badge variant="secondary">Comments</Badge>
|
||||
<Badge variant="secondary">评论</Badge>
|
||||
<div>
|
||||
<h2 className="text-3xl font-semibold tracking-tight">Moderation queue</h2>
|
||||
<h2 className="text-3xl font-semibold tracking-tight">评论审核队列</h2>
|
||||
<p className="mt-2 max-w-3xl text-sm leading-7 text-muted-foreground">
|
||||
Review article comments and paragraph-specific responses from one place, with fast
|
||||
approval controls for the public discussion layer.
|
||||
在一个页面中处理全文评论与段落评论,快速完成公开讨论区的审核工作。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Button variant="secondary" onClick={() => void loadComments(true)} disabled={refreshing}>
|
||||
<RefreshCcw className="h-4 w-4" />
|
||||
{refreshing ? 'Refreshing...' : 'Refresh'}
|
||||
{refreshing ? '刷新中...' : '刷新'}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-4 md:grid-cols-3">
|
||||
<Card className="bg-gradient-to-br from-card via-card to-background/70">
|
||||
<CardContent className="pt-6">
|
||||
<p className="text-xs uppercase tracking-[0.2em] text-muted-foreground">Pending</p>
|
||||
<p className="text-xs uppercase tracking-[0.2em] text-muted-foreground">待审核</p>
|
||||
<div className="mt-3 text-3xl font-semibold">{pendingCount}</div>
|
||||
<p className="mt-2 text-sm text-muted-foreground">Needs moderation attention.</p>
|
||||
<p className="mt-2 text-sm text-muted-foreground">需要人工审核处理。</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card className="bg-gradient-to-br from-card via-card to-background/70">
|
||||
<CardContent className="pt-6">
|
||||
<p className="text-xs uppercase tracking-[0.2em] text-muted-foreground">
|
||||
Paragraph replies
|
||||
段落评论
|
||||
</p>
|
||||
<div className="mt-3 text-3xl font-semibold">{paragraphCount}</div>
|
||||
<p className="mt-2 text-sm text-muted-foreground">Scoped to paragraph anchors.</p>
|
||||
<p className="mt-2 text-sm text-muted-foreground">挂载到具体段落锚点。</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<Card className="bg-gradient-to-br from-card via-card to-background/70">
|
||||
<CardContent className="pt-6">
|
||||
<p className="text-xs uppercase tracking-[0.2em] text-muted-foreground">Total</p>
|
||||
<p className="text-xs uppercase tracking-[0.2em] text-muted-foreground">总数</p>
|
||||
<div className="mt-3 text-3xl font-semibold">{comments.length}</div>
|
||||
<p className="mt-2 text-sm text-muted-foreground">Everything currently stored.</p>
|
||||
<p className="mt-2 text-sm text-muted-foreground">当前系统中全部评论。</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Comment list</CardTitle>
|
||||
<CardTitle>评论列表</CardTitle>
|
||||
<CardDescription>
|
||||
Filter the queue, then approve, hide, or remove entries without leaving the page.
|
||||
先筛选,再直接通过、隐藏或删除评论,无需离开当前页面。
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="grid gap-3 lg:grid-cols-[1.2fr_0.6fr_0.6fr]">
|
||||
<Input
|
||||
placeholder="Search by author, post slug, content, or paragraph key"
|
||||
placeholder="按作者、文章 slug、评论内容或段落键搜索"
|
||||
value={searchTerm}
|
||||
onChange={(event) => setSearchTerm(event.target.value)}
|
||||
/>
|
||||
@@ -166,14 +165,14 @@ export function CommentsPage() {
|
||||
value={approvalFilter}
|
||||
onChange={(event) => setApprovalFilter(event.target.value)}
|
||||
>
|
||||
<option value="all">All approval states</option>
|
||||
<option value="pending">Pending only</option>
|
||||
<option value="approved">Approved only</option>
|
||||
<option value="all">全部状态</option>
|
||||
<option value="pending">仅看待审核</option>
|
||||
<option value="approved">仅看已通过</option>
|
||||
</Select>
|
||||
<Select value={scopeFilter} onChange={(event) => setScopeFilter(event.target.value)}>
|
||||
<option value="all">All scopes</option>
|
||||
<option value="article">Article</option>
|
||||
<option value="paragraph">Paragraph</option>
|
||||
<option value="all">全部范围</option>
|
||||
<option value="article">全文</option>
|
||||
<option value="paragraph">段落</option>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
@@ -183,10 +182,10 @@ export function CommentsPage() {
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Comment</TableHead>
|
||||
<TableHead>Status</TableHead>
|
||||
<TableHead>Context</TableHead>
|
||||
<TableHead>Actions</TableHead>
|
||||
<TableHead>评论内容</TableHead>
|
||||
<TableHead>状态</TableHead>
|
||||
<TableHead>上下文</TableHead>
|
||||
<TableHead>操作</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
@@ -195,20 +194,20 @@ export function CommentsPage() {
|
||||
<TableCell>
|
||||
<div className="space-y-2">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="font-medium">{comment.author ?? 'Anonymous'}</span>
|
||||
<Badge variant="outline">{comment.scope}</Badge>
|
||||
<span className="font-medium">{comment.author ?? '匿名用户'}</span>
|
||||
<Badge variant="outline">{formatCommentScope(comment.scope)}</Badge>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{formatDateTime(comment.created_at)}
|
||||
</span>
|
||||
</div>
|
||||
<p className="text-sm leading-6 text-muted-foreground">
|
||||
{comment.content ?? 'No content provided.'}
|
||||
{comment.content ?? '暂无评论内容。'}
|
||||
</p>
|
||||
{comment.scope === 'paragraph' ? (
|
||||
<div className="rounded-2xl border border-border/70 bg-background/60 px-3 py-2 text-xs text-muted-foreground">
|
||||
<p className="font-mono">{comment.paragraph_key ?? 'missing-key'}</p>
|
||||
<p className="font-mono">{comment.paragraph_key ?? '缺少段落键'}</p>
|
||||
<p className="mt-1">
|
||||
{comment.paragraph_excerpt ?? 'No paragraph excerpt stored.'}
|
||||
{comment.paragraph_excerpt ?? '没有保存段落摘录。'}
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
@@ -216,16 +215,16 @@ export function CommentsPage() {
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Badge variant={moderationBadgeVariant(comment.approved)}>
|
||||
{comment.approved ? 'Approved' : 'Pending'}
|
||||
{comment.approved ? '已通过' : '待审核'}
|
||||
</Badge>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="space-y-1 text-sm text-muted-foreground">
|
||||
<p className="font-mono text-xs">{comment.post_slug ?? 'unknown-post'}</p>
|
||||
<p className="font-mono text-xs">{comment.post_slug ?? '未知文章'}</p>
|
||||
{comment.reply_to_comment_id ? (
|
||||
<p>Replying to #{comment.reply_to_comment_id}</p>
|
||||
<p>回复评论 #{comment.reply_to_comment_id}</p>
|
||||
) : (
|
||||
<p>Top-level comment</p>
|
||||
<p>顶级评论</p>
|
||||
)}
|
||||
</div>
|
||||
</TableCell>
|
||||
@@ -239,13 +238,11 @@ export function CommentsPage() {
|
||||
try {
|
||||
setActingId(comment.id)
|
||||
await adminApi.updateComment(comment.id, { approved: true })
|
||||
toast.success('Comment approved.')
|
||||
toast.success('评论已通过。')
|
||||
await loadComments(false)
|
||||
} catch (error) {
|
||||
toast.error(
|
||||
error instanceof ApiError
|
||||
? error.message
|
||||
: 'Unable to approve comment.',
|
||||
error instanceof ApiError ? error.message : '无法通过该评论。',
|
||||
)
|
||||
} finally {
|
||||
setActingId(null)
|
||||
@@ -253,7 +250,7 @@ export function CommentsPage() {
|
||||
}}
|
||||
>
|
||||
<CheckCheck className="h-4 w-4" />
|
||||
Approve
|
||||
通过
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
@@ -263,13 +260,11 @@ export function CommentsPage() {
|
||||
try {
|
||||
setActingId(comment.id)
|
||||
await adminApi.updateComment(comment.id, { approved: false })
|
||||
toast.success('Comment moved back to pending.')
|
||||
toast.success('评论已移回待审核。')
|
||||
await loadComments(false)
|
||||
} catch (error) {
|
||||
toast.error(
|
||||
error instanceof ApiError
|
||||
? error.message
|
||||
: 'Unable to update comment.',
|
||||
error instanceof ApiError ? error.message : '无法更新评论状态。',
|
||||
)
|
||||
} finally {
|
||||
setActingId(null)
|
||||
@@ -277,27 +272,25 @@ export function CommentsPage() {
|
||||
}}
|
||||
>
|
||||
<XCircle className="h-4 w-4" />
|
||||
Hide
|
||||
隐藏
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="danger"
|
||||
disabled={actingId === comment.id}
|
||||
onClick={async () => {
|
||||
if (!window.confirm('Delete this comment permanently?')) {
|
||||
if (!window.confirm('确定要永久删除这条评论吗?')) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
setActingId(comment.id)
|
||||
await adminApi.deleteComment(comment.id)
|
||||
toast.success('Comment deleted.')
|
||||
toast.success('评论已删除。')
|
||||
await loadComments(false)
|
||||
} catch (error) {
|
||||
toast.error(
|
||||
error instanceof ApiError
|
||||
? error.message
|
||||
: 'Unable to delete comment.',
|
||||
error instanceof ApiError ? error.message : '无法删除评论。',
|
||||
)
|
||||
} finally {
|
||||
setActingId(null)
|
||||
@@ -305,7 +298,7 @@ export function CommentsPage() {
|
||||
}}
|
||||
>
|
||||
<Trash2 className="h-4 w-4" />
|
||||
Delete
|
||||
删除
|
||||
</Button>
|
||||
</div>
|
||||
</TableCell>
|
||||
@@ -316,7 +309,7 @@ export function CommentsPage() {
|
||||
<TableCell colSpan={4} className="py-12 text-center">
|
||||
<div className="flex flex-col items-center gap-3 text-muted-foreground">
|
||||
<MessageSquareText className="h-8 w-8" />
|
||||
<p>No comments match the current moderation filters.</p>
|
||||
<p>当前筛选条件下没有匹配的评论。</p>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
||||
Reference in New Issue
Block a user