mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-29 18:00:51 +01:00
完成scrapy设置
This commit is contained in:
@@ -95,16 +95,18 @@
|
||||
:data="spiderScrapySettings"
|
||||
border
|
||||
:header-cell-style="{background:'rgb(48, 65, 86)',color:'white'}"
|
||||
max-height="calc(100vh - 240px"
|
||||
>
|
||||
<el-table-column
|
||||
:label="$t('Variable Name')"
|
||||
width="240px"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
<el-autocomplete
|
||||
v-model="scope.row.key"
|
||||
size="small"
|
||||
suffix-icon="el-icon-edit"
|
||||
:fetch-suggestions="settingsKeysFetchSuggestions"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -113,7 +115,7 @@
|
||||
width="120px"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-select v-model="scope.row.type" size="small">
|
||||
<el-select v-model="scope.row.type" size="small" @change="onParamTypeChange(scope.row)">
|
||||
<el-option value="string" :label="$t('String')"/>
|
||||
<el-option value="number" :label="$t('Number')"/>
|
||||
<el-option value="boolean" :label="$t('Boolean')"/>
|
||||
@@ -139,6 +141,7 @@
|
||||
v-model="scope.row.value"
|
||||
size="small"
|
||||
suffix-icon="el-icon-edit"
|
||||
@change="scope.row.value = Number(scope.row.value)"
|
||||
/>
|
||||
<div
|
||||
v-else-if="scope.row.type === 'boolean'"
|
||||
@@ -283,6 +286,28 @@ export default {
|
||||
delete value[key]
|
||||
this.$set(this.activeParam, 'value', value)
|
||||
}
|
||||
},
|
||||
settingsKeysFetchSuggestions (queryString, cb) {
|
||||
const data = this.$utils.scrapy.settingParamNames
|
||||
.filter(s => {
|
||||
if (!queryString) return true
|
||||
return !!s.match(new RegExp(queryString, 'i'))
|
||||
})
|
||||
.map(s => {
|
||||
return {
|
||||
value: s,
|
||||
label: s
|
||||
}
|
||||
})
|
||||
.sort((a, b) => {
|
||||
return a > b ? -1 : 1
|
||||
})
|
||||
cb(data)
|
||||
},
|
||||
onParamTypeChange (row) {
|
||||
if (row.type === 'number') {
|
||||
row.value = Number(row.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<el-tab-pane :label="$t('Overview')" name="overview">
|
||||
<spider-overview/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane v-if="isScrapy" :label="$t('Scrapy Settings')" name="scrapy-config">
|
||||
<el-tab-pane v-if="isScrapy" :label="$t('Scrapy Settings')" name="scrapy-settings">
|
||||
<spider-scrapy/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane v-if="isConfigurable" :label="$t('Config')" name="config">
|
||||
@@ -69,9 +69,6 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
activeTabName () {
|
||||
// 初始化文件
|
||||
this.$store.commit('file/SET_FILE_CONTENT', '')
|
||||
this.$store.commit('file/SET_CURRENT_PATH', '')
|
||||
}
|
||||
},
|
||||
data () {
|
||||
@@ -201,8 +198,13 @@ export default {
|
||||
this.$st.sendEv('教程', '开始', 'spider-detail-config')
|
||||
}, 100)
|
||||
}
|
||||
} else if (this.activeTabName === 'scrapy-config') {
|
||||
} else if (this.activeTabName === 'scrapy-settings') {
|
||||
this.$store.dispatch('spider/getSpiderScrapySpiders', this.$route.params.id)
|
||||
this.$store.dispatch('spider/getSpiderScrapySettings', this.$route.params.id)
|
||||
} else if (this.activeTabName === 'files') {
|
||||
if (this.currentPath) {
|
||||
this.$store.dispatch('file/getFileContent', { path: this.currentPath })
|
||||
}
|
||||
}
|
||||
this.$st.sendEv('爬虫详情', '切换标签', tab.name)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user