Skip to content

Commit

Permalink
Merge pull request #11 from fireyy/demo
Browse files Browse the repository at this point in the history
feat: #10 add demo page
  • Loading branch information
fireyy committed Feb 28, 2017
2 parents e04be00 + 39a0ded commit 305a292
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 5 deletions.
14 changes: 11 additions & 3 deletions README.md
@@ -1,5 +1,13 @@
## React Ant.Design Admin UI

<p align="center">
<a href="https://react-antd-admin-tdvuydxaou.now.sh" target="_blank">
<img src="demo.png" width="700px">
<br>
Live Demo
</a>
</p>

## Features

- [React](https://facebook.github.io/react/)
Expand All @@ -18,7 +26,7 @@ Just clone the repo and install the necessary node modules:
$ git clone https://github.com/fireyy/react-antd-admin
$ cd react-antd-admin
$ npm install
$ npm start
$ npm run dev
```

## Run test spec
Expand All @@ -33,10 +41,10 @@ $ npm run test
$ npm run build
```

## Run demo
## Run Production

```shell
$ npm run demo
$ npm run start
```

## Changelog
Expand Down
Binary file added demo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
121 changes: 121 additions & 0 deletions index.js
@@ -0,0 +1,121 @@
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');

var app = express();

app.get('/', function(req, res) {
res.sendFile(path.resolve(__dirname, 'dist', 'index.html'))
})

// static
app.use(express.static(publicPath));

// RESTful API
app.use(bodyParser.json({ type: 'application/json' }))

var port = process.env.PORT || 80;

app.put('/api/login', function(req, res) {
var credentials = req.body;
if(credentials.user==='admin' && credentials.password==='123456'){
res.cookie('uid', '1', {domain:'127.0.0.1'});
res.json({'user': credentials.user, 'role': 'ADMIN', 'uid': 1});
}else{
res.status('500').send({'message' : 'Invalid user/password'});
}
});

app.post('/api/menu', function(req, res) {
res.json({
menus: [
{
key: 1,
name: 'Dashboard',
icon: 'user',
child: [
{
name: '选项1',
key: 101,
url: '/home'
},
{
name: '选项2',
key: 102,
url: '/page2'
},
{
name: '选项3',
key: 103
},
{
name: '选项4',
key: 104
}
]
},
{
key: 2,
name: '导航二',
icon: 'laptop',
child: [
{
name: '选项5',
key: 201
},
{
name: '选项2',
key: 202
},
{
name: '选项3',
key: 203
},
{
name: '选项4',
key: 204
}
]
},
{
key: 3,
name: '导航三',
icon: 'notification',
child: [
{
name: '选项1',
key: 301
},
{
name: '选项2',
key: 302
},
{
name: '选项3',
key: 303
},
{
name: '选项4',
key: 304
}
]
}
]
});
});

app.post('/api/my', function(req, res) {
res.json({'user': 'admin', 'role': 'ADMIN', 'uid': 1});
});

app.post('/api/logout', function(req, res) {
res.clearCookie('uid');
res.json({'user': 'admin', 'role': 'ADMIN'});
});

app.listen(port, function (err, result) {
if(err){
console.log(err);
}
console.log('Server running on http://localhost:' + port);
});
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -6,8 +6,8 @@
"scripts": {
"test": "mocha tests/.setup.js tests/**/*-test.js --compilers css:mocha-compiler.js",
"build": "webpack --config webpack.prod.config.js",
"demo": "NODE_ENV=production PORT=5500 node server",
"start": "node server"
"dev": "node devServer",
"start": "NODE_ENV=production PORT=80 node ."
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 305a292

Please sign in to comment.