Next.js 如何将默认登录页更改为登录而不是索引

Next.js 如何将默认登录页更改为登录而不是索引,next.js,Next.js,我对next.js还不太熟悉,基本的问题还没解决 这是我的app.js class MyApp extends App { constructor (props) { super(props) this.persistor = persistStore(props.store) } static async getInitialProps ({ Component, ctx }) { let pageProps = {} if (Component

我对next.js还不太熟悉,基本的问题还没解决

这是我的app.js

class MyApp extends App {
  constructor (props) {
    super(props)
    this.persistor = persistStore(props.store)
  }

  static async getInitialProps ({ Component, ctx }) {
    let pageProps = {}

    if (Component.getInitialProps) {
      pageProps = await Component.getInitialProps({ ctx })
    }

    return { pageProps }
  }

  render () {
    const { Component, pageProps, store } = this.props
    return (
      <Provider store={store}>
        <PersistGate
          loading={null}
          persistor={this.persistor}
        >
          <Component {...pageProps} />
        </PersistGate>
      </Provider>
    )
  }
}

export default withRedux(createStore)(withReduxSaga(MyApp))
类MyApp扩展了应用程序{
建造师(道具){
超级(道具)
this.persistor=persistStore(props.store)
}
静态异步getInitialProps({Component,ctx}){
让pageProps={}
if(Component.getInitialProps){
pageProps=等待组件。getInitialProps({ctx})
}
返回{pageProps}
}
渲染(){
const{Component,pageProps,store}=this.props
返回(
)
}
}
使用Redux导出默认值(createStore)(使用ReduxSaga(MyApp))
这是我的index.js

function Home (props) {

    return (
      <div>
        <div className='home'>
          <Link href='/login'>
              <a>Go to Login</a>
            </Link>

            <h1>THIS IS HOME</h1>

        </div>
}
功能主页(道具){
返回(
转到登录
这是家
}
当前,当我启动一个应用程序时,它会登录到索引页面。 我如何直接在登录页面上登录


如果您需要查看其他文件,请告诉我?

不确定这是否是正确的操作方式,但当网站加载时,我能够在登录页面而不是索引页面上导航用户

  // redirect user to login page
  useEffect(() => {
    Router.push('/login')
  })
  return (
    <div>  
    </div>
  )
//将用户重定向到登录页面
useffect(()=>{
Router.push(“/login”)
})
返回(
)

NextJS将
pages
dir中的每个页面映射到一个路由,因此,您的浏览器在
/
上打开,该路径映射到
index.js。您所说的“登录时登录”是什么意思?您想将
/`映射到login.js页面?是的,根据您的解释,我想映射到/登录。现在它在/页面上打开。我想在加载网站时打开/登录。当用户已经登录时,您需要使用自定义服务器,您希望他们仍然看到登录页面吗?