-
+
{{$t('Import')}}
+
+
+
+
+
+
+
+ {{$t('Configurable Spider')}}
+
+
+
+
+ {{$t('Customized Spider')}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{$t('Please go to the source folder of your spiders, create a sub-folder and add your spider codes into it')}}
+
+
+
@@ -50,6 +110,12 @@
{{$t('Import Spiders')}}
+
+ {{$t('Add Spider')}}
+
- Scrapy
- PySpider
- WebMagic
- {{scope.row.type}}
+ {{$t('Configurable')}}
+ {{$t('Customized')}}
-
+
@@ -160,8 +223,12 @@ export default {
pageSize: 10
},
importLoading: false,
+ addConfigurableLoading: false,
isEditMode: false,
dialogVisible: false,
+ addDialogVisible: false,
+ addConfigurableDialogVisible: false,
+ addCustomizedDialogVisible: false,
filter: {
keyword: ''
},
@@ -169,7 +236,7 @@ export default {
columns: [
{ name: 'name', label: 'Name', width: 'auto' },
{ name: 'site_name', label: 'Site', width: '120' },
- { name: 'type', label: 'Spider Type', width: '120', sortable: true },
+ { name: 'type', label: 'Spider Type', width: '120' },
{ name: 'lang', label: 'Language', width: '120', sortable: true },
{ name: 'task_ts', label: 'Last Run', width: '160' },
{ name: 'last_7d_tasks', label: 'Last 7-Day Tasks', width: '80' },
@@ -219,9 +286,16 @@ export default {
console.log(value)
},
onAdd () {
+ this.addDialogVisible = true
+ },
+ onAddConfigurable () {
this.$store.commit('spider/SET_SPIDER_FORM', {})
- this.isEditMode = false
- this.dialogVisible = true
+ this.addDialogVisible = false
+ this.addConfigurableDialogVisible = true
+ },
+ onAddCustomized () {
+ this.addDialogVisible = false
+ this.addCustomizedDialogVisible = true
},
onRefresh () {
this.$store.dispatch('spider/getSpiderList')
@@ -246,10 +320,22 @@ export default {
this.$store.commit('spider/SET_SPIDER_FORM', {})
this.dialogVisible = false
},
+ onAddCancel () {
+ this.addDialogVisible = false
+ },
onDialogClose () {
this.$store.commit('spider/SET_SPIDER_FORM', {})
this.dialogVisible = false
},
+ onAddDialogClose () {
+ this.addDialogVisible = false
+ },
+ onAddCustomizedDialogClose () {
+ this.addCustomizedDialogVisible = false
+ },
+ onAddConfigurableDialogClose () {
+ this.addConfigurableDialogVisible = false
+ },
onEdit (row) {
this.isEditMode = true
this.$store.commit('spider/SET_SPIDER_FORM', row)
@@ -363,6 +449,21 @@ export default {
},
onSiteSelect (item) {
this.$store.commit('spider/SET_FILTER_SITE', item._id)
+ },
+ onAddConfigurableSiteSelect (item) {
+ this.spiderForm.site = item._id
+ },
+ onAddConfigurableSpider () {
+ this.$refs['addConfigurableForm'].validate(res => {
+ if (res) {
+ this.addConfigurableLoading = true
+ this.$store.dispatch('spider/addSpider')
+ .finally(() => {
+ this.addConfigurableLoading = false
+ this.addConfigurableDialogVisible = false
+ })
+ }
+ })
}
},
created () {
@@ -412,4 +513,37 @@ export default {
background-color: red;
}
+ .add-spider-wrapper {
+ display: flex;
+ justify-content: center;
+
+ .add-spider-item {
+ cursor: pointer;
+ width: 180px;
+ font-size: 18px;
+ height: 120px;
+ margin: 0 20px;
+ flex-basis: 40%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+
+ .add-spider-item.primary {
+ color: #409eff;
+ background: rgba(64, 158, 255, .1);
+ border: 1px solid rgba(64, 158, 255, .1);
+ }
+
+ .add-spider-item.success {
+ color: #67c23a;
+ background: rgba(103, 194, 58, .1);
+ border: 1px solid rgba(103, 194, 58, .1);
+ }
+ }
+
+ .el-autocomplete {
+ width: 100%;
+ }
+