mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-26 02:56:22 +00:00
- Update comment API to handle private comments and improve request structure. - Remove unused CSS animations and components related to comments. - Implement new comment input and item components with enhanced functionality including editing and private comment options. - Integrate user profile navigation and improve user experience with better feedback on actions (like, delete, edit). - Update localization for new features and ensure consistency in comment handling. - Introduce checkbox for private comments in the comment input.
27 lines
678 B
TypeScript
27 lines
678 B
TypeScript
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 useToUserProfile() {
|
||
const router = useRouter();
|
||
return (username: string) => {
|
||
router.push(`/u/${username}`);
|
||
};
|
||
}
|
||
|
||
export function clickToPost(postId: number) {
|
||
const router = useRouter()
|
||
return () => {
|
||
router.push(`/p/${postId}`)
|
||
}
|
||
} |