Skip to content

Commit

Permalink
v1完成
Browse files Browse the repository at this point in the history
  • Loading branch information
Ljhhhhhh committed Oct 26, 2019
1 parent 68e52f9 commit 82177e9
Show file tree
Hide file tree
Showing 34 changed files with 1,227 additions and 150 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NODE_ENV = 'development'
BASE_URL = '/'
VUE_APP_BASE_API = ''
VUE_APP_BASE_API = '/dev-api'
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VUE_CLI_BABEL_TRANSPILE_MODULES = true
NODE_ENV = 'development'
BASE_URL = '/'
VUE_APP_BASE_API = ''
VUE_APP_BASE_API = '/dev-api'
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NODE_ENV = 'production'
BASE_URL = './'
VUE_APP_BASE_API = 'https://easy-mock.com/'
VUE_APP_BASE_API = '/prod-api'
53 changes: 25 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
# vue-cli-h5
- [x] 自动注册路由表
- [x] 自动注册Vuex
- [x] 鉴权处理、登录拦截
- [x] 页面切换动画
- [x] 常用目录别名
- [x] Vant
- [x] Rem适配
- [x] 全局scss
- [x] 页面Title
- [x] axios封装
- [x] mock-server
- [x] SVG图标组件
- [x] 通用登录页面
- [x] 通用列表页(集成vo-pages)
- [x] V-console
- [x] Dayjs?
- [x] 跨域处理
- [x] 404页面
- [x] Lazyload
### 线上环境优化

## Project setup
```
yarn install
```

### Compiles and hot-reloads for development
```
yarn run serve
```

### Compiles and minifies for production
```
yarn run build
```

### Run your tests
```
yarn run test
```

### Lints and fixes files
```
yarn run lint
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
- [x] CDN引入
- [x] 资源压缩
- [x] console.log去除
- [x] gzip
- [x] 关闭 sourcemap
6 changes: 3 additions & 3 deletions mock/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ for (let i = 0; i < count; i++) {
export default [
{
url: '/article/list',
type: 'get',
type: 'post',
response: config => {
const { importance, type, title, page = 1, limit = 20, sort } = config.query
const { importance, type, title, page = 1, pageSize = 20, sort } = config.body

let mockList = List.filter(item => {
if (importance && item.importance !== +importance) return false
Expand All @@ -45,7 +45,7 @@ export default [
mockList = mockList.reverse()
}

const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1))
const pageList = mockList.filter((item, index) => index < pageSize * page && index >= pageSize * (page - 1))

return {
code: 200,
Expand Down
5 changes: 4 additions & 1 deletion mock/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import Mock from 'mockjs'
import { param2Obj } from '../src/utils'

import user from './user'
import role from './role'
import article from './article'
import search from './remote-search'

const mocks = [
...user,
...role,
...article,
...search
]
Expand Down Expand Up @@ -63,6 +65,7 @@ const responseFake = (url, type, respond) => {
}
}

export default mocks.map(route => {
const d = mocks.map(route => {
return responseFake(route.url, route.type, route.response)
})
export default d
4 changes: 2 additions & 2 deletions mock/remote-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default [
return !(name && lowerCaseName.indexOf(name.toLowerCase()) < 0)
})
return {
code: 20000,
code: 200,
data: { items: mockNameList }
}
}
Expand All @@ -34,7 +34,7 @@ export default [
type: 'get',
response: _ => {
return {
code: 20000,
code: 200,
data: {
total: 20,
'items|20': [{
Expand Down
98 changes: 98 additions & 0 deletions mock/role/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import Mock from 'mockjs'
import { deepClone } from '../../src/utils/index.js'
import { asyncRoutes, constantRoutes } from './routes.js'

const routes = deepClone([...constantRoutes, ...asyncRoutes])

const roles = [
{
key: 'admin',
name: 'admin',
description: 'Super Administrator. Have access to view all pages.',
routes: routes
},
{
key: 'editor',
name: 'editor',
description: 'Normal Editor. Can see all pages except permission page',
routes: routes.filter(i => i.path !== '/permission')// just a mock
},
{
key: 'visitor',
name: 'visitor',
description: 'Just a visitor. Can only see the home page and the document page',
routes: [{
path: '',
redirect: 'dashboard',
children: [
{
path: 'dashboard',
name: 'Dashboard',
meta: { title: 'dashboard', icon: 'dashboard' }
}
]
}]
}
]

export default [
// mock get all routes form server
{
url: '/routes',
type: 'get',
response: _ => {
return {
code: 200,
data: routes
}
}
},

// mock get all roles form server
{
url: '/roles',
type: 'get',
response: _ => {
return {
code: 200,
data: roles
}
}
},

// add role
{
url: '/role',
type: 'post',
response: {
code: 200,
data: {
key: Mock.mock('@integer(300, 5000)')
}
}
},

// update role
{
url: '/role/[A-Za-z0-9]',
type: 'put',
response: {
code: 200,
data: {
status: 'success'
}
}
},

// delete role
{
url: '/role/[A-Za-z0-9]',
type: 'delete',
response: {
code: 200,
data: {
status: 'success'
}
}
}
]
Loading

0 comments on commit 82177e9

Please sign in to comment.