admin-on-rest自定义路由重定向到信息中心

时间:2017-10-22 12:11:48

标签: admin-on-rest

我正在尝试向AOR添加自定义路线,充当电子邮件链接的目标网页。当我导航到http://localhost:3000/random_page AOR时,将网址更改为http://localhost:3000/random_page#/并呈现信息中心组件而不是我的RandomPage。我可能在这里遗漏了一些简单的东西,但这是一个准系统自定义路由示例。谁能看到我做错了什么?

import React from 'react'
import { Route } from 'react-router-dom'
import RandomPage from './RandomPage'

export default [
    <Route exact path="/random_page" component={RandomPage} noLayout/>,
]

import React, { Component } from 'react';
import './App.css';
import { jsonServerRestClient, fetchUtils, Admin, Resource, Delete } from 'admin-on-rest';
import { LogList } from './components/LogList';
import { UserLogs } from './components/UserLogs';
import Dashboard from './components/Dashboard'
import authClient from './authClient'
import customRoutes from './customRoutes'

const httpClient = (url, options = {}) => {
    if (!options.headers) {
        options.headers = new Headers({ Accept: 'application/json' });
    }
    options.headers.set('X-AUTH-TOKEN', localStorage.getItem('token'));
    return fetchUtils.fetchJson(url, options);
}

class App extends Component {
  render() {
    return (
      <Admin
        authClient={authClient}
        title = "Logs"
        restClient={jsonServerRestClient('http://localhost:3001/admin', httpClient)} 
        customRoutes={customRoutes}
        dashboard={Dashboard}
        >
        <Resource name="users" list={UserList} show={UserLogs}/>
        <Resource name="logs" list={LogList} remove={Delete} />
      </Admin>
    );
  }
}

export default App;

1 个答案:

答案 0 :(得分:0)

我相信您正在寻找文档中<Admin>组件下的enter image description here。然后,您可以从URL中解析出所需的信息并进行相应处理。