From 6ada352ac0bebdaa0753f7c3336134fe62236d4e Mon Sep 17 00:00:00 2001 From: marvzhang Date: Wed, 27 Nov 2019 19:59:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E9=85=8D=E7=BD=AE=E7=88=AC=E8=99=AB?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/Config/ConfigList.vue | 218 +++++++++++------- .../components/TableView/FieldsTableView.vue | 41 +++- 2 files changed, 167 insertions(+), 92 deletions(-) diff --git a/frontend/src/components/Config/ConfigList.vue b/frontend/src/components/Config/ConfigList.vue index cc405950..e54469a0 100644 --- a/frontend/src/components/Config/ConfigList.vue +++ b/frontend/src/components/Config/ConfigList.vue @@ -43,75 +43,63 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CSS - - - +
+
    +
  • + + +
  • +
  • + + + + +
  • +
  • + + + + +
  • +
  • + +
    + + + CSS + + + - - +
    +
  • +
+
- - - -
- {{$t('Run')}} - {{$t('Extract Fields')}} - - {{$t('Preview')}} - {{$t('Save')}} -
-
- -
+
+
+ {{$t('Run')}} + {{$t('Extract Fields')}} + + {{$t('Preview')}} + {{$t('Save')}} +
+
d.name) + }, + startUrlClass () { + if (!this.spiderForm.config.start_url) { + return 'invalid' + } else if (!this.spiderForm.config.start_url.match(/^https?:\/\/.+|^\/\/.+/i)) { + return 'invalid' + } + + return '' + }, + startStageClass () { + if (!this.spiderForm.config.start_stage) { + return 'invalid' + } else if (!this.activeNames.includes(this.spiderForm.config.start_stage)) { + return 'invalid' + } + return '' } }, methods: { @@ -408,8 +411,27 @@ export default { const stages = JSON.parse(JSON.stringify(this.spiderForm.config.stages)) delete stages[stage.name] this.$set(this.spiderForm.config, 'stages', stages) + if (Object.keys(stages).length === 0) { + this.onAddStage() + } }, onAddStage (stage) { + const stages = JSON.parse(JSON.stringify(this.spiderForm.config.stages)) + const ts = Math.floor(new Date().getTime()).toString() + const newStageName = `stage_${ts}` + const newField = { name: `field_${ts}`, next_stage: '' } + if (this.isCss) { + newField['css'] = 'body' + } else if (this.isXpath) { + newField['xpath'] = '//body' + } else { + newField['css'] = 'body' + } + stages[newStageName] = { + name: newStageName, + fields: [newField] + } + this.$set(this.spiderForm.config, 'stages', stages) } }, created () { @@ -492,9 +514,6 @@ export default { .selector-type-item { margin: 0 5px; cursor: pointer; - } - - .selector-type-item > .el-tag.active { font-weight: bolder; } @@ -572,4 +591,39 @@ export default { height: 32px; line-height: 32px; } + + .top-wrapper { + display: flex; + justify-content: space-between; + align-items: center; + } + + .top-wrapper .list { + list-style: none; + display: flex; + flex-wrap: wrap; + align-items: center; + padding: 0; + } + + .top-wrapper .list .item { + margin-bottom: 10px; + display: flex; + align-items: center; + } + + .top-wrapper .list .item label { + width: 100px; + text-align: right; + margin-right: 10px; + font-size: 12px; + } + + .top-wrapper .list .item label + * { + width: 240px; + } + + .invalid >>> .el-input__inner { + border: 1px solid red !important; + } diff --git a/frontend/src/components/TableView/FieldsTableView.vue b/frontend/src/components/TableView/FieldsTableView.vue index 7b1ef9f5..220deda8 100644 --- a/frontend/src/components/TableView/FieldsTableView.vue +++ b/frontend/src/components/TableView/FieldsTableView.vue @@ -10,6 +10,7 @@