Files
neo-blog/web/src/hooks/use-route.ts
Snowykami 3e70d63e70 Refactor comment system:
- 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.
2025-09-09 21:56:41 +08:00

27 lines
678 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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}`)
}
}