Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2050178

Browse files
committed
Merge branch 'feature/template' into develop
2 parents 6d8c815 + 421803e commit 2050178

File tree

36 files changed

+1546
-17
lines changed

36 files changed

+1546
-17
lines changed

‎generator.js

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,49 @@ const fs = require('fs')
33
const removeFiles = (files = []) => {
44
files.forEach(path => {
55
if (fs.existsSync(path)) {
6-
fs.unlinkSync(path);
6+
fs.unlinkSync(path)
77
}
88
})
99
}
1010

11+
const filesToRemove = [
12+
'src/components/HelloWorld.vue',
13+
'src/router.js',
14+
'src/store.js'
15+
]
16+
17+
const importsToRemove = [
18+
`import store from './store'`,
19+
`import router from './router'`
20+
]
21+
1122
module.exports = (api, options, rootOptions) => {
23+
const {
24+
entryFile,
25+
generator: { imports }
26+
} = api
27+
1228
api.extendPackage({
1329
dependencies: {
14-
'element-ui': '^2.4.11'
15-
},
30+
'element-ui': '^2.4.11',
31+
'vuex-router-sync': '^5.0.0'
32+
}
1633
})
1734

18-
api.injectImports(api.entryFile, `import './registerElementUI'`)
35+
// api.injectImports(entryFile, `import './registerElementUI'`)
36+
37+
// Remove the default imports generated by vue-cli
38+
if (imports[entryFile]) {
39+
importsToRemove.forEach(itr => imports[entryFile].delete(itr))
40+
}
1941

42+
// Remove the default files generated by vue-cli
43+
api.render(function(files) {
44+
filesToRemove.forEach(ftr => delete files[ftr])
45+
})
2046
api.render('./template/structure')
2147

2248
api.onCreateComplete(() => {
23-
removeFiles([
24-
api.resolve('src/components/HelloWorld.vue')
25-
])
49+
removeFiles(filesToRemove.map(ftr => api.resolve(ftr)))
2650
})
2751
}

‎preset.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
"@vue/cli-plugin-babel": {},
55
"@vue/cli-plugin-pwa": {},
66
"@vue/cli-plugin-eslint": {
7-
"config": "airbnb",
8-
"lintOn": [
9-
"save"
10-
]
7+
"config": "standard",
8+
"lintOn": ["save"]
119
},
1210
"@vue/cli-plugin-unit-jest": {}
1311
},

‎template/structure/src/App.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<template>
2+
<div id="app">
3+
<router-view/>
4+
</div>
5+
</template>
6+
7+
<style lang="scss">
8+
</style>
9+
10+
<script>
11+
export default {
12+
name: 'App'
13+
}
14+
</script>

‎template/structure/src/api/index.js

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { delay, checkCode } from '@/utils/request'
2+
3+
/* start of mocking user */
4+
const users = {
5+
admin: {
6+
id: 100001,
7+
name: 'Administrator',
8+
roles: ['USER', 'ADMIN']
9+
},
10+
codetrial: {
11+
id: 100001,
12+
name: 'Codetrial',
13+
roles: ['USER']
14+
}
15+
}
16+
17+
export async function getUser(username) {
18+
await delay(200)
19+
20+
const user = users[username]
21+
const response = user
22+
? {
23+
status: '1',
24+
data: user
25+
}
26+
: {
27+
status: '1100',
28+
message: 'Wrong user or password'
29+
}
30+
31+
return Promise.resolve(response).then(checkCode)
32+
}
33+
/* end of mocking user */
34+
35+
/* start of mocking example list */
36+
const exampleSource = Array(235)
37+
.fill(1)
38+
.map((element, index) => {
39+
const personal = index % 2 === 0
40+
return {
41+
id: index + 10000,
42+
name: `Example - ${index} - ${personal ? 'felixpy' : 'codetrial'}`,
43+
type: personal ? 1 : 2,
44+
status: index % 5 === 0 ? 0 : 1,
45+
url: personal ? 'https://felixpy.com' : 'https://codetrial.github.io',
46+
createUser: 100001,
47+
createUserName: 'Felix Yang',
48+
updateUser: 100001,
49+
updateUserName: 'Felix Yang',
50+
createTime: '2018年12月22日 11:00:00',
51+
updateTime: '2018年12月22日 11:00:00'
52+
}
53+
})
54+
55+
export async function getExampleList({ filter = {}, page = {} }) {
56+
const { pageNo = 1, pageSize = 20 } = page
57+
const offset = (pageNo - 1) * pageSize
58+
let list = exampleSource
59+
let total = exampleSource.length
60+
61+
// filter
62+
Object.keys(filter).forEach(key => {
63+
const filterValue = filter[key]
64+
if (filterValue != null && filterValue.length) {
65+
list = list.filter(item => {
66+
if (Array.isArray(filterValue)) {
67+
return filterValue.map(String).indexOf(String(item[key])) > -1
68+
}
69+
return String(item[key]) === String(filterValue)
70+
})
71+
}
72+
})
73+
74+
total = list.length
75+
76+
// sort
77+
list = list.sort((a, b) => {
78+
const { order, orderBy } = page
79+
80+
if (!order || !orderBy) {
81+
return
82+
}
83+
84+
const diff = (order === 'descending' ? -1 : 1) * (a[orderBy] - b[orderBy])
85+
return diff > 0 ? 1 : -1
86+
})
87+
88+
// pagination
89+
list = list.slice(offset, offset + pageSize)
90+
91+
await delay(1000)
92+
93+
return Promise.resolve({
94+
status: '1',
95+
data: {
96+
list,
97+
page: {
98+
...page,
99+
total
100+
}
101+
}
102+
}).then(checkCode)
103+
}
104+
/* end of mocking example list */
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<div class="error-page">
3+
<div class="error-page__tip">403 Forbidden</div>
4+
</div>
5+
</template>
6+
7+
<style lang="scss" scoped>
8+
@import './index';
9+
</style>
10+
11+
<script>
12+
export default {
13+
name: 'Forbidden'
14+
}
15+
</script>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<div class="error-page">
3+
<div class="error-page__tip">404 Not Found</div>
4+
</div>
5+
</template>
6+
7+
<style lang="scss" scoped>
8+
@import './index';
9+
</style>
10+
11+
<script>
12+
export default {
13+
name: 'NotFound'
14+
}
15+
</script>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<div class="error-page">
3+
<div class="error-page__tip">500 Internal Server Error</div>
4+
</div>
5+
</template>
6+
7+
<style lang="scss" scoped>
8+
@import './index';
9+
</style>
10+
11+
<script>
12+
export default {
13+
name: 'InternalServerError'
14+
}
15+
</script>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Forbidden from './403.vue'
2+
import NotFound from './404.vue'
3+
import InternalServerError from './500.vue'
4+
5+
export { Forbidden, NotFound, InternalServerError }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.error-page {
2+
padding: 100px 0;
3+
4+
.error-page__tip {
5+
font-size: 48px;
6+
font-weight: bold;
7+
text-align: center;
8+
}
9+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<template>
2+
<div class="breadcrumb" v-if="breadcrumb">
3+
<el-breadcrumb separator-class="el-icon-arrow-right">
4+
<template v-for="item in breadcrumb">
5+
<el-breadcrumb-item
6+
v-if="item.path"
7+
:key="item.name"
8+
:to="{ path: item.path }"
9+
>{{ item.name }}</el-breadcrumb-item>
10+
<el-breadcrumb-item v-else :key="item.name">{{ item.name }}</el-breadcrumb-item>
11+
</template>
12+
</el-breadcrumb>
13+
</div>
14+
</template>
15+
16+
<style lang="scss" scoped>
17+
.breadcrumb {
18+
margin-top: 10px;
19+
margin-bottom: 30px;
20+
}
21+
</style>
22+
23+
<script>
24+
import { mapState } from 'vuex'
25+
26+
export default {
27+
name: 'AppBreadcrumb',
28+
29+
computed: {
30+
...mapState({
31+
breadcrumb: state => {
32+
const { breadcrumb } = state.route.meta
33+
34+
if (breadcrumb) {
35+
return breadcrumb.map(item => {
36+
if (typeof item === 'string') {
37+
const [name, path = null] = item.split(' ')
38+
return {
39+
name,
40+
path
41+
}
42+
}
43+
return item
44+
})
45+
}
46+
47+
return null
48+
},
49+
route: 'route'
50+
})
51+
}
52+
}
53+
</script>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /