       @showPopularPackage @result
 
     onNextPage: ->
+      return unless @serverPackages
       @currentPage++  if @currentPage + 1 < @serverPackages.length / 10
       startIndex = @currentPage * 10
       endIndex = startIndex + 10

    fetchAllPackageFormServer:() ->
        Q.promise (resolve, reject, notify) =>
          r = request.get "#{PuzzleServer}/api/packages?access_token=#{PuzzleAccessToken}&sequence=create_date", (err, res, body) =>
            reject err if err
            data = JSON.parse(body)
            resolve data.packages

    #搜索完成时回调
    onSearchDone: (packages, keyword)->

        installPathEditor.setText destPath[0]

    installPackage: (path, name, repo, callback)->


      (require "../../utils/checkNetwork")("http", "http://www.baidu.com").then =>
        console.log "Start pull package,Path:#{path}, PackageName:#{name}, gitRepo:#{repo}"
        git({
          path: "#{path}"
          name: name
          repo: repo
          })
      .then (destPath) =>
        console.log 'package pull finished'
        callback(destPath) if callback
      .catch (error) =>
        @showTip 'Install error, please check out your network.'
        callback() if callback

    onPrevPage: ->
      return unless @serverPackages
      @currentPage-- if @currentPage > 0
      startIndex = @currentPage * 10
      endIndex = startIndex + 10
