Skip to content

Commit 230055e

Browse files
committed
Style(naming): enforce naming convention by following vue style guide
* Add global filters support * Update routes mock file
1 parent d816ee5 commit 230055e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+361
-431
lines changed

mock/role/routes.ts

+199-108
Large diffs are not rendered by default.
File renamed without changes.
File renamed without changes.

src/components/Charts/Keyboard.vue renamed to src/components/Charts/BarChart.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { mixins } from 'vue-class-component'
1313
import ResizeMixin from './mixins/resize'
1414
1515
@Component
16-
export default class Keyboard extends mixins(ResizeMixin) {
16+
export default class BarChart extends mixins(ResizeMixin) {
1717
@Prop({ default: 'chart' }) private className!: string
1818
@Prop({ default: 'chart' }) private id!: string
1919
@Prop({ default: '200px' }) private width!: string

src/components/Charts/LineMarker.vue renamed to src/components/Charts/LineChart.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { mixins } from 'vue-class-component'
1313
import ResizeMixin from './mixins/resize'
1414
1515
@Component
16-
export default class LineMarker extends mixins(ResizeMixin) {
16+
export default class LineChart extends mixins(ResizeMixin) {
1717
@Prop({ default: 'chart' }) private className!: string
1818
@Prop({ default: 'chart' }) private id!: string
1919
@Prop({ default: '200px' }) private width!: string

src/components/Charts/MixChart.vue renamed to src/components/Charts/MixedChart.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { mixins } from 'vue-class-component'
1313
import ResizeMixin from './mixins/resize'
1414
1515
@Component
16-
export default class MixChart extends mixins(ResizeMixin) {
16+
export default class MixedChart extends mixins(ResizeMixin) {
1717
@Prop({ default: 'chart' }) private className!: string
1818
@Prop({ default: 'chart' }) private id!: string
1919
@Prop({ default: '200px' }) private width!: string

src/components/DraggableSelect/index.vue

Whitespace-only changes.

src/components/ErrorLog/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676

7777
<script lang="ts">
7878
import { Component, Vue } from 'vue-property-decorator'
79-
import { ErrorLogModule } from '@/store/modules/errorLog'
79+
import { ErrorLogModule } from '@/store/modules/error-log'
8080
8181
@Component
8282
export default class ErrorLog extends Vue {

src/components/SizeSelect/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<script lang="ts">
2828
import { Component, Vue } from 'vue-property-decorator'
2929
import { AppModule } from '@/store/modules/app'
30-
import { TagsViewModule } from '@/store/modules/tagsView'
30+
import { TagsViewModule } from '@/store/modules/tags-view'
3131
3232
@Component
3333
export default class SizeSelect extends Vue {

src/filters/index.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
1-
// set function parseTime to filter
1+
// Set utils function parseTime to filter
22
export { parseTime } from '@/utils'
3+
4+
// Filter for article status
5+
export const articleStatusFilter = (status: string) => {
6+
const statusMap: { [key: string]: string } = {
7+
published: 'success',
8+
draft: 'info',
9+
deleted: 'danger'
10+
}
11+
return statusMap[status]
12+
}

src/icons/components/guide 2.ts renamed to src/icons/components/guide-2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @ts-ignore
44
import icon from 'vue-svgicon'
55
icon.register({
6-
'guide 2': {
6+
'guide-2': {
77
width: 1000,
88
height: 1000,
99
viewBox: '0 0 1000 1000',

src/icons/components/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import './eye-off'
1717
import './eye-on'
1818
import './form'
1919
import './fullscreen'
20-
import './guide 2'
20+
import './guide-2'
2121
import './guide'
2222
import './hamburger'
2323
import './icon'
File renamed without changes.

src/lang/en.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ export default {
1212
tinymce: 'Tinymce',
1313
markdown: 'Markdown',
1414
jsonEditor: 'JSON Editor',
15-
dndList: 'Dnd List',
1615
splitPane: 'SplitPane',
1716
avatarUpload: 'Avatar Upload',
1817
dropzone: 'Dropzone',
1918
sticky: 'Sticky',
2019
countTo: 'Count To',
2120
componentMixin: 'Mixin',
2221
backToTop: 'Back To Top',
22+
draggableList: 'Draggable List',
2323
draggableDialog: 'Draggable Dialog',
24-
dragSelect: 'Drag Select',
25-
dragKanban: 'Drag Kanban',
24+
draggableSelect: 'Draggable Select',
25+
draggableKanban: 'Draggable Kanban',
2626
charts: 'Charts',
27-
keyboardChart: 'Keyboard Chart',
27+
barChart: 'Bar Chart',
2828
lineChart: 'Line Chart',
29-
mixChart: 'Mix Chart',
29+
mixedChart: 'Mixed Chart',
3030
example: 'Example',
3131
nested: 'Nested Routes',
3232
menu1: 'Menu 1',
@@ -38,7 +38,7 @@ export default {
3838
menu2: 'Menu 2',
3939
table: 'Table',
4040
dynamicTable: 'Dynamic Table',
41-
dragTable: 'Drag Table',
41+
draggableTable: 'Draggable Table',
4242
inlineEditTable: 'Inline Edit',
4343
complexTable: 'Complex Table',
4444
tab: 'Tab',

src/lang/es.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ export default {
1212
tinymce: 'Tinymce',
1313
markdown: 'Markdown',
1414
jsonEditor: 'Editor JSON',
15-
dndList: 'Lista Dnd',
1615
splitPane: 'Panel dividido',
1716
avatarUpload: 'Subir avatar',
1817
dropzone: 'Subir ficheros',
1918
sticky: 'Sticky',
2019
countTo: 'Count To',
2120
componentMixin: 'Mixin',
2221
backToTop: 'Ir arriba',
22+
draggableList: 'Draggable List',
2323
draggableDialog: 'Draggable Dialog',
24-
dragSelect: 'Drag Select',
25-
dragKanban: 'Drag Kanban',
24+
draggableSelect: 'Draggable Select',
25+
draggableKanban: 'Draggable Kanban',
2626
charts: 'Gráficos',
27-
keyboardChart: 'Keyboard Chart',
27+
barChart: 'Bar Chart',
2828
lineChart: 'Gráfico de líneas',
29-
mixChart: 'Mix Chart',
29+
mixedChart: 'Mixed Chart',
3030
example: 'Ejemplo',
3131
nested: 'Rutas anidadass',
3232
menu1: 'Menu 1',
@@ -38,7 +38,7 @@ export default {
3838
menu2: 'Menu 2',
3939
table: 'Tabla',
4040
dynamicTable: 'Tabla dinámica',
41-
dragTable: 'Arrastrar tabla',
41+
draggableTable: 'Arrastrar tabla',
4242
inlineEditTable: 'Editor',
4343
complexTable: 'Complex Table',
4444
tab: 'Pestaña',

src/lang/ja.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ export default {
1212
tinymce: 'TinyMCE',
1313
markdown: 'Markdown',
1414
jsonEditor: 'JSON Editor',
15-
dndList: 'Drag-And-Drop',
1615
splitPane: 'パネル',
1716
avatarUpload: 'アバターアップロード',
1817
dropzone: 'Dropzone',
1918
sticky: 'Sticky',
2019
countTo: 'Count To',
2120
componentMixin: 'コンポーネントMixin',
2221
backToTop: 'Back To Top',
22+
draggableList: 'Draggable List',
2323
draggableDialog: 'Draggable Dialog',
24-
dragSelect: 'Drag Select',
25-
dragKanban: 'Drag 看板',
24+
draggableSelect: 'Draggable Select',
25+
draggableKanban: 'Draggable 看板',
2626
charts: 'チャート',
27-
keyboardChart: 'Keyboardチャート',
27+
barChart: 'Barチャート',
2828
lineChart: 'Lineチャート',
29-
mixChart: 'Mixチャート',
29+
mixedChart: 'Mixedチャート',
3030
example: 'Example',
3131
nested: 'Nested Routes',
3232
menu1: 'メニュー1',
@@ -38,7 +38,7 @@ export default {
3838
menu2: 'メニュー 2',
3939
table: 'Table',
4040
dynamicTable: '可変 Table',
41-
dragTable: 'Drag Table',
41+
draggableTable: 'Draggable Table',
4242
inlineEditTable: 'Inline Edit Table',
4343
complexTable: 'Complex Table',
4444
tab: 'Tab',

src/lang/zh.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ export default {
1212
tinymce: '富文本编辑器',
1313
markdown: 'Markdown',
1414
jsonEditor: 'JSON 编辑器',
15-
dndList: '列表拖拽',
1615
splitPane: 'Splitpane',
1716
avatarUpload: '头像上传',
1817
dropzone: 'Dropzone',
1918
sticky: 'Sticky',
2019
countTo: 'Count To',
2120
componentMixin: '小组件',
2221
backToTop: '返回顶部',
23-
draggableDialog: '可拖拽 Dialog',
24-
dragSelect: '拖拽 Select',
25-
dragKanban: '可拖拽看板',
22+
draggableDialog: '可拖拽对话框',
23+
draggableList: '可拖拽列表',
24+
draggableSelect: '可拖拽选择',
25+
draggableKanban: '可拖拽看板',
2626
charts: '图表',
27-
keyboardChart: '键盘图表',
27+
barChart: '柱状图表',
2828
lineChart: '折线图',
29-
mixChart: '混合图表',
29+
mixedChart: '混合图表',
3030
example: '综合实例',
3131
nested: '路由嵌套',
3232
menu1: '菜单 1',
@@ -38,7 +38,7 @@ export default {
3838
menu2: '菜单 2',
3939
table: '表格',
4040
dynamicTable: '动态表格',
41-
dragTable: '拖拽表格',
41+
draggableTable: '可拖拽表格',
4242
inlineEditTable: '表格内编辑',
4343
complexTable: '综合表格',
4444
tab: '分栏',

src/layout/components/AppMain.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<script lang="ts">
1515
import { Component, Vue } from 'vue-property-decorator'
16-
import { TagsViewModule } from '@/store/modules/tagsView'
16+
import { TagsViewModule } from '@/store/modules/tags-view'
1717
1818
@Component
1919
export default class AppMain extends Vue {

src/layout/components/Sidebar/SidebarItem.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
:class="['menu-wrapper', isCollapse ? 'simple-mode' : 'full-mode', {'first-level': isFirstLevel}]"
55
>
66
<template v-if="!alwaysShowRootMenu && theOnlyOneChild && !theOnlyOneChild.children">
7-
<app-link
7+
<sidebar-item-link
88
v-if="theOnlyOneChild.meta"
99
:to="resolvePath(theOnlyOneChild.path)"
1010
>
@@ -21,7 +21,7 @@
2121
slot="title"
2222
>{{ $t('route.' + theOnlyOneChild.meta.title) }}</span>
2323
</el-menu-item>
24-
</app-link>
24+
</sidebar-item-link>
2525
</template>
2626
<el-submenu
2727
v-else
@@ -56,14 +56,14 @@ import path from 'path'
5656
import { Component, Prop, Vue } from 'vue-property-decorator'
5757
import { Route, RouteConfig } from 'vue-router'
5858
import { isExternal } from '@/utils/validate'
59-
import AppLink from './Link.vue'
59+
import SidebarItemLink from './SidebarItemLink.vue'
6060
6161
@Component({
6262
// Set 'name' here to prevent uglifyjs from causing recursive component not work
6363
// See https://medium.com/haiiro-io/element-component-name-with-vue-class-component-f3b435656561 for detail
6464
name: 'SidebarItem',
6565
components: {
66-
AppLink
66+
SidebarItemLink
6767
}
6868
})
6969
export default class SidebarItem extends Vue {

src/layout/components/Sidebar/Link.vue renamed to src/layout/components/Sidebar/SidebarItemLink.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { isExternal } from '@/utils/validate'
2424
isExternal
2525
}
2626
})
27-
export default class Link extends Vue {
27+
export default class SidebarItemLink extends Vue {
2828
@Prop({ required: true }) private to!: string
2929
}
3030
</script>

src/layout/components/Sidebar/index.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div :class="{'has-logo': showLogo}">
3-
<logo
3+
<sidebar-logo
44
v-if="showLogo"
55
:collapse="isCollapse"
66
/>
@@ -32,14 +32,14 @@ import { Component, Prop, Vue } from 'vue-property-decorator'
3232
import { AppModule } from '@/store/modules/app'
3333
import { PermissionModule } from '@/store/modules/permission'
3434
import { SettingsModule } from '@/store/modules/settings'
35-
import Logo from './Logo.vue'
3635
import SidebarItem from './SidebarItem.vue'
36+
import SidebarLogo from './SidebarLogo.vue'
3737
import variables from '@/styles/_variables.scss'
3838
3939
@Component({
4040
components: {
41-
Logo,
42-
SidebarItem
41+
SidebarItem,
42+
SidebarLogo
4343
}
4444
})
4545
export default class SideBar extends Vue {

src/layout/components/TagsView/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import { Component, Vue, Watch } from 'vue-property-decorator'
5757
import VueRouter, { Route, RouteRecord, RouteConfig } from 'vue-router'
5858
import { ElBreadcrumbItem } from 'element-ui/types/breadcrumb-item'
5959
import { PermissionModule } from '@/store/modules/permission'
60-
import { TagsViewModule, ITagView } from '@/store/modules/tagsView'
60+
import { TagsViewModule, ITagView } from '@/store/modules/tags-view'
6161
import ScrollPane from './ScrollPane.vue'
6262
6363
@Component({

src/layout/mixin/resize.ts

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export default class ResizeMixin extends Vue {
4141
return rect.width - 1 < WIDTH
4242
}
4343

44-
// eslint-disable-next-line camelcase
4544
private resizeHandler() {
4645
if (!document.hidden) {
4746
const isMobile = this.isMobile()

src/main.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ import router from '@/router'
1212
import i18n from '@/lang' // Internationalization
1313
import '@/icons/components'
1414
import '@/permission'
15-
import '@/utils/error-log' // Error log
15+
import '@/utils/error-log'
1616
import '@/registerServiceWorker'
17+
import * as filters from '@/filters'
1718

1819
import { mockXHR } from '../mock'
1920
mockXHR()
2021

2122
Vue.use(ElementUI, {
22-
size: AppModule.size, // set element-ui default size
23+
size: AppModule.size, // Set element-ui default size
2324
i18n: (key: string, value: string) => i18n.t(key, value)
2425
})
2526

@@ -29,6 +30,11 @@ Vue.use(SvgIcon, {
2930
defaultHeight: '1em'
3031
})
3132

33+
// Register global filter functions
34+
Object.keys(filters).forEach(key => {
35+
Vue.filter(key, (filters as { [key: string ]: Function })[key])
36+
})
37+
3238
Vue.config.productionTip = false
3339

3440
new Vue({

0 commit comments

Comments
 (0)