开始写账号系统
This commit is contained in:
parent
8ee2cabf7d
commit
139c985ce2
8
app.js
8
app.js
|
|
@ -4,6 +4,7 @@ var favicon = require('serve-favicon');
|
|||
var logger = require('morgan');
|
||||
var cookieParser = require('cookie-parser');
|
||||
var bodyParser = require('body-parser');
|
||||
var session = require('express-session');
|
||||
|
||||
var routes = require('./routes/index');
|
||||
var users = require('./routes/users');
|
||||
|
|
@ -22,11 +23,14 @@ app.use(bodyParser.json());
|
|||
app.use(bodyParser.urlencoded({
|
||||
extended: false
|
||||
}));
|
||||
app.use(cookieParser());
|
||||
app.use(cookieParser('Wilson'));
|
||||
app.use(session({
|
||||
secret: 'wilson'
|
||||
}));
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
app.use('/api', api);
|
||||
app.use('/', routes);
|
||||
app.use('/api', api);
|
||||
app.use('/users', users);
|
||||
|
||||
// catch 404 and forward to error handler
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
"debug": "~2.2.0",
|
||||
"ejs": "~2.4.1",
|
||||
"express": "~4.13.4",
|
||||
"express-session": "^1.14.1",
|
||||
"morgan": "~1.7.0",
|
||||
"mysql": "^2.11.1",
|
||||
"serve-favicon": "~2.3.0",
|
||||
|
|
|
|||
|
|
@ -1,45 +1,42 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="bookmark">
|
||||
<meta name="author" content="luchenqun">
|
||||
<title>我的书签</title>
|
||||
<link href="/css/externe/semantic.min.css " rel="stylesheet" />
|
||||
<link href="/css/externe/calendar.min.css" rel="stylesheet" />
|
||||
<link href="/css/style.css " rel="stylesheet" />
|
||||
|
||||
<base href="/">
|
||||
</head>
|
||||
|
||||
<body ng-app="bookmarkApp">
|
||||
<div class="ui container ">
|
||||
<!-- directive:菜单 -->
|
||||
<menus></menus>
|
||||
<div class="ui container" style="width:100%;height:20px"></div>
|
||||
<div class="ui container">
|
||||
<div ui-view></div>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="bookmark">
|
||||
<meta name="author" content="luchenqun">
|
||||
<title>我的书签</title>
|
||||
<link href="/css/externe/semantic.min.css " rel="stylesheet"/>
|
||||
<link href="/css/externe/calendar.min.css" rel="stylesheet"/>
|
||||
<link href="/css/style.css " rel="stylesheet"/>
|
||||
<base href="/">
|
||||
</head>
|
||||
<body ng-app="bookmarkApp">
|
||||
<div class="ui container ">
|
||||
<!-- directive:菜单 -->
|
||||
<menus></menus>
|
||||
<div class="ui container" style="width:100%;height:20px"></div>
|
||||
<div class="ui container">
|
||||
<div ui-view></div>
|
||||
</div>
|
||||
<div class="foot"></div>
|
||||
<!-- directive:书签编辑 -->
|
||||
<edit></edit>
|
||||
</div>
|
||||
<div class="foot"></div>
|
||||
<!-- directive:书签编辑 -->
|
||||
<edit></edit>
|
||||
</div>
|
||||
<script src="/scripts/externe/jquery-3.1.1.min.js"></script>
|
||||
<script src="/scripts/externe/angular.min.js"></script>
|
||||
<script src="/scripts/externe/angular-ui-router.min.js"></script>
|
||||
<script src="/scripts/app-angular.js"></script>
|
||||
<script src="/scripts/services/bookmark-service.js"></script>
|
||||
<script src="/scripts/services/pub-sub-service.js"></script>
|
||||
<script src="/scripts/directives/edit-directive.js"></script>
|
||||
<script src="/scripts/directives/menus-directive.js"></script>
|
||||
<script src="/scripts/controllers/bookmarks-controller.js"></script>
|
||||
<script src="/scripts/controllers/tags-controller.js"></script>
|
||||
<script src="/scripts/controllers/menus-controller.js"></script>
|
||||
<script src="/scripts/controllers/edit-controller.js"></script>
|
||||
<script src="/scripts/externe/semantic.min.js"></script>
|
||||
<script src="/scripts/externe/calendar.min.js"></script>
|
||||
</body>
|
||||
|
||||
<script src="/scripts/externe/jquery-3.1.1.min.js"></script>
|
||||
<script src="/scripts/externe/angular.min.js"></script>
|
||||
<script src="/scripts/externe/angular-ui-router.min.js"></script>
|
||||
<script src="/scripts/app-angular.js"></script>
|
||||
<script src="/scripts/services/bookmark-service.js"></script>
|
||||
<script src="/scripts/services/pub-sub-service.js"></script>
|
||||
<script src="/scripts/directives/edit-directive.js"></script>
|
||||
<script src="/scripts/directives/menus-directive.js"></script>
|
||||
<script src="/scripts/controllers/bookmarks-controller.js"></script>
|
||||
<script src="/scripts/controllers/home-controller.js"></script>
|
||||
<script src="/scripts/controllers/tags-controller.js"></script>
|
||||
<script src="/scripts/controllers/menus-controller.js"></script>
|
||||
<script src="/scripts/controllers/edit-controller.js"></script>
|
||||
<script src="/scripts/externe/semantic.min.js"></script>
|
||||
<script src="/scripts/externe/calendar.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ app.config(function($stateProvider, $urlRouterProvider) {
|
|||
bar: null
|
||||
},
|
||||
controller: 'bookmarksCtr'
|
||||
|
||||
})
|
||||
.state('addBookmark', {
|
||||
url: '/addBookmark',
|
||||
|
|
@ -32,16 +31,13 @@ app.config(function($stateProvider, $urlRouterProvider) {
|
|||
url: '/settings',
|
||||
templateUrl: '/views/settings.html',
|
||||
})
|
||||
.state('register', {
|
||||
url: '/register',
|
||||
templateUrl: '/views/register.html'
|
||||
})
|
||||
.state('intro', {
|
||||
url: '/intro',
|
||||
templateUrl: '/views/intro.html'
|
||||
.state('login', {
|
||||
url: '/login',
|
||||
templateUrl: '/views/login.html'
|
||||
})
|
||||
.state('/', {
|
||||
url: '/',
|
||||
templateUrl: '/views/intro.html'
|
||||
templateUrl: '/views/home.html',
|
||||
controller: 'homeCtr'
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
app.controller('homeCtr', ['$scope', '$stateParams', '$filter', '$window', 'bookmarkService', 'pubSubService', function($scope, $stateParams, $filter, $window, bookmarkService, pubSubService) {
|
||||
console.log('Hello homeCtr......');
|
||||
var params = {
|
||||
a: 1111
|
||||
};
|
||||
bookmarkService.autoLogin(params).then(
|
||||
function(data) {
|
||||
console.log(data);
|
||||
},
|
||||
function(errorMsg) {
|
||||
console.log(errorMsg);
|
||||
}
|
||||
);
|
||||
}]);
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
app.controller('menuCtr', ['$scope', '$state', 'pubSubService', function($scope, $state, pubSubService) {
|
||||
$scope.login = true; /**< 是否登陆 */
|
||||
$scope.login = false; /**< 是否登陆 */
|
||||
$scope.selectLoginIndex = 0; /**< 默认登陆之后的选择的菜单索引,下表从 0 开始 */
|
||||
$scope.selectNotLoginIndex = 0; /**< 默认未登陆之后的选择的菜单索引,下表从 0 开始 */
|
||||
$scope.keyword = ''; /**< 搜索关键字 */
|
||||
|
|
@ -8,14 +8,14 @@ app.controller('menuCtr', ['$scope', '$state', 'pubSubService', function($scope,
|
|||
/**
|
||||
* @todo http://stackoverflow.com/questions/31449948/ui-router-state-go-not-working
|
||||
*/
|
||||
if ($scope.login) {
|
||||
setTimeout(() => {
|
||||
$state.go('bookmarks', {
|
||||
foo: 'i love you',
|
||||
bar: 'hello world'
|
||||
})
|
||||
}, 0);
|
||||
}
|
||||
// if ($scope.login) {
|
||||
// setTimeout(() => {
|
||||
// $state.go('bookmarks', {
|
||||
// foo: 'i love you',
|
||||
// bar: 'hello world'
|
||||
// })
|
||||
// }, 0);
|
||||
// }
|
||||
|
||||
// 登陆之后显示的菜单数据。uiSerf:内部跳转链接。
|
||||
$scope.loginMenus = [{
|
||||
|
|
@ -37,11 +37,11 @@ app.controller('menuCtr', ['$scope', '$state', 'pubSubService', function($scope,
|
|||
|
||||
// 未登陆显示的菜单数据
|
||||
$scope.notLoginMenus = [{
|
||||
uiSref: 'intro',
|
||||
title: '说明'
|
||||
uiSref: '/',
|
||||
title: '首页'
|
||||
}, {
|
||||
uiSref: 'register',
|
||||
title: '注册'
|
||||
uiSref: 'login',
|
||||
title: '登陆'
|
||||
}];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,12 +1,26 @@
|
|||
app.factory('bookmarkService', ['$http', '$q', function($http, $q) {
|
||||
// service interface
|
||||
var service = {
|
||||
autoLogin: function(params) {
|
||||
var def = $q.defer();
|
||||
$http.get('/api/autoLogin/', {
|
||||
params: params
|
||||
})
|
||||
.success(function(data) {
|
||||
def.resolve(data);
|
||||
})
|
||||
.error(function(data) {
|
||||
console.log('Error: ' + data);
|
||||
def.reject('Failed to get todos');
|
||||
});
|
||||
return def.promise;
|
||||
},
|
||||
/**
|
||||
* @func
|
||||
* @desc 根据显示页数的索引,获取书签的数据
|
||||
* @param {object} params - 参数
|
||||
*/
|
||||
getBookmarks: function getBookmarks(params) {
|
||||
getBookmarks: function(params) {
|
||||
var def = $q.defer();
|
||||
|
||||
$http.get('/api/bookmarks/', {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
<p>
|
||||
这是登陆界面
|
||||
</p>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<div class="js-menu" ng-controller="menuCtr">
|
||||
<div class="ui menu js-login-in" ng-if="login">
|
||||
<a class="item" ng-class="{active:$index==selectLoginIndex}" ui-sref="{{ menu.uiSref }}" ui-sref-opts="{reload: true}" ng-repeat="menu in loginMenus">
|
||||
<a class="item" ng-class="{active:$index==selectLoginIndex}" ui-sref="{{ menu.uiSref }}" ui-sref-opts="{reload: true}" ng-repeat="menu in loginMenus">
|
||||
<div>{{ menu.title }}</div>
|
||||
<div class="ui floating dropdown icon js-bookmark-dropdown" ng-if="$index==0">
|
||||
<i class="dropdown icon"></i>
|
||||
|
|
@ -44,9 +44,6 @@
|
|||
</div>
|
||||
<div class="results"></div>
|
||||
</div>
|
||||
<!-- <div class="item">
|
||||
<div class="ui button" ng-click="searchDetail()" ui-sref="bookmarks">详情搜索</div>
|
||||
</div> -->
|
||||
<div class="item">
|
||||
<div class="ui button" ng-click="showAddBookmarkMoadl()" ui-sref="bookmarks">添加书签</div>
|
||||
</div>
|
||||
|
|
@ -57,10 +54,5 @@
|
|||
</div>
|
||||
<div class="ui small menu js-not-login-in" ng-if="!login">
|
||||
<a class="item" ng-class="{active:$index==selectNotLoginIndex}" ui-sref="{{ menu.uiSref}}" ng-click="selectMenu($index, login)" ng-repeat="menu in notLoginMenus">{{ menu.title}}</a>
|
||||
<div class="right menu">
|
||||
<div class="item">
|
||||
<div class="ui button">登陆</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
<p> 这是注册界面 </p>
|
||||
|
|
@ -18,6 +18,13 @@ var client = mysql.createConnection({
|
|||
});
|
||||
client.connect();
|
||||
|
||||
api.get('/autoLogin', function(req, res) {
|
||||
console.log('autoLogin......');
|
||||
res.json({
|
||||
data: "autoLogin reply",
|
||||
});
|
||||
});
|
||||
|
||||
api.get('/bookmarks', function(req, res) {
|
||||
console.log('hello bookmarks', JSON.stringify(req.query));
|
||||
if (req.query.show === 'navigate') {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ var router = express.Router();
|
|||
|
||||
/* GET home page. */
|
||||
router.get('/', function(req, res, next) {
|
||||
res.render('index', { title: 'Express' });
|
||||
console.log('Hello , i enter index');
|
||||
// res.render('index', {
|
||||
// title: 'Express'
|
||||
// });
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
Loading…
Reference in New Issue