mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-23 06:31:51 +00:00
article CRUD with socket
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
import React from 'react'
|
||||
import { createStore } from 'redux'
|
||||
import { Provider } from 'react-redux'
|
||||
import { updateUser, refreshArticles } from './actions'
|
||||
import reducer from './reducer'
|
||||
import { fetchCurrentUser, fetchArticles } from 'boost/api'
|
||||
import { updateUser } from './actions'
|
||||
import { fetchCurrentUser } from 'boost/api'
|
||||
import { Router, Route, IndexRoute } from 'react-router'
|
||||
import MainPage from './MainPage'
|
||||
import LoginPage from './LoginPage'
|
||||
import SignupPage from './SignupPage'
|
||||
import HomePage from './HomePage'
|
||||
import auth from 'boost/auth'
|
||||
import store, { devToolElement } from './store'
|
||||
require('../styles/main/index.styl')
|
||||
|
||||
function onlyUser (state, replaceState) {
|
||||
var currentUser = JSON.parse(localStorage.getItem('currentUser'))
|
||||
let currentUser = auth.user()
|
||||
if (currentUser == null) return replaceState('login', '/login')
|
||||
if (state.location.pathname === '/') return replaceState('user', '/users/' + currentUser.id)
|
||||
}
|
||||
@@ -26,24 +26,6 @@ let routes = (
|
||||
</Route>
|
||||
)
|
||||
|
||||
// with Dev
|
||||
import { compose } from 'redux'
|
||||
// Redux DevTools store enhancers
|
||||
import { devTools, persistState } from 'redux-devtools'
|
||||
// React components for Redux DevTools
|
||||
import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react'
|
||||
|
||||
let finalCreateStore = compose(devTools(), persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/)))(createStore)
|
||||
let store = finalCreateStore(reducer)
|
||||
let devEl = (
|
||||
<DebugPanel top right bottom>
|
||||
<DevTools store={store} monitor={LogMonitor} visibleOnLoad={false}/>
|
||||
</DebugPanel>
|
||||
)
|
||||
|
||||
// On production
|
||||
// let store = createStore(reducer)
|
||||
|
||||
let el = document.getElementById('content')
|
||||
|
||||
React.render((
|
||||
@@ -51,7 +33,7 @@ React.render((
|
||||
<Provider store={store}>
|
||||
{() => <Router>{routes}</Router>}
|
||||
</Provider>
|
||||
{devEl}
|
||||
{devToolElement}
|
||||
</div>
|
||||
), el, function () {
|
||||
let loadingCover = document.getElementById('loadingCover')
|
||||
|
||||
Reference in New Issue
Block a user