-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
435 additions
and
0 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 @@ | ||
VUE_APP_API='./api/' |
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 @@ | ||
VUE_APP_API='https://wx.redrock.team//' |
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 @@ | ||
VUE_APP_API='https://wx.redrock.team/cq_impress/' |
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 @@ | ||
VUE_APP_API='https://wx.redrock.team//' |
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,71 @@ | ||
import Vue from "vue"; | ||
import axios from "axios"; | ||
import VueAxios from "vue-axios"; | ||
import JwtService from "@/common/service/jwt"; | ||
import { API_URL } from "@/common/config"; | ||
|
||
const ApiService = { | ||
init () { | ||
Vue.use(VueAxios, axios) | ||
Vue.axios.defaults.baseURL = API_URL | ||
this.setHeader() | ||
this.setFormat() | ||
}, | ||
|
||
setHeader () { | ||
Vue.axios.defaults.headers.common[ | ||
"Authorization" | ||
] = `Token ${JwtService.getToken()}`; | ||
}, | ||
setFormat(){ | ||
Vue.axios.defaults.headers.post[ | ||
'Content-Type' | ||
] = 'application/x-www-form-urlencoded' | ||
}, | ||
|
||
get (resource) { | ||
return Vue.axios.get(resource).catch(error => { | ||
throw new Error(`[RWV] ApiService ${error}`); | ||
}); | ||
}, | ||
|
||
post (resource, params) { | ||
return Vue.axios.post(`${resource}`, params); | ||
}, | ||
|
||
patch (resource, params) { | ||
return Vue.axios.patch(resource, params); | ||
}, | ||
|
||
put (resource, params) { | ||
return Vue.axios.put(resource, params); | ||
}, | ||
|
||
delete (resource) { | ||
return Vue.axios.delete(resource).catch(error => { | ||
throw new Error(`[RWV] ApiService ${error}`); | ||
}); | ||
} | ||
}; | ||
|
||
export default ApiService; | ||
|
||
export const ResultService = { | ||
getFirstAnswer (params) { | ||
return ApiService.post(`answer`,params) | ||
}, | ||
|
||
getOldAnswer(){ | ||
return ApiService.post(`answered`,) | ||
} | ||
} | ||
|
||
//openid 放在头部 得到是否为初次测试的结果 | ||
//返回参数为 judgement ==0 初次答题 ==1 不是第一次答题 | ||
export const JudgeService = { | ||
getJudge(){ | ||
return ApiService.post(`main`) | ||
} | ||
} | ||
|
||
|
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,61 @@ | ||
import Vue from "vue"; | ||
import axios from "axios"; | ||
import VueAxios from "vue-axios"; | ||
import JwtService from "@/common/service/jwt"; | ||
import { API_URL } from "@/common/config"; | ||
|
||
const ApiService = { | ||
init() { | ||
Vue.use(VueAxios, axios) | ||
Vue.axios.defaults.baseURL = API_URL | ||
this.setHeader() | ||
this.setFormat() | ||
}, | ||
|
||
setHeader() { | ||
Vue.axios.defaults.headers.common[ | ||
"Authorization" | ||
] = `Token ${JwtService.getToken()}`; | ||
}, | ||
setFormat() { | ||
Vue.axios.defaults.headers.post[ | ||
'Content-Type' | ||
] = 'application/x-www-form-urlencoded' | ||
}, | ||
|
||
get(resource) { | ||
return Vue.axios.get(resource).catch(error => { | ||
throw new Error(`[RWV] ApiService ${error}`); | ||
}); | ||
}, | ||
|
||
post(resource, params) { | ||
return Vue.axios.post(`${resource}`, params); | ||
}, | ||
|
||
patch(resource, params) { | ||
return Vue.axios.patch(resource, params); | ||
}, | ||
|
||
put(resource, params) { | ||
return Vue.axios.put(resource, params); | ||
}, | ||
|
||
delete(resource) { | ||
return Vue.axios.delete(resource).catch(error => { | ||
throw new Error(`[RWV] ApiService ${error}`); | ||
}); | ||
} | ||
}; | ||
|
||
export default ApiService; | ||
|
||
export const ResultService = { | ||
getFirstAnswer(params) { | ||
return ApiService.post(`answer`, params) | ||
}, | ||
|
||
} | ||
|
||
|
||
|
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 @@ | ||
import Vue from 'vue' | ||
import App from './App.vue' | ||
import router from './router' | ||
import store from './store' | ||
import axios from 'axios' | ||
import ApiService from './common/service/api' | ||
|
||
import './assets/styles/common.css' | ||
import './assets/font/font.css' | ||
|
||
Vue.prototype.$axios = axios; | ||
Vue.config.productionTip = false | ||
|
||
new Vue({ | ||
router, | ||
store, | ||
render: h => h(App) | ||
}).$mount('#app') |
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,20 @@ | ||
import Vue from 'vue' | ||
import App from './App.vue' | ||
import router from './router' | ||
import store from './store' | ||
import axios from 'axios' | ||
import ApiService from './common/service/api' | ||
|
||
import './assets/styles/common.css' | ||
import './assets/font/font.css' | ||
|
||
Vue.prototype.$axios = axios; | ||
Vue.config.productionTip = false | ||
|
||
ApiService.init() | ||
|
||
new Vue({ | ||
router, | ||
store, | ||
render: h => h(App) | ||
}).$mount('#app') |
Empty file.
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,88 @@ | ||
|
||
|
||
module.exports = { | ||
port: 8080, | ||
before(app) { | ||
// search | ||
app.get('/api/search/hot', (req, res) => { | ||
res.json(searchHot) | ||
}) | ||
app.get('/api/search/questions*', (req, res) => { | ||
res.json(questions) | ||
}) | ||
// questions | ||
app.get('/api/questions', (req, res) => { | ||
res.json(questions) | ||
}) | ||
app.post('/api/questions', (req, res) => { | ||
res.sendStatus(201) | ||
res.json(question) | ||
}) | ||
app.get('/api/questions/tag/*', (req, res) => { | ||
res.json(questions) | ||
}) | ||
app.get('/api/questions/*', (req, res) => { | ||
res.json(questionAndAnswer) | ||
}) | ||
app.patch('/api/questions/*', (req, res) => { | ||
res.sendStatus(201) | ||
res.json(question) | ||
}) | ||
app.delete('/api/questions/*', (req, res) => { | ||
res.sendStatus(204) | ||
res.text('') | ||
}) | ||
|
||
// 回答 | ||
app.post('/api/questions/*/answer', (req, res) => { | ||
res.sendStatus(201) | ||
res.json(answer) | ||
}) | ||
|
||
app.delete('/api/answers/*', (req, res) => { | ||
res.sendStatus(204) | ||
res.text('') | ||
}) | ||
|
||
app.post('/api/answers/*/approval', (req, res) => { | ||
res.json(api) | ||
}), | ||
app.post('/api/answers/*/oppose', (req, res) => { | ||
res.json(api) | ||
}) | ||
|
||
// tags | ||
app.get('/api/tags/hot', (req, res) => { | ||
res.json(tagHot) | ||
}) | ||
|
||
// 图片 | ||
app.post('/api/image', (req, res) => { | ||
res.sendStatus(201) | ||
res.json(image) | ||
}) | ||
|
||
app.post('/api/image/delete', (req, res) => { | ||
res.sendStatus(204) | ||
res.text('/api') | ||
}) | ||
|
||
// 用户 | ||
app.get('/api/user/questions', (req, res) => { | ||
res.json(questions) | ||
}) | ||
|
||
app.get('/api/user/answers*', (req, res) => { | ||
res.json(answers) | ||
}) | ||
|
||
app.get('/api/user', (req, res) => { | ||
if (Math.floor(Math.random() * 10) % 2) { | ||
res.json(userNew) | ||
} else { | ||
res.json(userOld) | ||
} | ||
|
||
}) | ||
} | ||
} |
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,87 @@ | ||
|
||
|
||
module.exports = { | ||
before(app) { | ||
// search | ||
app.get('/api/search/hot', (req, res) => { | ||
res.json(searchHot) | ||
}) | ||
app.get('/api/search/questions*', (req, res) => { | ||
res.json(questions) | ||
}) | ||
// questions | ||
app.get('/api/questions', (req, res) => { | ||
res.json(questions) | ||
}) | ||
app.post('/api/questions', (req, res) => { | ||
res.sendStatus(201) | ||
res.json(question) | ||
}) | ||
app.get('/api/questions/tag/*', (req, res) => { | ||
res.json(questions) | ||
}) | ||
app.get('/api/questions/*', (req, res) => { | ||
res.json(questionAndAnswer) | ||
}) | ||
app.patch('/api/questions/*', (req, res) => { | ||
res.sendStatus(201) | ||
res.json(question) | ||
}) | ||
app.delete('/api/questions/*', (req, res) => { | ||
res.sendStatus(204) | ||
res.text('') | ||
}) | ||
|
||
// 回答 | ||
app.post('/api/questions/*/answer', (req, res) => { | ||
res.sendStatus(201) | ||
res.json(answer) | ||
}) | ||
|
||
app.delete('/api/answers/*', (req, res) => { | ||
res.sendStatus(204) | ||
res.text('') | ||
}) | ||
|
||
app.post('/api/answers/*/approval', (req, res) => { | ||
res.json(api) | ||
}), | ||
app.post('/api/answers/*/oppose', (req, res) => { | ||
res.json(api) | ||
}) | ||
|
||
// tags | ||
app.get('/api/tags/hot', (req, res) => { | ||
res.json(tagHot) | ||
}) | ||
|
||
// 图片 | ||
app.post('/api/image', (req, res) => { | ||
res.sendStatus(201) | ||
res.json(image) | ||
}) | ||
|
||
app.post('/api/image/delete', (req, res) => { | ||
res.sendStatus(204) | ||
res.text('/api') | ||
}) | ||
|
||
// 用户 | ||
app.get('/api/user/questions', (req, res) => { | ||
res.json(questions) | ||
}) | ||
|
||
app.get('/api/user/answers*', (req, res) => { | ||
res.json(answers) | ||
}) | ||
|
||
app.get('/api/user', (req, res) => { | ||
if (Math.floor(Math.random() * 10) % 2) { | ||
res.json(userNew) | ||
} else { | ||
res.json(userOld) | ||
} | ||
|
||
}) | ||
} | ||
} |
Empty file.
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 @@ | ||
export const API_URL = process.env.VUE_APP_API |
Oops, something went wrong.