diff --git a/backend/services/spider.go b/backend/services/spider.go index aa97b4ad..3922d822 100644 --- a/backend/services/spider.go +++ b/backend/services/spider.go @@ -116,12 +116,15 @@ func PublishAllSpiders() { // 发布爬虫 func PublishSpider(spider model.Spider) { - // 查询gf file,不存在则标记为爬虫文件不存在 - gfFile := model.GetGridFs(spider.FileId) - if gfFile == nil { - spider.FileId = constants.ObjectIdNull - _ = spider.Save() - return + var gfFile *model.GridFs + if spider.FileId.Hex() != constants.ObjectIdNull { + // 查询gf file,不存在则标记为爬虫文件不存在 + gfFile = model.GetGridFs(spider.FileId) + if gfFile == nil { + spider.FileId = constants.ObjectIdNull + _ = spider.Save() + return + } } // 如果FileId为空,表示还没有上传爬虫到GridFS,则跳过 diff --git a/frontend/src/components/Config/ConfigList.vue b/frontend/src/components/Config/ConfigList.vue index bd909cf0..d08b1109 100644 --- a/frontend/src/components/Config/ConfigList.vue +++ b/frontend/src/components/Config/ConfigList.vue @@ -139,18 +139,22 @@ > - - - - - + + @@ -600,6 +669,56 @@ ${f.css || f.xpath} ${f.attr ? ('(' + f.attr + ')') : ''} ${f.next_stage ? (' -- } catch (e) { this.$message.error('Something wrong happened') } + }, + isList (stage) { + return !!stage.list_css || !!stage.list_xpath + }, + onCheckIsList (value, stage) { + if (value) { + if (!stage.list_css && !stage.list_xpath) { + stage.list_css = 'body' + } + } else { + stage.list_css = '' + stage.list_xpath = '' + } + }, + onClickStageList ($event, stage, type) { + $event.stopPropagation() + }, + onSelectStageListType (stage, type) { + if (type === 'css') { + if (!stage.list_css) stage.list_css = 'body' + stage.list_xpath = '' + } else { + if (!stage.list_xpath) stage.list_xpath = '//body' + stage.list_css = '' + } + }, + isPage (stage) { + return !!stage.page_css || !!stage.page_xpath + }, + onCheckIsPage (value, stage) { + if (value) { + if (!stage.page_css && !stage.page_xpath) { + stage.page_css = 'body' + } + } else { + stage.page_css = '' + stage.page_xpath = '' + } + }, + onClickStagePage ($event, stage, type) { + $event.stopPropagation() + }, + onSelectStagePageType (stage, type) { + if (type === 'css') { + if (!stage.page_css) stage.page_css = 'body' + stage.page_xpath = '' + } else { + if (!stage.page_xpath) stage.page_xpath = '//body' + stage.page_css = '' + } } }, mounted () { @@ -653,12 +772,19 @@ ${f.css || f.xpath} ${f.attr ? ('(' + f.attr + ')') : ''} ${f.next_stage ? (' -- font-weight: bolder; } - .selector-type-item > .el-tag.inactive { + .el-tag { + margin-right: 5px; + font-weight: bolder; + cursor: pointer; + } + + .el-tag.inactive { opacity: 0.5; } .stage-list { - width: calc(80px + 320px); + width: 100%; + /*width: calc(80px + 320px);*/ display: flex; flex-wrap: wrap; list-style: none; @@ -667,8 +793,8 @@ ${f.css || f.xpath} ${f.attr ? ('(' + f.attr + ')') : ''} ${f.next_stage ? (' -- } .stage-list .stage-item { - flex-basis: 320px; - width: 320px; + /*flex-basis: 320px;*/ + min-width: 120px; display: flex; align-items: center; } @@ -677,6 +803,7 @@ ${f.css || f.xpath} ${f.attr ? ('(' + f.attr + ')') : ''} ${f.next_stage ? (' -- flex-basis: 90px; margin-right: 10px; justify-self: flex-end; + text-align: right; } .stage-list .stage-item .el-input { diff --git a/frontend/src/i18n/zh.js b/frontend/src/i18n/zh.js index a1190253..4d2883e1 100644 --- a/frontend/src/i18n/zh.js +++ b/frontend/src/i18n/zh.js @@ -164,6 +164,8 @@ export default { 'No Next Stage': '没有下一阶段', 'Fields': '字段', 'Stage': '阶段', + 'Is List': '是否为列表', + 'Pagination': '分页', // 爬虫列表 'Name': '名称',