-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from hocgin/v4.0.42
V4.0.42
- Loading branch information
Showing
23 changed files
with
447 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* 模拟返回结构 | ||
*/ | ||
export default function result(success: boolean, message: string, data?: any) { | ||
return { | ||
success: success, | ||
message: message, | ||
data: data, | ||
}; | ||
} | ||
|
||
export function success(data: any = null) { | ||
return result(true, 'ok', data); | ||
} | ||
|
||
export function error(message = 'error', data: any = null) { | ||
return result(false, message, data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { success } from './_utils/result'; | ||
|
||
// http://mockjs.com/examples.html | ||
export default { | ||
'GET /api/worked': (req: any, res: any) => { | ||
return res.json(success()); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { success } from './_utils/result'; | ||
import Mock from 'mockjs'; | ||
import { CommentType } from '@/Comment/components/type'; | ||
import { UserType } from '@/Utils/interface'; | ||
|
||
// http://mockjs.com/examples.html | ||
export default { | ||
'GET /api/ums/account': (req: any, res: any) => | ||
res.json( | ||
success({ | ||
id: 1, | ||
nickname: 'hocgin', | ||
username: 'hocgin', | ||
avatar: Mock.Random.image('100x100'), | ||
}), | ||
), | ||
'POST /api/com/comment/:refType/:refId/like': (req: any, res: any) => | ||
res.json(success(mockData())), | ||
'POST /api/com/comment/:refType/:refId/dislike': (req: any, res: any) => | ||
res.json(success(mockData())), | ||
'POST /api/com/comment/:refType/:refId/report': (req: any, res: any) => | ||
res.json(success(mockData())), | ||
'POST /api/com/comment/:refType/:refId/reply': (req: any, res: any) => | ||
res.json(success(mockData())), | ||
'POST /api/com/comment/:refType/:refId/_scroll': (req: any, res: any) => | ||
res.json( | ||
success({ | ||
nextId: 1, | ||
hasMore: true, | ||
records: [mockData()], | ||
}), | ||
), | ||
'POST /api/com/comment/:refType/:refId/_paging': (req: any, res: any) => | ||
res.json( | ||
success({ | ||
current: 1, | ||
total: 1, | ||
size: 1, | ||
pages: 1, | ||
records: [mockData()], | ||
}), | ||
), | ||
}; | ||
|
||
let mockData = () => { | ||
return Mock.mock({ | ||
id: '@integer()', | ||
replyId: 1, | ||
likes: '@integer(0, 10)', | ||
disliked: '@integer(0, 10)', | ||
action: 'none', | ||
content: '@string()', | ||
hasReply: '@bool()', | ||
author: mockUser(), | ||
replier: mockUser(), | ||
}); | ||
}; | ||
|
||
let mockUser = () => { | ||
return { | ||
id: 1, | ||
title: 'hocgin', | ||
avatarUrl: Mock.Random.image('100x100'), | ||
} as UserType; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { success } from './_utils/result'; | ||
import Mock from 'mockjs'; | ||
|
||
// http://mockjs.com/examples.html | ||
export default { | ||
'POST /api/com/file/upload': (req: any, res: any) => { | ||
return res.json(success(Mock.Random.image('100x100'))); | ||
}, | ||
'GET /api/com/file/upload': (req: any, res: any) => { | ||
return res.json(success(Mock.Random.image('100x100'))); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
7ec7595
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: