mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-26 19:16:24 +00:00
✨ feat: 添加评论功能,重构评论输入和列表组件,支持多种目标类型,更新国际化文本
All checks were successful
Push to Helm Chart Repository / build (push) Successful in 18s
All checks were successful
Push to Helm Chart Repository / build (push) Successful in 18s
This commit is contained in:
13
web/src/hooks/use-to-login.ts
Normal file
13
web/src/hooks/use-to-login.ts
Normal file
@ -0,0 +1,13 @@
|
||||
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)}`)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user