diff --git a/CHANGELOG-zh.md b/CHANGELOG-zh.md index e94ecfbb..83440bbb 100644 --- a/CHANGELOG-zh.md +++ b/CHANGELOG-zh.md @@ -6,6 +6,7 @@ - **示例爬虫**. 当初始化时,自动加入示例爬虫. [#379](https://github.com/crawlab-team/crawlab/issues/379) - **用户管理优化**. 限制管理用户的权限. [#456](https://github.com/crawlab-team/crawlab/issues/456) - **设置页面优化**. +- **任务结果页面优化**. ### Bug 修复 - **无法找到爬虫文件错误**. [#485](https://github.com/crawlab-team/crawlab/issues/485) @@ -14,6 +15,7 @@ - **下载结果错误**. [#465](https://github.com/crawlab-team/crawlab/issues/465) - **crawlab-sdk CLI 错误**. [#458](https://github.com/crawlab-team/crawlab/issues/458) - **页面刷新问题**. [#441](https://github.com/crawlab-team/crawlab/issues/441) +- **结果不支持 JSON**. [#202](https://github.com/crawlab-team/crawlab/issues/202) - **修复“删除爬虫后获取所有爬虫”错误**. - **修复 i18n 警告**. diff --git a/CHANGELOG.md b/CHANGELOG.md index 07103074..4c6c56ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - **Demo Spiders**. Added demo spiders when Crawlab is initialized. [#379](https://github.com/crawlab-team/crawlab/issues/379) - **User Admin Optimization**. Restrict privilleges of admin users. [#456](https://github.com/crawlab-team/crawlab/issues/456) - **Setting Page Optimization**. +- **Task Results Optimization**. ### Bug Fixes - **Unable to find spider file error**. [#485](https://github.com/crawlab-team/crawlab/issues/485) @@ -14,6 +15,7 @@ - **Download results error**. [#465](https://github.com/crawlab-team/crawlab/issues/465) - **crawlab-sdk CLI error**. [#458](https://github.com/crawlab-team/crawlab/issues/458) - **Page refresh issue**. [#441](https://github.com/crawlab-team/crawlab/issues/441) +- **Results not support JSON**. [#202](https://github.com/crawlab-team/crawlab/issues/202) - **Getting all spider after deleting a spider**. - **i18n warning**. diff --git a/backend/utils/model.go b/backend/utils/model.go index 21a295d6..048b0001 100644 --- a/backend/utils/model.go +++ b/backend/utils/model.go @@ -2,9 +2,9 @@ package utils import ( "crawlab/constants" + "encoding/json" "github.com/globalsign/mgo/bson" - "strconv" - "time" + "strings" ) func IsObjectIdNull(id bson.ObjectId) bool { @@ -12,16 +12,13 @@ func IsObjectIdNull(id bson.ObjectId) bool { } func InterfaceToString(value interface{}) string { - switch realValue := value.(type) { - case bson.ObjectId: - return realValue.Hex() - case string: - return realValue - case int: - return strconv.Itoa(realValue) - case time.Time: - return realValue.String() - default: + bytes, err := json.Marshal(value) + if err != nil { return "" } + str := string(bytes) + if strings.HasPrefix(str, "\"") && strings.HasSuffix(str, "\"") { + str = str[1 : len(str)-1] + } + return str } diff --git a/frontend/src/components/TableView/GeneralTableView.vue b/frontend/src/components/TableView/GeneralTableView.vue index 819a0572..3f7693f3 100644 --- a/frontend/src/components/TableView/GeneralTableView.vue +++ b/frontend/src/components/TableView/GeneralTableView.vue @@ -6,6 +6,13 @@ border> + + + + {{getString(scope.row[col])}} + + + @@ -58,23 +65,39 @@ export default { computed: { filteredData () { return this.data - // .map(d => d) - // .filter((d, index) => { - // // pagination - // const pageNum = this.pageNum - // const pageSize = this.pageSize - // return (pageSize * (pageNum - 1) <= index) && (index < pageSize * pageNum) - // }) } }, methods: { onPageChange () { this.$emit('page-change', { pageNum: this.pageNum, pageSize: this.pageSize }) + }, + getString (value) { + if (value === undefined) return '' + const str = JSON.stringify(value) + if (str.match(/^"(.*)"$/)) return str.match(/^"(.*)"$/)[1] + return str } } } + +