mirror of
https://github.com/wu736139669/vczero.github.io.git
synced 2026-11-08 02:32:02 +00:00
add ug grunt
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
module.exports = function(grunt){
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
concat:{
|
||||
options:{
|
||||
separator: ';'
|
||||
},
|
||||
dist:{
|
||||
src:[
|
||||
'./lib/main.js',
|
||||
'./lib/directive/**/*.js',
|
||||
'./lib/service/**/*.js',
|
||||
'./lib/list/**/*.js'
|
||||
],
|
||||
dest:'./build/main.js'
|
||||
}
|
||||
},
|
||||
uglify: {
|
||||
options: {
|
||||
//头部
|
||||
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
|
||||
},
|
||||
dist: {
|
||||
src: './build/main.js',
|
||||
dest: './build/main.min.js'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||
grunt.loadNpmTasks('grunt-contrib-concat');
|
||||
|
||||
grunt.registerTask('default', ['concat', 'uglify']);
|
||||
};
|
||||
@@ -1,5 +1,7 @@
|
||||
爱搜索 爱生活
|
||||
======
|
||||
网址:[点击](http://vczero.github.io/t/html/index.html#/)
|
||||
|
||||
+ 图书
|
||||
+ 音乐
|
||||
+ 电影
|
||||
|
||||
+294
@@ -0,0 +1,294 @@
|
||||
var app = angular.module('app', ['ui.router']);
|
||||
|
||||
/*$rootScope的相关配置*/
|
||||
app.run(['$rootScope', function($rootScope){
|
||||
$rootScope.version = '0.1';
|
||||
$rootScope.author = 'vczero';
|
||||
$rootScope.author_alias = '鬼谣';
|
||||
$rootScope.isNoLoaded = true;
|
||||
$rootScope.bookList = []; //当然这是个不好的做法,只因为APP太simple
|
||||
$rootScope.musicList = [];
|
||||
$rootScope.movieList = [];
|
||||
$rootScope.keywordsObj = {
|
||||
book: '',
|
||||
music: '',
|
||||
movie: ''
|
||||
};
|
||||
}]);
|
||||
|
||||
/*服务的URL配置*/
|
||||
app.constant('ServiceConfig', {
|
||||
book_search: 'https://api.douban.com/v2/book/search',
|
||||
book_search_id: 'https://api.douban.com/v2/book/',
|
||||
|
||||
music_search: 'https://api.douban.com/v2/music/search',
|
||||
music_search_id: 'https://api.douban.com/v2/music/',
|
||||
|
||||
movie_search: 'https://api.douban.com/v2/movie/search',
|
||||
movie_search_id: 'https://api.douban.com/v2/movie/subject/'
|
||||
});
|
||||
|
||||
app.config(['$stateProvider', '$urlRouterProvider',function($stateProvider, $urlRouterProvider){
|
||||
/*URL路由*/
|
||||
$urlRouterProvider.otherwise("/");
|
||||
|
||||
/*状态配置*/
|
||||
$stateProvider
|
||||
//首页
|
||||
.state('index',{
|
||||
url: '/',
|
||||
views:{
|
||||
header:{
|
||||
templateUrl: '../html/views/list_header.html',
|
||||
controller: 'SearchController'
|
||||
},
|
||||
container:{
|
||||
templateUrl: '../html/views/list_book.html',
|
||||
controller: 'BookListController'
|
||||
},
|
||||
footer:{
|
||||
templateUrl: '../html/views/list_footer.html',
|
||||
controller: ''
|
||||
}
|
||||
}
|
||||
})
|
||||
//book list
|
||||
.state('book_list',{
|
||||
url: '/book',
|
||||
views:{
|
||||
header:{
|
||||
templateUrl: '../html/views/list_header.html',
|
||||
controller: 'SearchController'
|
||||
},
|
||||
container:{
|
||||
templateUrl: '../html/views/list_book.html',
|
||||
controller: 'BookListController'
|
||||
},
|
||||
footer:{
|
||||
templateUrl: '../html/views/list_footer.html',
|
||||
controller: ''
|
||||
}
|
||||
}
|
||||
})
|
||||
// book detail
|
||||
.state('book_detail',{
|
||||
url: '/book/:id',
|
||||
views:{
|
||||
header:{
|
||||
templateUrl: '../html/views/list_header.html',
|
||||
controller: 'SearchController'
|
||||
},
|
||||
container:{
|
||||
templateUrl: '../html/views/detail_book.html',
|
||||
controller: 'BookDetailController'
|
||||
},
|
||||
footer:{
|
||||
templateUrl: '../html/views/list_footer.html',
|
||||
controller: ''
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// music list
|
||||
.state('music_lsit',{
|
||||
url: '/music',
|
||||
views:{
|
||||
header:{
|
||||
templateUrl: '../html/views/list_header.html',
|
||||
controller: 'SearchController'
|
||||
},
|
||||
container:{
|
||||
templateUrl: '../html/views/list_music.html',
|
||||
controller: 'musicListController'
|
||||
},
|
||||
footer:{
|
||||
templateUrl: '../html/views/list_footer.html',
|
||||
controller: ''
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// movie list
|
||||
.state('movie_lsit',{
|
||||
url: '/movie',
|
||||
views:{
|
||||
header:{
|
||||
templateUrl: '../html/views/list_header.html',
|
||||
controller: 'SearchController'
|
||||
},
|
||||
container:{
|
||||
templateUrl: '../html/views/list_movie.html',
|
||||
controller: 'movieListController'
|
||||
},
|
||||
footer:{
|
||||
templateUrl: '../html/views/list_footer.html',
|
||||
controller: ''
|
||||
}
|
||||
}
|
||||
});
|
||||
}]);
|
||||
;
|
||||
|
||||
app.directive('loading', function(){
|
||||
|
||||
var str = '<div id="loading" ng-show="isNoLoaded"><img src="../imgs/loading.gif" /></div>';
|
||||
return {
|
||||
restrict: 'AE',
|
||||
template: str,
|
||||
replace: true
|
||||
};
|
||||
|
||||
});
|
||||
;
|
||||
app.directive('tip', function(){
|
||||
var str = '<div id="loading" ng-show="isNoLoaded"><img src="../imgs/loading.gif" /></div>';
|
||||
return {
|
||||
restrict: 'AE',
|
||||
template: str,
|
||||
replace: true
|
||||
};
|
||||
|
||||
});
|
||||
;/*构建BookList服务*/
|
||||
app.factory('bookList', ['$rootScope', '$http', 'ServiceConfig', function($rootScope, $http, ServiceConfig){
|
||||
$rootScope.isNoLoaded = true;
|
||||
var _BookList = {
|
||||
getData: function(keywords){
|
||||
$rootScope.isNoLoaded = true;
|
||||
$http.jsonp(ServiceConfig.book_search + '?callback=searchBookList&count=10&q=' + keywords);
|
||||
window.searchBookList = function(data){
|
||||
if(data.books.length){
|
||||
$rootScope.isNoLoaded = false;
|
||||
}
|
||||
var list = [];
|
||||
for(var i = 0; i < data.books.length; i++){
|
||||
var book = data.books[i];
|
||||
var item = {
|
||||
id: book.id,
|
||||
image: book.image,
|
||||
origin_title: book.title || '书名未共享',
|
||||
author: book.author[0] || '作者未知',
|
||||
publisher: book.publisher || '出版社未知',
|
||||
price: book.price.split('.')[0] || '未知',
|
||||
pages: book.pages
|
||||
};
|
||||
list.push(item);
|
||||
}
|
||||
$rootScope.bookList = list;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
return _BookList;
|
||||
}]);;/*构建movieList服务*/
|
||||
app.factory('movieList', ['$rootScope', '$http', 'ServiceConfig', function($rootScope, $http, ServiceConfig){
|
||||
$rootScope.isNoLoaded = true;
|
||||
var _MovieList = {
|
||||
getData: function(keywords){
|
||||
$rootScope.isNoLoaded = true;
|
||||
$http.jsonp(ServiceConfig.movie_search + '?callback=movieSearch&count=5&q=' + keywords);
|
||||
|
||||
window.movieSearch = function(data){
|
||||
$rootScope.isNoLoaded = false;
|
||||
if(data.subjects && data.subjects.length){
|
||||
$rootScope.movieList = data.subjects;
|
||||
}
|
||||
console.log(data.subjects);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
return _MovieList;
|
||||
}]);;/*构建musicList服务*/
|
||||
app.factory('musicList', ['$rootScope', '$http', 'ServiceConfig', function($rootScope, $http, ServiceConfig){
|
||||
$rootScope.isNoLoaded = true;
|
||||
var _MusicList = {
|
||||
getData: function(keywords){
|
||||
$rootScope.isNoLoaded = true;
|
||||
$http.jsonp(ServiceConfig.music_search + '?callback=musicSearch&count=10&q=' + keywords);
|
||||
|
||||
window.musicSearch = function(data){
|
||||
$rootScope.isNoLoaded = false;
|
||||
if(data.musics && data.musics.length){
|
||||
$rootScope.musicList = data.musics;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
return _MusicList;
|
||||
}]);;/*初始化图书列表页*/
|
||||
app.controller('BookListController', ['$rootScope', 'bookList',function($rootScope, bookList){
|
||||
if(!$rootScope.keywordsObj.book){
|
||||
$rootScope.keywordsObj.book = 'C语言';
|
||||
}
|
||||
bookList.getData($rootScope.keywordsObj.book);
|
||||
}]);
|
||||
|
||||
|
||||
/*图书详情页*/
|
||||
app.controller('BookDetailController', ['$rootScope', '$http', '$scope', '$location', 'ServiceConfig',function($rootScope, $http, $scope, $location, ServiceConfig){
|
||||
var bookId = $location.path().split('/book/')[1] || '';
|
||||
$rootScope.isNoLoaded = true;
|
||||
$http.jsonp(ServiceConfig.book_search_id + '' + bookId + '?callback=showBookDeatil');
|
||||
window.showBookDeatil = function(data){
|
||||
$rootScope.isNoLoaded = false;
|
||||
$scope.data = data;
|
||||
};
|
||||
}]);;app.controller('MenuController', ['$scope', '$location',function($scope, $location){
|
||||
$scope.bookSearch = function(){
|
||||
$location.path('/book');
|
||||
};
|
||||
|
||||
$scope.musicSearch = function(){
|
||||
$location.path('/music');
|
||||
};
|
||||
|
||||
$scope.movieSearch = function(){
|
||||
$location.path('/movie');
|
||||
};
|
||||
|
||||
}]);;/*初始化的结果*/
|
||||
app.controller('movieListController', ['$rootScope', 'movieList',function($rootScope, movieList){
|
||||
if(!$rootScope.keywordsObj.movie){
|
||||
$rootScope.keywordsObj.movie = '幸福';
|
||||
}
|
||||
movieList.getData($rootScope.keywordsObj.movie);
|
||||
}]);;
|
||||
/*初始化的结果*/
|
||||
app.controller('musicListController', ['$rootScope', 'musicList',function($rootScope, musicList){
|
||||
|
||||
if(!$rootScope.keywordsObj.music){
|
||||
$rootScope.keywordsObj.music = '刘德华';
|
||||
}
|
||||
musicList.getData($rootScope.keywordsObj.music);
|
||||
}]);
|
||||
;/*搜索*/
|
||||
var SearchController = function($scope, $rootScope, $location, bookList, musicList, movieList){
|
||||
var path = $location.path();
|
||||
$scope.search = function(){
|
||||
var keywords = $scope.keywords;
|
||||
if(path.indexOf('/book') !== -1 || path === '/'){
|
||||
if(keywords){
|
||||
$rootScope.keywordsObj.book = keywords;
|
||||
}
|
||||
bookList.getData($rootScope.keywordsObj.book);
|
||||
|
||||
}else if(path.indexOf('/music') !== -1 || path === '/music'){
|
||||
if(keywords){
|
||||
$rootScope.keywordsObj.music = keywords;
|
||||
}
|
||||
musicList.getData($rootScope.keywordsObj.music);
|
||||
|
||||
}else if(path.indexOf('/movie') !== -1 || path === '/movie'){
|
||||
if(keywords){
|
||||
$rootScope.keywordsObj.movie = keywords;
|
||||
}
|
||||
movieList.getData($rootScope.keywordsObj.movie);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
SearchController.$inject = ['$scope', '$rootScope', '$location', 'bookList', 'musicList', 'movieList'];
|
||||
|
||||
app.controller('SearchController', SearchController);
|
||||
Vendored
+2
File diff suppressed because one or more lines are too long
+1
-1
@@ -189,7 +189,7 @@ section .list_item:last-child{
|
||||
}
|
||||
|
||||
#loading{
|
||||
position:absolute;top:170px;left:110px;z-index:2;
|
||||
position:absolute;top:170px;left:150px;z-index:2;
|
||||
}
|
||||
/* book detail*/
|
||||
#book_detail_info{
|
||||
|
||||
+2
-15
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
|
||||
<title>i so</title>
|
||||
<title>i搜索 i生活</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/main.css">
|
||||
</head>
|
||||
<body>
|
||||
@@ -14,19 +14,6 @@
|
||||
|
||||
<script type="text/javascript" src="../js/angular.min.js"></script>
|
||||
<script type="text/javascript" src="../js/angular-ui-router.js"></script>
|
||||
<script type="text/javascript" src="../lib/main.js"></script>
|
||||
<!--service-->
|
||||
<script type="text/javascript" src="../lib/service/bookList.js"></script>
|
||||
<script type="text/javascript" src="../lib/service/musicList.js"></script>
|
||||
<script type="text/javascript" src="../lib/service/movieList.js"></script>
|
||||
<!--directive-->
|
||||
<script type="text/javascript" src="../lib/directive/loading.js"></script>
|
||||
<!--header-->
|
||||
<script type="text/javascript" src="../lib/list/searchController.js"></script>
|
||||
<script type="text/javascript" src="../lib/list/menuController.js"></script>
|
||||
<!--list-->
|
||||
<script type="text/javascript" src="../lib/list/bookController.js"></script>
|
||||
<script type="text/javascript" src="../lib/list/musicController.js"></script>
|
||||
<script type="text/javascript" src="../lib/list/movieController.js"></script>
|
||||
<script type="text/javascript" src="../build/main.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 1.7 KiB |
Vendored
+1
-4226
File diff suppressed because one or more lines are too long
@@ -1,5 +1,5 @@
|
||||
|
||||
app.directive('loading', function(){
|
||||
app.directive('tip', function(){
|
||||
var str = '<div id="loading" ng-show="isNoLoaded"><img src="../imgs/loading.gif" /></div>';
|
||||
return {
|
||||
restrict: 'AE',
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/*初始化图书列表页*/
|
||||
app.controller('BookListController', function($rootScope, bookList){
|
||||
app.controller('BookListController', ['$rootScope', 'bookList',function($rootScope, bookList){
|
||||
if(!$rootScope.keywordsObj.book){
|
||||
$rootScope.keywordsObj.book = 'C语言';
|
||||
}
|
||||
bookList.getData($rootScope.keywordsObj.book);
|
||||
});
|
||||
}]);
|
||||
|
||||
|
||||
/*图书详情页*/
|
||||
app.controller('BookDetailController', function($rootScope, $http, $scope, $location, ServiceConfig){
|
||||
app.controller('BookDetailController', ['$rootScope', '$http', '$scope', '$location', 'ServiceConfig',function($rootScope, $http, $scope, $location, ServiceConfig){
|
||||
var bookId = $location.path().split('/book/')[1] || '';
|
||||
$rootScope.isNoLoaded = true;
|
||||
$http.jsonp(ServiceConfig.book_search_id + '' + bookId + '?callback=showBookDeatil');
|
||||
@@ -16,4 +16,4 @@ app.controller('BookDetailController', function($rootScope, $http, $scope, $loca
|
||||
$rootScope.isNoLoaded = false;
|
||||
$scope.data = data;
|
||||
};
|
||||
});
|
||||
}]);
|
||||
@@ -1,4 +1,4 @@
|
||||
app.controller('MenuController', function($scope, $location){
|
||||
app.controller('MenuController', ['$scope', '$location',function($scope, $location){
|
||||
$scope.bookSearch = function(){
|
||||
$location.path('/book');
|
||||
};
|
||||
@@ -11,4 +11,4 @@ app.controller('MenuController', function($scope, $location){
|
||||
$location.path('/movie');
|
||||
};
|
||||
|
||||
});
|
||||
}]);
|
||||
@@ -1,7 +1,7 @@
|
||||
/*初始化的结果*/
|
||||
app.controller('movieListController', function($rootScope, movieList){
|
||||
app.controller('movieListController', ['$rootScope', 'movieList',function($rootScope, movieList){
|
||||
if(!$rootScope.keywordsObj.movie){
|
||||
$rootScope.keywordsObj.movie = '幸福';
|
||||
}
|
||||
movieList.getData($rootScope.keywordsObj.movie);
|
||||
});
|
||||
}]);
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
/*初始化的结果*/
|
||||
app.controller('musicListController', function($rootScope, musicList){
|
||||
app.controller('musicListController', ['$rootScope', 'musicList',function($rootScope, musicList){
|
||||
|
||||
if(!$rootScope.keywordsObj.music){
|
||||
$rootScope.keywordsObj.music = '刘德华';
|
||||
}
|
||||
musicList.getData($rootScope.keywordsObj.music);
|
||||
});
|
||||
}]);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*搜索*/
|
||||
app.controller('SearchController', function($scope, $rootScope, $location, bookList, musicList, movieList){
|
||||
var SearchController = function($scope, $rootScope, $location, bookList, musicList, movieList){
|
||||
var path = $location.path();
|
||||
$scope.search = function(){
|
||||
var keywords = $scope.keywords;
|
||||
@@ -22,4 +22,7 @@ app.controller('SearchController', function($scope, $rootScope, $location, bookL
|
||||
movieList.getData($rootScope.keywordsObj.movie);
|
||||
}
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
SearchController.$inject = ['$scope', '$rootScope', '$location', 'bookList', 'musicList', 'movieList'];
|
||||
app.controller('SearchController', SearchController);
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
var app = angular.module('app', ['ui.router']);
|
||||
|
||||
/*$rootScope的相关配置*/
|
||||
app.run(function($rootScope){
|
||||
app.run(['$rootScope', function($rootScope){
|
||||
$rootScope.version = '0.1';
|
||||
$rootScope.author = 'vczero';
|
||||
$rootScope.author_alias = '鬼谣';
|
||||
@@ -14,7 +14,7 @@ app.run(function($rootScope){
|
||||
music: '',
|
||||
movie: ''
|
||||
};
|
||||
});
|
||||
}]);
|
||||
|
||||
/*服务的URL配置*/
|
||||
app.constant('ServiceConfig', {
|
||||
@@ -28,7 +28,7 @@ app.constant('ServiceConfig', {
|
||||
movie_search_id: 'https://api.douban.com/v2/movie/subject/'
|
||||
});
|
||||
|
||||
app.config(function($stateProvider, $urlRouterProvider){
|
||||
app.config(['$stateProvider', '$urlRouterProvider',function($stateProvider, $urlRouterProvider){
|
||||
/*URL路由*/
|
||||
$urlRouterProvider.otherwise("/");
|
||||
|
||||
@@ -126,4 +126,4 @@ app.config(function($stateProvider, $urlRouterProvider){
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}]);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*构建BookList服务*/
|
||||
app.factory('bookList', function($rootScope, $http, ServiceConfig){
|
||||
app.factory('bookList', ['$rootScope', '$http', 'ServiceConfig', function($rootScope, $http, ServiceConfig){
|
||||
$rootScope.isNoLoaded = true;
|
||||
var _BookList = {
|
||||
getData: function(keywords){
|
||||
@@ -29,4 +29,4 @@ app.factory('bookList', function($rootScope, $http, ServiceConfig){
|
||||
};
|
||||
|
||||
return _BookList;
|
||||
});
|
||||
}]);
|
||||
@@ -1,5 +1,5 @@
|
||||
/*构建movieList服务*/
|
||||
app.factory('movieList', function($rootScope, $http, ServiceConfig){
|
||||
app.factory('movieList', ['$rootScope', '$http', 'ServiceConfig', function($rootScope, $http, ServiceConfig){
|
||||
$rootScope.isNoLoaded = true;
|
||||
var _MovieList = {
|
||||
getData: function(keywords){
|
||||
@@ -17,4 +17,4 @@ app.factory('movieList', function($rootScope, $http, ServiceConfig){
|
||||
};
|
||||
|
||||
return _MovieList;
|
||||
});
|
||||
}]);
|
||||
@@ -1,5 +1,5 @@
|
||||
/*构建musicList服务*/
|
||||
app.factory('musicList', function($rootScope, $http, ServiceConfig){
|
||||
app.factory('musicList', ['$rootScope', '$http', 'ServiceConfig', function($rootScope, $http, ServiceConfig){
|
||||
$rootScope.isNoLoaded = true;
|
||||
var _MusicList = {
|
||||
getData: function(keywords){
|
||||
@@ -16,4 +16,4 @@ app.factory('musicList', function($rootScope, $http, ServiceConfig){
|
||||
};
|
||||
|
||||
return _MusicList;
|
||||
});
|
||||
}]);
|
||||
+8
-4
@@ -1,5 +1,9 @@
|
||||
{
|
||||
"dependencies":{
|
||||
"grunt": "*"
|
||||
}
|
||||
}
|
||||
"name": "wlhmyit",
|
||||
"version": "0.0.1",
|
||||
"devDependencies": {
|
||||
"grunt": "~0.4.5",
|
||||
"grunt-contrib-uglify": "~0.6.0",
|
||||
"grunt-contrib-concat": "~0.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user