Skip to content

Commit

Permalink
代码优化,删除initData.js,生产环境移除console
Browse files Browse the repository at this point in the history
  • Loading branch information
elunez committed Nov 25, 2019
1 parent 882dc03 commit 0351b72
Show file tree
Hide file tree
Showing 27 changed files with 80 additions and 170 deletions.
6 changes: 6 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
const plugins = ['@vue/babel-plugin-transform-vue-jsx']
// 生产环境移除console
if (process.env.NODE_ENV === 'production') {
plugins.push('transform-remove-console')
}
module.exports = {
plugins: plugins,
presets: [
'@vue/app'
]
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.0.1",
"babel-jest": "23.6.0",
"babel-plugin-transform-remove-console": "^6.9.4",
"chalk": "2.4.2",
"chokidar": "2.1.5",
"connect": "3.6.6",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/icons/svg/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/assets/icons/svg/mntsvg

This file was deleted.

1 change: 1 addition & 0 deletions src/assets/icons/svg/source.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/styles/eladmin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
line-height: 30.5px;
}
}
.el-select__caret.el-input__icon.el-icon-arrow-up{
line-height: 30.5px;
}
.date-item {
display: inline-block;
vertical-align: middle;
margin-bottom: 10px;
height: 30.5px;
width: 223px;
}
}
.el-avatar {
Expand Down
24 changes: 9 additions & 15 deletions src/components/Github/index.vue
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
<template>
<a href="https://github.com/elunez/eladmin" target="_blank">
<svg id="icon-github" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="icon svg" viewBox="0 0 1025 1024" width="100%" height="100%"><path d="M512.032 831.904c-19.168 0-38.304-9.92-58.144-29.76-7.808-7.808-7.808-20.48 0-28.288s20.48-7.808 28.288 0c12.192 12.224 21.984 18.144 29.856 18.144s17.664-5.92 29.856-18.144c7.808-7.808 20.48-7.808 28.288 0s7.808 20.48 0 28.288c-19.84 19.84-38.976 29.76-58.144 29.76zM0.032 525.504c0 49.888 4.256 95.136 12.8 135.68s20.544 75.744 36 105.536c15.456 29.792 35.008 55.904 58.656 78.336s49.344 40.928 77.056 55.456c27.744 14.528 59.456 26.304 95.2 35.264s72.096 15.264 109.056 18.848 77.696 5.376 122.144 5.376c44.448 0 85.248-1.792 122.4-5.376s73.6-9.856 109.344-18.848c35.744-8.96 67.552-20.736 95.456-35.264s53.792-33.024 77.6-55.456c23.808-22.432 43.456-48.544 58.944-78.336s27.552-64.96 36.256-105.536c8.704-40.576 13.056-85.792 13.056-135.68 0-89.376-27.744-166.368-83.2-230.976 3.2-8.608 5.952-18.496 8.256-29.6s4.544-26.816 6.656-47.104c2.144-20.288 1.344-43.712-2.4-70.272s-10.752-53.664-21.056-81.312l-8-1.632c-5.344-1.088-14.048-0.704-26.144 1.088s-26.208 5.024-42.4 9.696c-16.192 4.672-37.056 13.92-62.656 27.744s-52.608 31.328-81.056 52.512c-48.352-14.72-115.008-30.112-200-30.112s-151.808 15.392-200.544 30.112c-28.448-21.184-55.552-38.592-81.344-52.224s-46.4-22.976-61.856-28c-15.456-5.024-29.792-8.256-42.944-9.696s-21.6-1.888-25.344-1.344c-3.744 0.544-6.496 1.152-8.256 1.888-10.304 27.648-17.408 54.752-21.344 81.312s-4.8 49.888-2.656 69.984c2.144 20.096 4.448 35.904 6.944 47.392s5.344 21.344 8.544 29.6c-55.456 64.256-83.2 141.248-83.2 230.976zM136.576 639.392c0-58.016 21.344-110.624 64-157.856 12.8-14.4 27.648-25.312 44.544-32.704s36.096-11.616 57.6-12.608 42.048-0.8 61.6 0.608c19.552 1.408 43.744 3.296 72.544 5.696s53.696 3.616 74.656 3.616c20.96 0 45.856-1.184 74.656-3.616s52.992-4.288 72.544-5.696c19.552-1.408 40.096-1.6 61.6-0.608s40.8 5.216 57.856 12.608c17.056 7.392 32 18.304 44.8 32.704 42.656 47.232 64 99.84 64 157.856 0 34.016-3.552 64.32-10.656 90.944s-16.096 48.928-26.944 66.912c-10.848 18.016-26.048 33.216-45.6 45.632s-38.496 22.016-56.8 28.8c-18.304 6.784-41.952 12.096-70.944 15.904s-54.944 6.112-77.856 6.912c-22.944 0.8-51.808 1.216-86.656 1.216s-63.648-0.416-86.4-1.216c-22.752-0.8-48.608-3.104-77.6-6.912s-52.608-9.12-70.944-15.904c-18.304-6.816-37.248-16.416-56.8-28.8s-34.752-27.616-45.6-45.632c-10.848-18.016-19.84-40.32-26.944-66.912s-10.656-56.928-10.656-90.944zM256.032 608c0-53.024 28.64-96 64-96s64 42.976 64 96c0 53.024-28.64 96-64 96s-64-42.976-64-96zM640.032 608c0-53.024 28.64-96 64-96s64 42.976 64 96c0 53.024-28.64 96-64 96s-64-42.976-64-96z" p-id="1450" /></svg>
</a>
<div>
<svg-icon icon-class="github" @click="click" />
</div>
</template>

<script>
export default {
name: 'Github'
name: 'Github',
methods: {
click() {
window.open('https://github.com/elunez/eladmin', '_blank')
}
}
}
</script>

<style scoped>
.svg {
display: inline-block;
cursor: pointer;
fill: #5a5e66;;
width: 20px;
height: 20px;
vertical-align: 10px;
}
</style>
12 changes: 10 additions & 2 deletions src/layout/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
<template v-if="device!=='mobile'">
<search id="header-search" class="right-menu-item" />

<screenfull id="screenfull" class="right-menu-item hover-effect" />
<el-tooltip content="源码地址" effect="dark" placement="bottom">
<Github class="right-menu-item hover-effect" />
</el-tooltip>

<el-tooltip content="全屏缩放" effect="dark" placement="bottom">
<screenfull id="screenfull" class="right-menu-item hover-effect" />
</el-tooltip>

<el-tooltip content="布局设置" effect="dark" placement="bottom">
<size-select id="size-select" class="right-menu-item hover-effect" />
Expand Down Expand Up @@ -52,6 +58,7 @@
import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'
import Github from '@/components/Github'
import Screenfull from '@/components/Screenfull'
import SizeSelect from '@/components/SizeSelect'
import Search from '@/components/HeaderSearch'
Expand All @@ -63,7 +70,8 @@ export default {
Hamburger,
Screenfull,
SizeSelect,
Search
Search,
Github
},
data() {
return {
Expand Down
81 changes: 0 additions & 81 deletions src/mixins/initData.js

This file was deleted.

19 changes: 13 additions & 6 deletions src/views/generator/config.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
value="Like"
/>
<el-option
label="DateRange"
value="DateRange"
label="BetWeen"
value="BetWeen"
/>
</el-select>
</template>
Expand Down Expand Up @@ -146,6 +146,10 @@
<el-input v-model="form.pack" style="width: 40%" />
<span style="color: #C0C0C0;margin-left: 10px;">项目包的名称,生成的代码放到哪个包里面</span>
</el-form-item>
<el-form-item label="接口名称" prop="apiAlias">
<el-input v-model="form.apiAlias" style="width: 40%" />
<span style="color: #C0C0C0;margin-left: 10px;">接口的名称,用于控制器与接口文档中</span>
</el-form-item>
<el-form-item label="前端路径" prop="path">
<el-input v-model="form.path" style="width: 40%" />
<span style="color: #C0C0C0;margin-left: 10px;">输入views文件夹下的目录,不存在即创建</span>
Expand Down Expand Up @@ -173,18 +177,18 @@
</template>

<script>
import initData from '@/mixins/initData'
import crud from '@/mixins/crud'
import { update, get } from '@/api/generator/genConfig'
import { save } from '@/api/generator/generator'
import { getDicts } from '@/api/system/dict'
export default {
name: 'GeneratorConfig',
components: {},
mixins: [initData],
mixins: [crud],
data() {
return {
activeName: 'first', tableName: '', tableHeight: 550, columnLoading: false, configLoading: false, dicts: [],
form: { id: null, tableName: '', author: '', pack: '', path: '', moduleName: '', cover: 'false', apiPath: '', prefix: '' },
form: { id: null, tableName: '', author: '', pack: '', path: '', moduleName: '', cover: 'false', apiPath: '', prefix: '', apiAlias: null },
rules: {
author: [
{ required: true, message: '作者不能为空', trigger: 'blur' }
Expand All @@ -196,7 +200,10 @@ export default {
{ required: true, message: '包路径不能为空', trigger: 'blur' }
],
path: [
{ required: true, message: '前端代码生成路径不能为空', trigger: 'blur' }
{ required: true, message: '前端路径不能为空', trigger: 'blur' }
],
apiAlias: [
{ required: true, message: '接口名称不能为空', trigger: 'blur' }
],
cover: [
{ required: true, message: '不能为空', trigger: 'blur' }
Expand Down
32 changes: 2 additions & 30 deletions src/views/generator/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,13 @@
</template>

<script>
import initData from '@/mixins/initData'
import { parseTime } from '@/utils/index'
import crud from '@/mixins/crud'
import { generator } from '@/api/generator/generator'
export default {
name: 'GeneratorIndex',
mixins: [initData],
mixins: [crud],
data() {
return {
loading: false, dialog: false,
form: { author: '', pack: '', path: '', moduleName: '', cover: 'false', apiPath: '', prefix: '' },
rules: {
author: [
{ required: true, message: '作者不能为空', trigger: 'blur' }
],
pack: [
{ required: true, message: '包路径不能为空', trigger: 'blur' }
],
moduleName: [
{ required: true, message: '包路径不能为空', trigger: 'blur' }
],
path: [
{ required: true, message: '前端代码生成路径不能为空', trigger: 'blur' }
],
apiPath: [
{ required: true, message: '前端Api文件生成路径不能为空', trigger: 'blur' }
],
cover: [
{ required: true, message: '不能为空', trigger: 'blur' }
]
}
}
},
created() {
Expand All @@ -84,13 +61,8 @@ export default {
})
},
methods: {
parseTime,
beforeInit() {
this.url = 'api/generator/tables'
const query = this.query
const name = query.name
this.params = { page: this.page, size: this.size }
if (name) { this.params['name'] = name }
return true
},
toGen(tableName) {
Expand Down
Loading

0 comments on commit 0351b72

Please sign in to comment.