基於豆瓣API+Angular開發的web App,apiangular

來源:互聯網
上載者:User

基於豆瓣API+Angular開發的web App,apiangular

一、扯淡的說

name:【豆瓣搜尋】

最近關注了下豆瓣的API,發現豆瓣開放平台需要加強API文檔撰寫啊....但是有個可喜的發現豆瓣V2介面提供了搜尋介面。最近在用phantom弄些爬蟲,想想,真是美麗極了!有個豆瓣的介面,我都不用去爬資料,不用資料存放區,丟給github page直接完事。豆瓣,Nice!最近也在看angular,於是就萌生了使用Angular + 豆瓣API 做一個web app。於是...網上回家就折騰了。

體驗地址:http://vczero.github.io/t/html/index.html#/

項目地址:https://github.com/vczero/search (歡迎大家fork,任意修改,繼續增加功能;歡迎拍磚,一起進步。)

二、直接

(1)圖書搜尋

(2)音樂搜尋介面

(3)圖書詳情

(4)電影搜尋

三、項目結構和簡介

三、幾個注意點

(1)-webkit-tap-highlight-color:rgba(255,255,255,0);去除點擊時的高亮陰影

(2)box-sizing:border-box的使用,包含padding的像素計算

(3)position fixed 和 搜尋跳轉的結合(虛擬鍵盤引起)

(4)angular-ui-router的多視圖控制

(5)ios & android系統的各種細節

(6)壓縮angularjs代碼依賴注入的問題

...

我覺得比較重要的服務和狀態路由的代碼貼出來

複製代碼 代碼如下:
/*服務的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: ''
                }
            }
        })
        .state('search',{
            url: '/search/:type',
            views:{
                header:{
                    templateUrl: '../html/views/search.html',
                    controller: 'Search'
                },
                container:{
                    templateUrl: '',
                    controller: ''
                },
                footer:{
                    templateUrl: '',
                    controller: ''
                }
            }
        });
}]);

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.