File tree Expand file tree Collapse file tree 6 files changed +47
-8
lines changed
Expand file tree Collapse file tree 6 files changed +47
-8
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ require('./check-versions')()
22var config = require ( '../config' )
33if ( ! process . env . NODE_ENV ) process . env . NODE_ENV = JSON . parse ( config . dev . env . NODE_ENV )
44var path = require ( 'path' )
5+ var fs = require ( 'fs' )
56var express = require ( 'express' )
67var webpack = require ( 'webpack' )
78var opn = require ( 'opn' )
@@ -44,6 +45,13 @@ Object.keys(proxyTable).forEach(function (context) {
4445 app . use ( proxyMiddleware ( context , options ) )
4546} )
4647
48+ // mock data
49+ var mockDir = path . resolve ( __dirname , '../mock' )
50+ fs . readdirSync ( mockDir ) . forEach ( function ( file ) {
51+ var mock = require ( path . resolve ( mockDir , file ) )
52+ app . use ( mock . api , mock . response )
53+ } )
54+
4755// handle fallback for HTML5 history API
4856app . use ( require ( 'connect-history-api-fallback' ) ( ) )
4957
Original file line number Diff line number Diff line change @@ -22,10 +22,10 @@ module.exports = {
2222 assetsSubDirectory : 'static' ,
2323 assetsPublicPath : '/' ,
2424 proxyTable : {
25- // '/edu_rest/**': {
26- // target: 'http://www /api',
27- // changeOrigin: true
28- // }
25+ '/edu_rest/**' : {
26+ target : 'http://other.domain /api' ,
27+ changeOrigin : true
28+ }
2929 } ,
3030 // CSS Sourcemaps off by default because relative paths are "buggy"
3131 // with this option, according to the CSS-Loader README
Original file line number Diff line number Diff line change 1+ const faker = require ( 'faker' )
2+ faker . locale = 'zh_CN'
3+
4+ module . exports = {
5+ api : '/mock/edu_rest/acquire_campus/:id' ,
6+ response : function ( req , res ) {
7+ res . json ( {
8+ rlt : 'true' ,
9+ msg : 'ok' ,
10+ data : [
11+ { id : faker . random . uuid ( ) , name : faker . random . words ( ) } ,
12+ { id : faker . random . uuid ( ) , name : faker . random . words ( ) } ,
13+ { id : faker . random . uuid ( ) , name : faker . random . words ( ) }
14+ ]
15+ } )
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ const faker = require ( 'faker' )
2+
3+ module . exports = {
4+ api : '/mock/edu_rest/org_login' ,
5+ response : function ( req , res ) {
6+ res . json ( {
7+ rlt : 'true' ,
8+ msg : 'ok' ,
9+ data : faker . random . uuid ( )
10+ } )
11+ }
12+ }
Original file line number Diff line number Diff line change 11{
2- "name" : " vue-project-demo " ,
2+ "name" : " vue-spa-project " ,
33 "version" : " 1.0.0" ,
4- "description" : " 教务系统 Demo" ,
4+ "description" : " 基于Vue.js技术栈的教务管理系统 Demo" ,
55 "author" : " super_xp@126.com" ,
66 "private" : true ,
77 "scripts" : {
5656 "eventsource-polyfill" : " ^0.9.6" ,
5757 "express" : " ^4.14.0" ,
5858 "extract-text-webpack-plugin" : " ^1.0.1" ,
59+ "faker" : " ^4.0.0" ,
5960 "file-loader" : " ^0.9.0" ,
6061 "friendly-errors-webpack-plugin" : " ^1.1.2" ,
6162 "function-bind" : " ^1.1.0" ,
Original file line number Diff line number Diff line change 22 * 接口配置
33 */
44
5- // const BaseUrl = 'http://www/api'
6- const BaseUrl = '' // for local proxy
5+ // const BaseUrl = 'http://www/api' // for production
6+ // const BaseUrl = '' // for local poxy
7+ const BaseUrl = '/mock' // for local mock test
78
89export const LOGIN = BaseUrl + '/edu_rest/org_login' // 登录
910export const REGIST = BaseUrl + '/edu_rest/org_register' // 注册
You can’t perform that action at this time.
0 commit comments