创新实训博客(40)——Web爬取任务管理界面设计以及用户接口调用

界面设计布局

主界面

添加功能

api部分接口对接

export function adminGetCrawlList() {
  return request({
    url: '/admin/crawl/list',
    method: 'get'
  })
}

export function adminAddCrawl(id) {
  return request({
    url: '/admin/crawl/add/' + id,
    method: 'get'
  })
}

前端html代码

<template>
  <div class="app-container" style="margin-left: 8%; width: 84%">
    <el-row>
      <el-col :span="6" style="margin: 8px">
        <el-input v-model="searchItem" placeholder="请输入内容" size="small">
          <el-button slot="append" size="small" icon="el-icon-search" />
        </el-input>
      </el-col>
      <el-col :span="4" style="margin: 8px">
        <el-button type="plain" size="small" icon="el-icon-plus" @click="addBlog">添加任务</el-button>
      </el-col>
    </el-row>
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      stripe
      border
      fit
      highlight-current-row
    >
      <el-table-column align="center" label="博客id" width="120%" prop="id" />
      <el-table-column align="center" label="博客名称" prop="title" />
      <el-table-column align="center" label="博客链接" prop="url" />
      <el-table-column align="center" label="订阅链接" prop="feed" />
      <el-table-column align="center" label="文章数量" width="120%" prop="articleCount" />
      <el-table-column align="center" label="管理" width="120%">
        <template slot-scope="scope">
          <el-button-group>
            <el-button type="danger" size="mini" icon="el-icon-delete" @click="del(scope.row)">删除</el-button>
          </el-button-group>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog :visible.sync="addFormVisible" title="添加任务">
      <el-form label-width="80px" style="margin: 8px">
        <el-form-item label="博客id"><el-input v-model="addBlogId" placeholder="请输入博客待抓取的博客id:xxx" /></el-form-item>
        <el-form-item>
          <div style="float: right">
            <el-button @click="addFormVisible = false">取消</el-button>
            <el-button type="primary" @click="confirmAdd">确定</el-button>
          </div>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

js接口调用代码

    handleCurrentChange() {
      var that = this
      that.listLoading = true
      adminGetCrawlList().then(response => {
        const { data } = response
        that.list = data
        that.listLoading = false
      })
    },
    addBlog() {
      this.addFormVisible = true
    },
    confirmAdd() {
      var that = this
      adminAddCrawl(that.addBlogId).then(response => {
        that.addBlogId = 0
        that.addFormVisible = false
        that.handleCurrentChange()
      }).catch(error => {
        console.log(error)
      })
    },

修改用户的博主服务,添加爬取按钮

            <el-button v-if="isDev" type="info" :loading="crawlLoading" size="medium" @click="startCrawl">抓取</el-button>

设置爬取按钮函数

    startCrawl() {
      var that = this
      that.crawlLoading = true
      userAddCrawl(that.basicInfo.id).then(response => {
        that.crawlLoading = true
      })
    }

界面效果

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值