-
Notifications
You must be signed in to change notification settings - Fork 93
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
25 changed files
with
4,679 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -2,4 +2,3 @@ node_modules | |
.DS_Store | ||
dist | ||
es | ||
examples |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
.DS_Store | ||
dist | ||
*.local |
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,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite App</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/main.js"></script> | ||
</body> | ||
</html> |
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,17 @@ | ||
export default [ | ||
{ | ||
url: '/api/getRoleById', | ||
method: 'get', | ||
response: ({ query }) => { | ||
console.log('id>>>>>>>>', query.id); | ||
return { | ||
code: 0, | ||
message: 'ok', | ||
data: { | ||
roleName: 'admin', | ||
roleValue: 'admin', | ||
}, | ||
}; | ||
}, | ||
}, | ||
]; |
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,14 @@ | ||
export default [ | ||
{ | ||
url: '/api/createUser', | ||
method: 'post', | ||
response: ({ body }) => { | ||
console.log('body>>>>>>>>', body); | ||
return { | ||
code: 0, | ||
message: 'ok', | ||
data: null, | ||
}; | ||
}, | ||
}, | ||
]; |
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 @@ | ||
{ | ||
"name": "ts-example", | ||
"version": "0.0.0", | ||
"scripts": { | ||
"serve": "cross-env NODE_ENV=development vite", | ||
"build": "cross-env NODE_ENV=production vite build " | ||
}, | ||
"dependencies": { | ||
"axios": "^0.20.0", | ||
"mockjs": "^1.1.0", | ||
"vue": "^3.0.0-rc.1" | ||
}, | ||
"devDependencies": { | ||
"@vue/compiler-sfc": "^3.0.0-rc.1", | ||
"vite": "^1.0.0-rc.1", | ||
"vite-plugin-mock": "^1.0.2" | ||
} | ||
} |
Binary file not shown.
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,34 @@ | ||
<template> | ||
<button @click="getRoleById"> getRoleById</button> | ||
<br /> | ||
<button @click="createUser"> createUser</button> | ||
</template> | ||
|
||
<script> | ||
import { defineComponent } from 'vue'; | ||
import axios from 'axios'; | ||
export default defineComponent({ | ||
name: 'App', | ||
setup() { | ||
const getRoleById = () => { | ||
axios.get('/api/getRoleById', { params: { id: 1 } }).then((res) => { | ||
console.log(res); | ||
}); | ||
}; | ||
const createUser = () => { | ||
axios | ||
.post('/api/createUser', { | ||
name: 'vben', | ||
gender: 'man', | ||
}) | ||
.then((res) => { | ||
console.log(res); | ||
}); | ||
}; | ||
return { | ||
getRoleById, | ||
createUser, | ||
}; | ||
}, | ||
}); | ||
</script> |
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,11 @@ | ||
import { createApp } from 'vue'; | ||
import App from './App.vue'; | ||
// import { setupProdMockServer } from './mockProdServer'; | ||
|
||
createApp(App).mount('#app'); | ||
|
||
// production mock server | ||
// if (process.env.NODE_ENV === 'production') { | ||
// console.log(111); | ||
// setupProdMockServer(); | ||
// } |
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,7 @@ | ||
import { createProdMockServer } from 'vite-plugin-mock/es/createProdMockServer'; | ||
import roleMock from '../mock/role'; | ||
import userMock from '../mock/user'; | ||
|
||
export function setupProdMockServer() { | ||
createProdMockServer([...roleMock, ...userMock]); | ||
} |
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,13 @@ | ||
import { createMockServer } from 'vite-plugin-mock'; | ||
|
||
const config = { | ||
plugins: [ | ||
createMockServer({ | ||
// close support .ts file | ||
supportTs: false, | ||
// default | ||
mockPath: 'mock', | ||
}), | ||
], | ||
}; | ||
export default config; |
Oops, something went wrong.