Skip to content

Commit

Permalink
feat: 添加mock能力与替换yarn为pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
sdmu-gaoqi committed Jan 18, 2024
1 parent 4982c10 commit 2c05a0b
Show file tree
Hide file tree
Showing 20 changed files with 7,769 additions and 5,836 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
│   ├── menu.ts // 菜单配置
│   ├── route.ts // route配置
│   ├── utils // 工具函数集合
│   ├── mock // mock接口
│   └── logo.svg
├── index.html
├── package.json
Expand Down Expand Up @@ -104,6 +105,10 @@ export type WAMenu = (ItemType & {
## 关于环境
不同环境配置再 env目录下
不同环境配置在 env目录下
注意 暴露给页面使用的需要加VITE前缀
package里有不同环境的打包方式
## 关于mock
mock预设为 test 与 prod(根据import.meta.env.MODE 决定 prod模式时 使用的是prod文件下的mock 其他的都是用的test下的mock)
需要增加更多环境支持可以在 mock/index.ts修改
2 changes: 1 addition & 1 deletion env/.env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NODE_ENV: development
VITE_BASE_REQUEST: https: //store-operations-admin-dev.yuque.com
VITE_BASE_REQUEST: /
2 changes: 1 addition & 1 deletion env/.env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NODE_ENV: production
VITE_BASE_REQUEST: https: //store-operations-admin.yuque.com
VITE_BASE_REQUEST: https://store-operations-admin.yuque.com
2 changes: 1 addition & 1 deletion env/.env.staging
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NODE_ENV: production
VITE_BASE_REQUEST: https: //store-operations-admin-staging.yuque.com
VITE_BASE_REQUEST: https://store-operations-admin-staging.yuque.com
2 changes: 1 addition & 1 deletion env/.env.test
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NODE_ENV: production
VITE_BASE_REQUEST: https: //store-operations-admin-test.yuque.com
VITE_BASE_REQUEST: https://store-operations-admin-test.yuque.com
Empty file added mock/prod/user.ts
Empty file.
33 changes: 33 additions & 0 deletions mock/test/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { MockMethod } from 'vite-plugin-mock'

// @ts-ignore
const testMock: MockMethod = [
{
url: '/api/login',
method: 'post',
timeout: 1000,
response: ({ data }: any) => {
console.log('登录请求数据 =>', data)
return {
code: 0,
data: {
token: 'thisIsToken'
}
}
}
},
{
url: '/api/perm',
method: 'post',
timeout: 1000,
response: ({ data }: any) => {
console.log('登录请求数据 =>', data)
return {
code: 0,
data: ['perm-1']
}
}
}
]

export default testMock
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build:test": "vue-tsc && vite build --mode test",
"build:pre": "vue-tsc && vite build --mode staging",
"build:dev": "vue-tsc && vite build --mode development",
"dev": "vite",
"dev": "pnpm vite",
"preview": "vite preview",
"prepare": "husky install",
"prettier": "prettier -c --write **/*",
Expand Down Expand Up @@ -48,10 +48,12 @@
"@types/vue": "^2.0.0",
"add": "^2.0.6",
"ant-design-vue": "^4.0.0",
"axios": "^1.6.5",
"babel-eslint": "^10.1.0",
"dayjs": "^1.11.10",
"echarts": "^5.4.3",
"eslint-plugin-import": "^2.25.2",
"mockjs": "^1.1.0",
"path": "^0.12.7",
"postcss": "^8.0.0",
"prettier": "^3.0.0",
Expand Down Expand Up @@ -81,13 +83,15 @@
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-vue": "^9.17.0",
"glob": "^10.3.10",
"husky": "^8.0.3",
"lint-staged": "^13.0.3",
"stylelint": "^15.10.2",
"stylelint-config-standard-scss": "^10.0.0",
"tailwindcss": "^3.3.3",
"typescript": "*",
"vite": "^4.4.7",
"vite-plugin-mock": "^2.9.6",
"vite-svg-loader": "^4.0.0",
"vue-tsc": "^1.8.5",
"wa-postcss-pxtorem": "^0.0.1"
Expand Down
Loading

0 comments on commit 2c05a0b

Please sign in to comment.