Skip to content

Commit

Permalink
使用 Mock 添加接口测试数据
Browse files Browse the repository at this point in the history
  • Loading branch information
fengzifz committed Apr 3, 2019
1 parent dc18fa0 commit fcdcec4
Show file tree
Hide file tree
Showing 16 changed files with 2,053 additions and 921 deletions.
5 changes: 3 additions & 2 deletions config/dev.env.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ const prodEnv = require('./prod.env')

module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
HOST: '"http://ganttask.damon.com"',
HOST: '""',
BASE_PATH: '"http://localhost:8080"',
EDITOR_IMG_UPLOAD: '"http://ganttask.damon.com/api/v1/task/upload"',
VERSION: '"v1.0.4"'
VERSION: '"v1.0.4"',
Mock: true
})
3 changes: 2 additions & 1 deletion config/prod.env.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
VER: '"v1.0.4"',
HOST: '"https://xxxxxx"', // API 地址
BASE_PATH: '"https://xxxxx"', // 前端地址
EDITOR_IMG_UPLOAD: '"https://xxxxx"' // 上传 API
EDITOR_IMG_UPLOAD: '"https://xxxxx"', // 上传 API
Mock: false
}

2,724 changes: 1,851 additions & 873 deletions package-lock.json

Large diffs are not rendered by default.

59 changes: 30 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@
},
"dependencies": {
"axios": "^0.18.0",
"element-ui": "^2.4.5",
"element-ui": "^2.7.0",
"font-awesome": "^4.7.0",
"frappe-gantt": "fengzifz/gantt#master",
"node-sass": "^4.9.2",
"quill-image-extend-module": "fengzifz/quill-image-extend-module#master",
"sass-loader": "^7.0.1",
"vue": "^2.5.2",
"vue-axios": "^2.1.2",
"frappe-gantt": "github:fengzifz/gantt#master",
"node-sass": "^4.11.0",
"quill-image-extend-module": "github:fengzifz/quill-image-extend-module#master",
"sass-loader": "^7.1.0",
"vue": "^2.6.10",
"vue-axios": "^2.1.4",
"vue-quill-editor": "^3.0.6",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
"vue-router": "^3.0.2",
"vuex": "^3.1.0"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-eslint": "^8.2.1",
"babel-eslint": "^8.2.6",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-jest": "^21.0.2",
"babel-loader": "^7.1.1",
"babel-loader": "^7.1.5",
"babel-plugin-dynamic-import-node": "^1.2.0",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
Expand All @@ -42,48 +42,49 @@
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chalk": "^2.0.1",
"chromedriver": "^2.27.2",
"copy-webpack-plugin": "^4.0.1",
"chalk": "^2.4.2",
"chromedriver": "^2.46.0",
"copy-webpack-plugin": "^4.6.0",
"cross-spawn": "^5.0.1",
"css-loader": "^0.28.0",
"eslint": "^4.15.0",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.0.0",
"eslint-plugin-vue": "^4.7.1",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"jest": "^22.0.4",
"jest-serializer-vue": "^0.3.0",
"nightwatch": "^1.0.6",
"node-notifier": "^5.1.2",
"mockjs": "^1.0.1-beta3",
"nightwatch": "^1.0.19",
"node-notifier": "^5.4.0",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"portfinder": "^1.0.20",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"postcss-loader": "^2.1.6",
"postcss-url": "^7.2.1",
"rimraf": "^2.6.0",
"selenium-server": "^3.0.1",
"semver": "^5.3.0",
"rimraf": "^2.6.3",
"selenium-server": "^3.141.59",
"semver": "^5.7.0",
"shelljs": "^0.7.6",
"uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^1.0.1",
"uglifyjs-webpack-plugin": "^1.3.0",
"url-loader": "^1.1.2",
"vue-jest": "^1.0.2",
"vue-loader": "^13.3.0",
"vue-loader": "^13.7.3",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"vue-template-compiler": "^2.6.10",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.9.1",
"webpack-merge": "^4.1.0"
"webpack-dev-server": "^2.11.5",
"webpack-merge": "^4.2.1"
},
"engines": {
"node": ">= 6.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<el-col :span="24">
<router-link :to="'/personal/settings'">
<div class="avatar">
<img :src="host + '/storage/' + this.userAvatar" />
<img :src="userAvatar" />
</div>
<div class="username">{{ name || '点击修改昵称' }}</div>
</router-link>
Expand Down Expand Up @@ -85,7 +85,7 @@ export default {
return {
loading: false,
version: process.env.VER,
host: process.env.HOST
host: process.env.BASE_PATH
}
},
computed: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/GantChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export default {
target: '#task-item-' + tid,
spinner: 'el-icon-loading'
})
axios.post('task/update_general', {
axios.post('/task/update_general', {
api_token: this.apiToken,
executor_id: executorId,
progress: progress,
Expand Down
4 changes: 2 additions & 2 deletions src/components/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export default {
methods: {
login: function () {
this.loading = true
axios.post('user/login', {
app_key: 'xxxxxxxxxx',
axios.post('/user/login', {
email: this.userInfo.email,
password: this.userInfo.password
}).then((res) => {
console.log(res)
if (res.data.error) {
this.$message.error(res.data.message)
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/components/ProjectMembers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<el-col :span="3" v-for="(item, index) in proMembers" :key="index">
<el-card :body-style="{padding: '10px'}" shadow="hover" class="member-wrap">
<div class="member-avatar">
<img :src="host + '/storage/' + item.avatar " />
<img :src="'/static/n.png'" />
</div>
<div class="member-name">
{{ item.name }}
Expand Down Expand Up @@ -107,7 +107,7 @@ export default {
this.diaLoading = true
let token = this.apiToken
let tid = this.teamId
axios.get('team/get_team_users?api_token=' + token + '&team_id=' + tid).then(res => {
axios.get('/team/get_team_users?api_token=' + token + '&team_id=' + tid).then(res => {
if (res.data.error) {
this.$message.error(res.data.message)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Projects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default {
},
getAllProjects: function () {
this.allLoading = true
axios.get('project/get_all?api_token=' + this.apiToken + '&team_id=' + this.currentTeamId)
axios.get('/project/get_all?api_token=' + this.apiToken + '&team_id=' + this.currentTeamId)
.then((res) => {
if (res.data.error) {
this.$message.error(res.data.message)
Expand Down
6 changes: 3 additions & 3 deletions src/components/Task.vue
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ export default {
this.loading = true
let pid = this.currentProjectId
let tid = this.currentTeamId
axios.get('task/get_tasks?api_token=' + this.apiToken + '&project_id=' + pid + '&team_id=' + tid).then((res) => {
axios.get('/task/get_tasks?api_token=' + this.apiToken + '&project_id=' + pid + '&team_id=' + tid).then((res) => {
if (res.data.error) {
this.$message.error(res.data.message)
} else {
Expand All @@ -369,7 +369,7 @@ export default {
},
getMembers: function () {
// 获取项目的所有成员
axios.get('project/get_members?api_token=' + this.apiToken +
axios.get('/project/get_members?api_token=' + this.apiToken +
'&project_id=' + this.currentProjectId + '&team_id=' + this.currentTeamId)
.then((res) => {
if (res.data.error) {
Expand All @@ -382,7 +382,7 @@ export default {
addNewTask: function () {
// 添加新任务
this.addTaskLoading = true
axios.post('task/create', {
axios.post('/task/create', {
project_id: this.currentProjectId,
team_id: this.currentTeamId,
name: this.newTask.name,
Expand Down
2 changes: 1 addition & 1 deletion src/components/TaskCompleted.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default {
methods: {
getCompletedTasks: function () {
this.loading = true
axios.get('task/get_completed?api_token=' + this.apiToken + '&team_id=' + this.tid +
axios.get('/task/get_completed?api_token=' + this.apiToken + '&team_id=' + this.tid +
'&project_id=' + this.pid).then(res => {
if (res.data.error) {
this.$message.error(res.data.message)
Expand Down
2 changes: 1 addition & 1 deletion src/components/TaskDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default {
// 根据 id 获取任务信息
this.loading = true
let tid = this.$route.params.id
axios.get('task/get?api_token=' + this.apiToken + '&project_id=' + this.currentProjectId +
axios.get('/task/get?api_token=' + this.apiToken + '&project_id=' + this.currentProjectId +
'&team_id=' + this.currentTeamId + '&id=' + tid).then((res) => {
if (res.data.error) {
this.$message.error(res.data.message)
Expand Down
4 changes: 2 additions & 2 deletions src/components/Team.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default {
},
getUserTeams: function () {
this.loading = true
axios.get('team/get_user_teams?api_token=' + this.apiToken)
axios.get('/team/get_user_teams?api_token=' + this.apiToken)
.then((res) => {
if (res.data.error) {
this.$message.error(res.data.message)
Expand All @@ -83,7 +83,7 @@ export default {
},
create: function () {
this.loading = true
axios.post('team/create', {
axios.post('/team/create', {
name: this.newTeam.name,
api_token: this.apiToken
}).then((res) => {
Expand Down
4 changes: 3 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

axios.defaults.baseURL = process.env.HOST + '/api/v1/'
process.env.Mock && require('./mock/index')

axios.defaults.baseURL = process.env.HOST + '/'
axios.defaults.headers = {
'Accept': 'Application/json',
'Access-Control-Allow-Origin': '*',
Expand Down
Loading

0 comments on commit fcdcec4

Please sign in to comment.