Skip to content

Commit

Permalink
Feature(example): add example page
Browse files Browse the repository at this point in the history
  • Loading branch information
Armour committed May 25, 2019
1 parent 66510bd commit 3d42066
Show file tree
Hide file tree
Showing 31 changed files with 1,605 additions and 269 deletions.
52 changes: 17 additions & 35 deletions mock/article.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,30 @@
import Mock from 'mockjs'
import { IExampleArticleData } from '@/api/article'

interface ListItem {
id: number
timestamp: number
author: string
reviewer: string
title: string
contentShort: string
content: string
forecast: number
importance: number
type: string
status: string
displayTime: string
commentDisabled: boolean
pageviews: number
imageUri: string
platforms: string[]
}

const List: ListItem[] = []
const List: IExampleArticleData[] = []
const count = 100

const baseContent = '<p>我是测试数据我是测试数据</p><p><img src="https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943"></p>'
const imageUri = 'https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3'
const fullContent = '<p>I am testing data, I am testing data.</p><p><img src="https://wpimg.wallstcn.com/4c69009c-0fd4-4153-b112-6cb53d1cf943"></p>'
const imageURL = 'https://wpimg.wallstcn.com/e4558086-631c-425c-9430-56ffb46e70b3'
const sourceURL = ''

for (let i = 0; i < count; i++) {
List.push(Mock.mock({
id: '@increment',
timestamp: +Mock.Random.date('T'),
author: '@first',
reviewer: '@first',
'status|1': ['published', 'draft', 'deleted'],
title: '@title(5, 10)',
content_short: 'mock data',
content: baseContent,
forecast: '@float(0, 100, 2, 2)',
abstractContent: 'mock data',
fullContent,
sourceURL,
imageURL,
timestamp: '@datetime',
platforms: ['a-platform'],
disableComment: true,
importance: '@integer(1, 3)',
author: '@first',
reviewer: '@first',
'type|1': ['CN', 'US', 'JP', 'EU'],
'status|1': ['published', 'draft', 'deleted'],
display_time: '@datetime',
comment_disabled: true,
pageviews: '@integer(300, 5000)',
imageUri,
platforms: ['a-platform']
pageviews: '@integer(300, 5000)'
}))
}

Expand Down Expand Up @@ -82,7 +64,7 @@ export default [
response: (config: any) => {
const { id } = config.query
for (const article of List) {
if (article.id === +id) {
if (article.id.toString() === id) {
return {
code: 20000,
data: article
Expand Down
36 changes: 36 additions & 0 deletions src/api/article.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
import request from '@/utils/request'

export interface IExampleArticleData {
id: string
status: string
title: string
abstractContent: string
fullContent: string
sourceURL: string
imageURL: string
timestamp: string | number
platforms: string[]
disableComment: boolean
importance: number
author: string
reviewer: string
type: string
pageviews: number
}

export const defaultExampleArticleData: IExampleArticleData = {
id: '',
status: 'draft',
title: '',
fullContent: '',
abstractContent: '',
sourceURL: '',
imageURL: '',
timestamp: '',
platforms: ['a-platform'],
disableComment: false,
importance: 0,
author: '',
reviewer: '',
type: '',
pageviews: 0
}

export const fetchList = (params: any) =>
request({
url: '/article/list',
Expand Down
Loading

1 comment on commit 3d42066

@Armour
Copy link
Owner Author

@Armour Armour commented on 3d42066 May 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#51

Please sign in to comment.