Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
felixpy committed Dec 23, 2018
1 parent 2334574 commit 6aa2ba8
Show file tree
Hide file tree
Showing 45 changed files with 1,557 additions and 161 deletions.
6 changes: 2 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ module.exports = {
env: {
node: true
},
'extends': [
'plugin:vue/essential',
'@vue/standard'
],
extends: ['plugin:vue/essential', '@vue/standard'],
rules: {
'space-before-function-paren': 'off',
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
},
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
# winter-app
# element-admin

## 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
```

### Run your unit tests

```
yarn run test:unit
```

### Customize configuration

See [Configuration Reference](https://cli.vuejs.org/config/).
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "winter-app",
"name": "element-admin",
"version": "0.1.0",
"private": true,
"scripts": {
Expand All @@ -9,10 +9,12 @@
"test:unit": "vue-cli-service test:unit"
},
"dependencies": {
"element-ui": "^2.4.11",
"register-service-worker": "^1.5.2",
"vue": "^2.5.17",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
"vuex": "^3.0.1",
"vuex-router-sync": "^5.0.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.2.0",
Expand Down
15 changes: 9 additions & 6 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>winter-app</title>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title>Codetrial Element Admin</title>
</head>
<body>
<noscript>
<strong>We're sorry but winter-app doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
<strong
>We're sorry but Codetrial Element Admin doesn't work properly without
JavaScript enabled. Please enable it to continue.</strong
>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
Expand Down
4 changes: 2 additions & 2 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "winter-app",
"short_name": "winter-app",
"name": "element-admin",
"short_name": "element-admin",
"icons": [
{
"src": "./img/icons/android-chrome-192x192.png",
Expand Down
27 changes: 6 additions & 21 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
<template>
<div id="app">
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div>
<router-view/>
</div>
</template>

<style lang="scss">
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
#nav {
padding: 30px;
a {
font-weight: bold;
color: #2c3e50;
&.router-link-exact-active {
color: #42b983;
}
}
}
</style>

<script>
export default {
name: 'App'
}
</script>
104 changes: 104 additions & 0 deletions src/api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { delay, checkCode } from '@/utils/request'

/* start of mocking user */
const users = {
admin: {
id: 100001,
name: 'Administrator',
roles: ['USER', 'ADMIN']
},
codetrial: {
id: 100001,
name: 'Codetrial',
roles: ['USER']
}
}

export async function getUser(username) {
await delay(200)

const user = users[username]
const response = user
? {
status: '1',
data: user
}
: {
status: '1100',
message: 'Wrong user or password'
}

return Promise.resolve(response).then(checkCode)
}
/* end of mocking user */

/* start of mocking example list */
const exampleSource = Array(235)
.fill(1)
.map((element, index) => {
const personal = index % 2 === 0
return {
id: index + 10000,
name: `Example - ${index} - ${personal ? 'felixpy' : 'codetrial'}`,
type: personal ? 1 : 2,
status: index % 5 === 0 ? 0 : 1,
url: personal ? 'https://felixpy.com' : 'https://codetrial.github.io',
createUser: 100001,
createUserName: 'Felix Yang',
updateUser: 100001,
updateUserName: 'Felix Yang',
createTime: '2018-12-22 11:00:00',
updateTime: '2018-12-22 11:00:00'
}
})

export async function getExampleList({ filter = {}, page = {} }) {
const { pageNo = 1, pageSize = 20 } = page
const offset = (pageNo - 1) * pageSize
let list = exampleSource
let total = exampleSource.length

// filter
Object.keys(filter).forEach(key => {
const filterValue = filter[key]
if (filterValue != null && filterValue.length) {
list = list.filter(item => {
if (Array.isArray(filterValue)) {
return filterValue.map(String).indexOf(String(item[key])) > -1
}
return String(item[key]) === String(filterValue)
})
}
})

total = list.length

// sort
list = list.sort((a, b) => {
const { order, orderBy } = page

if (!order || !orderBy) {
return
}

const diff = (order === 'descending' ? -1 : 1) * (a[orderBy] - b[orderBy])
return diff > 0 ? 1 : -1
})

// pagination
list = list.slice(offset, offset + pageSize)

await delay(1000)

return Promise.resolve({
status: '1',
data: {
list,
page: {
...page,
total
}
}
}).then(checkCode)
}
/* end of mocking example list */
60 changes: 0 additions & 60 deletions src/components/HelloWorld.vue

This file was deleted.

15 changes: 15 additions & 0 deletions src/components/errors/403.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<div class="error-page">
<div class="error-page__tip">403 Forbidden</div>
</div>
</template>

<style lang="scss" scoped>
@import './index';
</style>

<script>
export default {
name: 'Forbidden'
}
</script>
15 changes: 15 additions & 0 deletions src/components/errors/404.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<div class="error-page">
<div class="error-page__tip">404 Not Found</div>
</div>
</template>

<style lang="scss" scoped>
@import './index';
</style>

<script>
export default {
name: 'NotFound'
}
</script>
15 changes: 15 additions & 0 deletions src/components/errors/500.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<div class="error-page">
<div class="error-page__tip">500 Internal Server Error</div>
</div>
</template>

<style lang="scss" scoped>
@import './index';
</style>

<script>
export default {
name: 'InternalServerError'
}
</script>
5 changes: 5 additions & 0 deletions src/components/errors/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Forbidden from './403.vue'
import NotFound from './404.vue'
import InternalServerError from './500.vue'

export { Forbidden, NotFound, InternalServerError }
9 changes: 9 additions & 0 deletions src/components/errors/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.error-page {
padding: 100px 0;

.error-page__tip {
font-size: 48px;
font-weight: bold;
text-align: center;
}
}
Loading

0 comments on commit 6aa2ba8

Please sign in to comment.