Skip to content

Commit df422f8

Browse files
committed
chore(lint): 增加commit规范校验
1 parent 04afef5 commit df422f8

File tree

7 files changed

+125
-97
lines changed

7 files changed

+125
-97
lines changed

.eslintrc.js

+31-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: 秦少卫
33
* @Date: 2022-09-03 19:22:16
44
* @LastEditors: 秦少卫
5-
* @LastEditTime: 2023-02-08 00:27:43
5+
* @LastEditTime: 2023-02-08 17:04:28
66
* @Description: file content
77
*/
88
module.exports = {
@@ -20,6 +20,36 @@ module.exports = {
2020
rules: {
2121
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
2222
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
23+
'vuejs-accessibility/click-events-have-key-events': 'off',
24+
'max-len': 'off',
25+
'no-underscore-dangle': 'off',
26+
'no-unde': 'off',
27+
'no-unused-vars': 'off',
28+
'block-scoped-var': 'off',
29+
'no-undef': 'off',
30+
'no-unused-expressions': 'off',
31+
'no-unused-var': 'off',
32+
'no-param-reassign': 'off',
33+
'no-use-before-defin': 'off',
34+
'no-use-before-define': 'off',
35+
'vars-on-top': 'off',
36+
'no-plusplus': 'off',
37+
'no-var': 'off',
38+
'no-continue': 'off',
39+
'no-multi-assign': 'off',
40+
'implicit-arrow-linebreak': 'off',
41+
'consistent-return': 'off',
42+
'prefer-destructuring': 'off',
43+
'consistent-return': 'off',
44+
'no-dupe-keys': 'off',
45+
'new-cap': 'off',
46+
'no-empty': 'off',
47+
'no-redeclare': 'off',
48+
'import/no-unresolved': 'off',
49+
'no-return-assign': 'off',
50+
'prefer-destructuring': 'off',
51+
'import/prefer-default-export': 'off',
52+
'vuejs-accessibility/form-control-has-label': 'off',
2353
},
2454
overrides: [
2555
{

commitlint.config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
module.exports = {
2-
extends: ['@commitlint/config-conventional']
3-
};
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
};

src/assets/fonts/font.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
*/
88

99
const cnList = [
10-
{
11-
"name": "汉体",
12-
"fontFamily": "汉体"
13-
},
14-
{
15-
"name": "华康金刚黑",
16-
"fontFamily": "华康金刚黑"
17-
}
18-
]
10+
{
11+
name: '汉体',
12+
fontFamily: '汉体',
13+
},
14+
{
15+
name: '华康金刚黑',
16+
fontFamily: '华康金刚黑',
17+
},
18+
];
1919

20-
const enList = []
20+
const enList = [];
2121

22-
export default [...cnList, ...enList]
22+
export default [...cnList, ...enList];

src/components/mouseMenu.vue

+51-53
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
</template>
2626

2727
<script>
28-
import { isEmpty, debounce } from 'lodash-es'
29-
import select from '@/mixins/select'
28+
import { isEmpty, debounce } from 'lodash-es';
29+
import select from '@/mixins/select';
3030
31-
const canvasDom = document.getElementById('canvas') || null
31+
const canvasDom = document.getElementById('canvas') || null;
3232
export default ({
3333
name: 'mouseMenu',
3434
inject: ['canvas', 'fabric'],
@@ -39,39 +39,39 @@ export default ({
3939
left: 0,
4040
top: 0,
4141
zIndex: -100,
42-
menu: null
43-
}
42+
menu: null,
43+
};
4444
},
4545
computed: {
4646
// 单选且等于组元素
4747
isGroup() {
48-
return (this.mSelectMode === 'one' && this.mSelectOneType === 'group')
48+
return (this.mSelectMode === 'one' && this.mSelectOneType === 'group');
4949
},
5050
// 是否为多选
51-
isMultiple(){
52-
return (this.mSelectMode === 'multiple')
51+
isMultiple() {
52+
return (this.mSelectMode === 'multiple');
5353
},
5454
},
5555
mounted() {
5656
this.$nextTick(() => {
57-
this.menu = this.$refs.mouseMenuRef
58-
this.menu && (this.menu.oncontextmenu = e => e.preventDefault())
59-
this.init()
57+
this.menu = this.$refs.mouseMenuRef;
58+
this.menu && (this.menu.oncontextmenu = (e) => e.preventDefault());
59+
this.init();
6060
});
6161
// 监听点击 隐藏(右键点击外部和fabric右键有冲突,因为点击非canvas只有点击左键才可以隐藏)
62-
window.addEventListener('click', debounce(this.clickHide, 200))
62+
window.addEventListener('click', debounce(this.clickHide, 200));
6363
},
6464
6565
beforeMount() {
66-
window.removeEventListener('click', this.clickHide)
66+
window.removeEventListener('click', this.clickHide);
6767
},
6868
6969
methods: {
7070
init() {
7171
if (!isEmpty(this.canvas) && !isEmpty(this.canvas.c)) {
7272
this.canvas.c.on('mouse:down', this.handleMouseUp);
7373
} else {
74-
this.hideMenu()
74+
this.hideMenu();
7575
}
7676
},
7777
@@ -80,96 +80,94 @@ export default ({
8080
if (opt.button === 3 && opt.target && opt.target.id !== 'workspace') {
8181
// 显示菜单,设置右键菜单位置
8282
// 获取菜单组件的宽高
83-
const menuWidth = this.menu.offsetWidth
84-
const menuHeight = this.menu.offsetHeight
83+
const menuWidth = this.menu.offsetWidth;
84+
const menuHeight = this.menu.offsetHeight;
8585
// 当前鼠标位置
86-
let pointX = opt.pointer.x
87-
let pointY = opt.pointer.y
86+
let pointX = opt.pointer.x;
87+
let pointY = opt.pointer.y;
8888
8989
// 计算菜单出现的位置
9090
// 如果鼠标靠近画布右侧,菜单就出现在鼠标指针左侧
9191
if (canvas.width - pointX <= menuWidth) {
92-
pointX -= menuWidth
92+
pointX -= menuWidth;
9393
}
9494
// 如果鼠标靠近画布底部,菜单就出现在鼠标指针上方
9595
if (canvas.height - pointY <= menuHeight) {
96-
pointY -= menuHeight
96+
pointY -= menuHeight;
9797
}
98-
this.showMenu(pointX, pointY)
99-
98+
this.showMenu(pointX, pointY);
10099
} else {
101-
this.hideMenu()
100+
this.hideMenu();
102101
}
103102
} catch (error) {
104-
console.log(error)
103+
console.log(error);
105104
}
106105
},
107106
108107
showMenu(x, y) {
109-
this.show = 'visible'
110-
this.left = `${x}px`
111-
this.top = `${y}px`
112-
this.zIndex = 100
108+
this.show = 'visible';
109+
this.left = `${x}px`;
110+
this.top = `${y}px`;
111+
this.zIndex = 100;
113112
},
114113
115114
hideMenu(e) {
116-
this.show = 'hidden'
117-
this.left = 0
118-
this.top = 0
119-
this.zIndex = -100
115+
this.show = 'hidden';
116+
this.left = 0;
117+
this.top = 0;
118+
this.zIndex = -100;
120119
},
121120
122121
clickHide(e) {
123122
if ((e.target !== canvasDom) && (this.show === 'visible')) {
124-
this.hideMenu()
123+
this.hideMenu();
125124
}
126125
},
127126
128127
handleMenu(e) {
129-
const active = e.target.dataset.active || e.srcElement.dataset.active
130-
if (!active) return this.hideMenu()
131-
const canvas = this.canvas.c
128+
const active = e.target.dataset.active || e.srcElement.dataset.active;
129+
if (!active) return this.hideMenu();
130+
const canvas = this.canvas.c;
132131
const activeObject = canvas.getActiveObjects();
133132
switch (active) {
134133
case 'copy':
135-
this.canvas.editor.clone()
134+
this.canvas.editor.clone();
136135
break;
137136
case 'delete':
138-
activeObject && activeObject.map(item => canvas.remove(item))
139-
canvas.requestRenderAll()
140-
canvas.discardActiveObject()
137+
activeObject && activeObject.map((item) => canvas.remove(item));
138+
canvas.requestRenderAll();
139+
canvas.discardActiveObject();
141140
break;
142141
case 'center':
143-
this.canvas.editor.centerAlign.position('center')
142+
this.canvas.editor.centerAlign.position('center');
144143
break;
145144
case 'group':
146-
this.canvas.editor.group()
145+
this.canvas.editor.group();
147146
break;
148147
case 'unGroup':
149-
this.canvas.editor.unGroup()
148+
this.canvas.editor.unGroup();
150149
break;
151150
case 'up':
152-
this.canvas.editor.up()
151+
this.canvas.editor.up();
153152
break;
154153
case 'down':
155-
this.canvas.editor.down()
154+
this.canvas.editor.down();
156155
break;
157156
case 'upTop':
158-
this.canvas.editor.upTop()
157+
this.canvas.editor.upTop();
159158
break;
160159
case 'downTop':
161-
this.canvas.editor.downTop()
160+
this.canvas.editor.downTop();
162161
break;
163162
default:
164163
break;
165164
}
166-
this.hideMenu()
167-
}
168-
}
169-
})
165+
this.hideMenu();
166+
},
167+
},
168+
});
170169
</script>
171170

172-
173171
<style lang='less' scoped>
174172
.menu-wrap {
175173
width: 196px;
@@ -204,4 +202,4 @@ export default ({
204202
color: red;
205203
}
206204
}
207-
</style>
205+
</style>

src/components/svgIcon/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
* @Description: file content
77
*/
88

9-
import svgIcon from './index.vue'
9+
import svgIcon from './index.vue';
1010

1111
export default {
12-
install(Vue) {
13-
Vue.component(svgIcon.name, svgIcon)
14-
}
15-
}
12+
install(Vue) {
13+
Vue.component(svgIcon.name, svgIcon);
14+
},
15+
};

src/components/svgIcon/index.vue

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<span>
3-
<svg t="1650443094178" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1549"
3+
<svg t="1650443094178" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1549"
44
:width="size" :height="size" :fill="color">
55
<!-- -->
66
<template v-if="name === 'default'">
@@ -18,24 +18,24 @@
1818
<script>
1919
export default {
2020
name: 'svgIcon',
21-
props:{
21+
props: {
2222
name: {
2323
type: String,
24-
default: 'default'
24+
default: 'default',
2525
},
2626
color: {
2727
type: String,
28-
default: '#ea9518'
28+
default: '#ea9518',
2929
},
3030
size: {
3131
type: Number,
32-
default: 14
33-
}
32+
default: 14,
33+
},
3434
},
3535
data() {
3636
return {};
3737
},
38-
methods:{}
38+
methods: {},
3939
};
4040
</script>
4141

src/locales/i18n.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import Vue from "vue";
2-
import VueI18n from "vue-i18n";
3-
import { getLocal, setLocal } from '@/utils/local'
4-
import { LANG } from '@/config/constants/app'
1+
import Vue from 'vue';
2+
import VueI18n from 'vue-i18n';
3+
import { getLocal, setLocal } from '@/utils/local';
4+
import { LANG } from '@/config/constants/app';
55

66
Vue.use(VueI18n);
77

88
function loadLocaleMessages() {
99
const locales = require.context(
10-
"@/locales/lang/",
10+
'@/locales/lang/',
1111
true,
12-
/[A-Za-z0-9-_,\s]+\.json$/i
12+
/[A-Za-z0-9-_,\s]+\.json$/i,
1313
);
1414
const messages = {};
15-
locales.keys().forEach(key => {
15+
locales.keys().forEach((key) => {
1616
const matched = key.match(/([A-Za-z0-9-_]+)\./i);
1717
if (matched && matched.length > 1) {
1818
const locale = matched[1];
@@ -23,20 +23,20 @@ function loadLocaleMessages() {
2323
}
2424

2525
function getLocalLang() {
26-
let localLang = getLocal(LANG)
27-
if(!localLang) {
28-
let defaultLang = navigator.language
29-
if(defaultLang) {
30-
defaultLang = localLang = defaultLang.split('-')[0]
26+
let localLang = getLocal(LANG);
27+
if (!localLang) {
28+
let defaultLang = navigator.language;
29+
if (defaultLang) {
30+
defaultLang = localLang = defaultLang.split('-')[0];
3131
}
32-
setLocal(LANG, defaultLang)
32+
setLocal(LANG, defaultLang);
3333
}
34-
return localLang
34+
return localLang;
3535
}
36-
const lang = getLocalLang()
37-
console.log(lang)
36+
const lang = getLocalLang();
37+
console.log(lang);
3838
export default new VueI18n({
3939
locale: lang,
4040
fallbackLocale: lang,
41-
messages: loadLocaleMessages()
41+
messages: loadLocaleMessages(),
4242
});

0 commit comments

Comments
 (0)