feat: 重构评论功能,支持删除和点赞,更新国际化文本,优化组件结构

This commit is contained in:
2025-09-09 20:11:31 +08:00
parent dd7641bf6e
commit ad9dfb0c4c
15 changed files with 504 additions and 85 deletions

View File

@ -0,0 +1,27 @@
import { useRouter, usePathname } from "next/navigation"
/**
* 用于跳转到登录页并自动带上 redirect_back 参数
* 用法const toLogin = useToLogin(); <Button onClick={toLogin}>去登录</Button>
*/
export function useToLogin() {
const router = useRouter()
const pathname = usePathname()
return () => {
router.push(`/login?redirect_back=${encodeURIComponent(pathname)}`)
}
}
export function clickToUserprofile(username: string) {
const router = useRouter()
return () => {
router.push(`/user/${username}`)
}
}
export function clickToPost(postId: number) {
const router = useRouter()
return () => {
router.push(`/p/${postId}`)
}
}