From f63b58906eec25fb8a7bbf8572e11693ab350f6d Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Wed, 22 May 2019 22:33:43 +0800 Subject: [PATCH] updated SiteList --- frontend/src/i18n/zh.js | 1 + frontend/src/store/modules/site.js | 29 ++++++++ frontend/src/store/modules/spider.js | 15 +++- frontend/src/views/site/SiteList.vue | 91 +++++++++++++++--------- frontend/src/views/spider/SpiderList.vue | 74 ++++++++++++++----- 5 files changed, 158 insertions(+), 52 deletions(-) diff --git a/frontend/src/i18n/zh.js b/frontend/src/i18n/zh.js index 17a0df1e..ea1caed6 100644 --- a/frontend/src/i18n/zh.js +++ b/frontend/src/i18n/zh.js @@ -137,6 +137,7 @@ export default { 'Domain': '域名', 'Category': '类别', 'Select': '请选择', + 'Select Main Category': '请选择主类别', 'Select Category': '请选择类别', 'Spider Count': '爬虫数', 'Robots Protocol': 'Robots 协议', diff --git a/frontend/src/store/modules/site.js b/frontend/src/store/modules/site.js index d05b8de4..ec1de9f3 100644 --- a/frontend/src/store/modules/site.js +++ b/frontend/src/store/modules/site.js @@ -1,10 +1,18 @@ import request from '../../api/request' const state = { + // site list siteList: [], + // main category list + mainCategoryList: [], + + // (sub) category list + categoryList: [], + // filter filter: { + mainCategory: undefined, category: undefined }, keyword: '', @@ -32,6 +40,12 @@ const mutations = { }, SET_TOTAL_COUNT (state, value) { state.totalCount = value + }, + SET_MAIN_CATEGORY_LIST (state, value) { + state.mainCategoryList = value + }, + SET_CATEGORY_LIST (state, value) { + state.categoryList = value } } @@ -48,6 +62,7 @@ const actions = { page_size: state.pageSize, keyword: state.keyword || undefined, filter: { + main_category: state.filter.mainCategory || undefined, category: state.filter.category || undefined } }) @@ -55,6 +70,20 @@ const actions = { commit('SET_SITE_LIST', response.data.items) commit('SET_TOTAL_COUNT', response.data.total_count) }) + }, + getMainCategoryList ({ state, commit }) { + return request.get('/sites/get/get_main_category_list') + .then(response => { + commit('SET_MAIN_CATEGORY_LIST', response.data.items) + }) + }, + getCategoryList ({ state, commit }) { + return request.get('/sites/get/get_category_list', { + 'main_category': state.filter.mainCategory || undefined + }) + .then(response => { + commit('SET_CATEGORY_LIST', response.data.items) + }) } } diff --git a/frontend/src/store/modules/spider.js b/frontend/src/store/modules/spider.js index b7e702fd..a55f90f7 100644 --- a/frontend/src/store/modules/spider.js +++ b/frontend/src/store/modules/spider.js @@ -26,7 +26,10 @@ const state = { dailyStats: [], // spider node stats - nodeStats: [] + nodeStats: [], + + // filters + filterSite: '' } const getters = {} @@ -55,12 +58,20 @@ const mutations = { }, SET_NODE_STATS (state, value) { state.nodeStats = value + }, + SET_FILTER_SITE (state, value) { + state.filterSite = value } } const actions = { getSpiderList ({ state, commit }) { - return request.get('/spiders', {}) + let params = {} + if (state.filterSite) { + params.site = state.filterSite + } + console.log(params) + return request.get('/spiders', params) .then(response => { commit('SET_SPIDER_LIST', response.data.items) }) diff --git a/frontend/src/views/site/SiteList.vue b/frontend/src/views/site/SiteList.vue index 7cf3e936..ede3941e 100644 --- a/frontend/src/views/site/SiteList.vue +++ b/frontend/src/views/site/SiteList.vue @@ -7,11 +7,15 @@ class="filter-search" v-model="keyword"> + + + {{$t('Search')}} @@ -25,24 +29,24 @@ :header-cell-style="{background:'rgb(48, 65, 86)',color:'white'}" border>