diff --git a/frontend/src/store/modules/spider.js b/frontend/src/store/modules/spider.js
index b7093da4..e653db3d 100644
--- a/frontend/src/store/modules/spider.js
+++ b/frontend/src/store/modules/spider.js
@@ -155,6 +155,9 @@ const actions = {
saveConfigSpiderSpiderfile ({ state, rootState }) {
const content = rootState.file.fileContent
return request.post(`/config_spiders/${state.spiderForm._id}/spiderfile`, { content })
+ },
+ addConfigSpider ({ state }) {
+ return request.put(`/config_spiders`, state.spiderForm)
}
}
diff --git a/frontend/src/views/spider/SpiderList.vue b/frontend/src/views/spider/SpiderList.vue
index 11884a7f..41007044 100644
--- a/frontend/src/views/spider/SpiderList.vue
+++ b/frontend/src/views/spider/SpiderList.vue
@@ -33,18 +33,52 @@
width="40%"
:visible.sync="addDialogVisible"
:before-close="onAddDialogClose">
-
-
-
- {{$t('Configurable Spider')}}
-
-
-
-
- {{$t('Customized Spider')}}
-
-
-
+
+
+
+
+
+ {{$t('Upload')}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{$t('Add')}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -81,20 +115,7 @@
width="40%"
:visible.sync="addCustomizedDialogVisible"
:before-close="onAddCustomizedDialogClose">
-
-
-
- {{$t('Upload')}}
-
-
-
-
+
@@ -301,7 +322,8 @@ export default {
spiderFormRules: {
name: [{ required: true, message: 'Required Field', trigger: 'change' }]
},
- fileList: []
+ fileList: [],
+ spiderType: 'customized'
}
},
computed: {
@@ -332,14 +354,24 @@ export default {
this.getList()
},
onAdd () {
- // this.addDialogVisible = true
- this.onAddCustomized()
+ this.$store.commit('spider/SET_SPIDER_FORM', {})
+ this.addDialogVisible = true
+ // this.onAddCustomized()
},
onAddConfigurable () {
- this.$store.commit('spider/SET_SPIDER_FORM', {})
- this.addDialogVisible = false
- this.addConfigurableDialogVisible = true
- this.$st.sendEv('爬虫', '添加爬虫-可配置爬虫')
+ this.$refs['addConfigurableForm'].validate(async res => {
+ if (!res) return
+
+ let res2
+ try {
+ res2 = await this.$store.dispatch('spider/addConfigSpider')
+ } catch (e) {
+ this.$message.error(this.$t('Something wrong happened'))
+ return
+ }
+ this.$router.push(`/spiders/${res2.data.data._id}`)
+ this.$st.sendEv('爬虫', '添加爬虫-可配置爬虫')
+ })
},
onAddCustomized () {
this.addDialogVisible = false
@@ -613,4 +645,8 @@ export default {
.el-table >>> tr {
cursor: pointer;
}
+
+ .actions {
+ text-align: right;
+ }