Skip to content

Commit 85bd7cb

Browse files
陈鑫陈鑫
authored andcommitted
添加airbnb代码规范教研
1 parent 73f074e commit 85bd7cb

Some content is hidden

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

62 files changed

+1070
-949
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/*
2+
public/*
3+
src/components/GlobalBg.vue
4+
vue.config.js

.eslintrc.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true,
5+
},
6+
extends: [
7+
'plugin:vue/essential',
8+
'@vue/airbnb',
9+
'@vue/typescript/recommended',
10+
],
11+
parserOptions: {
12+
ecmaVersion: 2020,
13+
},
14+
rules: {
15+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
16+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
17+
"@typescript-eslint/no-explicit-any": ["off"],
18+
"@typescript-eslint/no-empty-function": "off",
19+
"eqeqeq": "off", //是否开启==
20+
"class-methods-use-this": "off", //在方法中是否必须使用this
21+
"no-plusplus": "off", //不允许使用++ --运算符
22+
"no-param-reassign": "off", //不允许重新分配函数参数"no-proto": 2, //不允许使用__proto__属性
23+
"import/no-extraneous-dependencies": "off",
24+
"no-underscore-dangle": "off", //不允许标识符以下划线开头
25+
"global-require": "off",
26+
"import/no-cycle": 'off',
27+
"import/prefer-default-export": 'off',
28+
"import/no-dynamic-require": "off",
29+
"@typescript-eslint/camelcase": "off",
30+
"@typescript-eslint/no-empty-interface": "off",
31+
"@typescript-eslint/no-this-alias": "off",
32+
"@typescript-eslint/no-namespace": "off",
33+
"no-unused-expressions": "off", //不允许无用的表达式
34+
"no-lonely-if": "off",
35+
"object-curly-newline": "off",
36+
'comma-dangle': [0, 'never'],
37+
},
38+
};

.prettierrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
{
3+
"singleQuote": true,
4+
"semi": true
5+
}

package.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "vue-design-admin",
2+
"name": "vue-typescript-starter",
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
@@ -11,11 +11,13 @@
1111
"@antv/g6": "^3.6.0",
1212
"ant-design-vue": "^1.6.5",
1313
"axios": "0.19.0",
14+
"babel-polyfill": "^6.26.0",
1415
"core-js": "^3.6.5",
1516
"crypto-js": "^4.0.0",
1617
"echarts": "^4.7.0",
1718
"flv.js": "^1.5.0",
1819
"moment": "^2.24.0",
20+
"qs": "^6.9.6",
1921
"spark-md5": "^3.0.1",
2022
"vue": "^2.6.11",
2123
"vue-class-component": "^7.2.3",
@@ -28,20 +30,27 @@
2830
"vuex-module-decorators": "^0.17.0"
2931
},
3032
"devDependencies": {
33+
"@typescript-eslint/eslint-plugin": "^2.33.0",
34+
"@typescript-eslint/parser": "^2.33.0",
3135
"@vue/cli-plugin-babel": "~4.5.0",
36+
"@vue/cli-plugin-eslint": "~4.5.0",
3237
"@vue/cli-plugin-router": "~4.5.0",
3338
"@vue/cli-plugin-typescript": "~4.5.0",
3439
"@vue/cli-plugin-vuex": "~4.5.0",
3540
"@vue/cli-service": "~4.5.0",
36-
"babel-plugin-import": "^1.13.0",
37-
"babel-polyfill": "^6.26.0",
41+
"@vue/eslint-config-airbnb": "^5.0.2",
42+
"@vue/eslint-config-typescript": "^5.0.2",
43+
"babel-plugin-import": "^1.13.3",
3844
"compression-webpack-plugin": "^5.0.1",
39-
"es6-promise": "^4.2.8",
45+
"eslint": "^6.7.2",
46+
"eslint-plugin-import": "^2.20.2",
47+
"eslint-plugin-node": "^11.1.0",
48+
"eslint-plugin-promise": "^4.2.1",
49+
"eslint-plugin-vue": "^6.2.2",
4050
"less": "^3.0.4",
4151
"less-loader": "^5.0.0",
4252
"mockjs": "^1.1.0",
4353
"typescript": "~3.9.3",
44-
"vue-class": "^2.0.1",
4554
"vue-template-compiler": "^2.6.11"
4655
},
4756
"browserslist": [

src/App.vue

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
<template>
22
<div id="app">
3-
<router-view v-if="isRouterAlive"/>
3+
<router-view v-if="isRouterAlive" />
44
</div>
55
</template>
66

77
<script lang="ts">
8-
import { UserModule } from "@/store/modules/user";
9-
import { Component, Prop, Vue, Provide } from "vue-property-decorator";
8+
import { UserModule } from '@/store/modules/user';
9+
import { Component, Prop, Vue, Provide } from 'vue-property-decorator';
1010
1111
@Component({})
1212
export default class App extends Vue {
13-
private isRouterAlive: boolean = true;
13+
private isRouterAlive = true;
14+
1415
mounted() {
15-
const lang = sessionStorage.getItem("LANGUAGE");
16+
const lang = sessionStorage.getItem('LANGUAGE');
1617
if (!lang) {
17-
sessionStorage.setItem("LANGUAGE", "zh");
18+
sessionStorage.setItem('LANGUAGE', 'zh');
1819
}
1920
}
20-
//刷新页面
21+
22+
// 刷新页面
2123
@Provide()
2224
private reload() {
2325
this.isRouterAlive = false;
@@ -29,6 +31,6 @@ export default class App extends Vue {
2931
</script>
3032

3133
<style lang="less">
32-
@import "./public/css/base.css";
33-
@import "./public/css/init.less";
34+
@import './public/css/base.css';
35+
@import './public/css/init.less';
3436
</style>

src/api/users.ts

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
1-
import service from "@/utils/fetch"
2-
import qs from 'qs'
1+
import service from '@/utils/fetch';
2+
import qs from 'qs';
33

4-
//用户登录
5-
export const login = (params: any): any => {
6-
return service({
7-
method: "post",
8-
url: '/login',
9-
data: params
10-
})
11-
}
4+
// 用户登录
5+
export const login = (params: any): any => service({
6+
method: 'post',
7+
url: '/login',
8+
data: params,
9+
});
1210

13-
//用户登出
14-
export const logout = (params: any) => {
15-
return service({
16-
method: "get",
17-
url: '/logout',
18-
data: params
19-
})
20-
}
11+
// 用户登出
12+
export const logout = (params: any) => service({
13+
method: 'get',
14+
url: '/logout',
15+
data: params,
16+
});
2117

22-
//获取权限列表
23-
export const getPermissionsList = (params: any) => {
24-
return service({
25-
method: "get",
26-
url: "/navPerson",
27-
data: qs.stringify(params)
28-
})
29-
}
18+
// 获取权限列表
19+
export const getPermissionsList = (params: any) => service({
20+
method: 'get',
21+
url: '/navPerson',
22+
data: qs.stringify(params),
23+
});

src/components/Exception/ExceptionPage.vue

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<template>
22
<div class="exception">
33
<div class="imgBlock">
4-
<div class="imgEle" :style="{backgroundImage: `url(${config[type].img})`}"></div>
4+
<div class="imgEle"
5+
:style="{backgroundImage: `url(${config[type].img})`}"></div>
56
</div>
67
<div class="content">
78
<h1>{{ config[type].title }}</h1>
@@ -11,26 +12,27 @@
1112
</template>
1213

1314
<script lang="ts">
14-
import types from "./type";
15-
import { Component, Vue, Watch, Prop } from "vue-property-decorator";
15+
import { Component, Vue, Prop } from 'vue-property-decorator';
16+
import types from './type';
1617
1718
@Component
1819
export default class ExceptionPage extends Vue {
1920
@Prop({
2021
type: String,
2122
required: false,
22-
default: "404"
23+
default: '404',
2324
})
2425
type!: string;
2526
2627
private config: object = types;
28+
2729
private handleToHome() {
28-
this.$router.push("/");
30+
this.$router.push('/');
2931
}
3032
}
3133
</script>
3234
<style lang="less">
33-
@import "~ant-design-vue/lib/style/index";
35+
@import '~ant-design-vue/lib/style/index';
3436
3537
.exception {
3638
display: flex;
@@ -45,7 +47,7 @@ export default class ExceptionPage extends Vue {
4547
zoom: 1;
4648
&::before,
4749
&::after {
48-
content: " ";
50+
content: ' ';
4951
display: table;
5052
}
5153
&::after {

src/components/Exception/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
import ExceptionPage from './ExceptionPage.vue'
2-
export default ExceptionPage
1+
import ExceptionPage from './ExceptionPage.vue';
2+
3+
export default ExceptionPage;

src/components/Exception/type.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ const types = {
22
403: {
33
img: 'https://gw.alipayobjects.com/zos/rmsportal/wZcnGqRDyhPOEYFcZDnb.svg',
44
title: '403',
5-
desc: '抱歉,你无权访问该页面'
5+
desc: '抱歉,你无权访问该页面',
66
},
77
404: {
88
img: 'https://gw.alipayobjects.com/zos/rmsportal/KpnpchXsobRgLElEozzI.svg',
99
title: '404',
10-
desc: '抱歉,你访问的页面不存在或仍在开发中'
10+
desc: '抱歉,你访问的页面不存在或仍在开发中',
1111
},
1212
500: {
1313
img: 'https://gw.alipayobjects.com/zos/rmsportal/RVRUAYdCGeYNBWoKiIwB.svg',
1414
title: '500',
15-
desc: '抱歉,服务器出错了'
16-
}
17-
}
15+
desc: '抱歉,服务器出错了',
16+
},
17+
};
1818

19-
export default types
19+
export default types;

src/components/FlvPlayer.vue

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
<template>
2-
<video class="video-item" controls ref="flvPlayerElem" muted></video>
2+
<video class="video-item"
3+
controls
4+
ref="flvPlayerElem"
5+
muted></video>
36
</template>
47

58
<script lang="ts">
6-
import flv from "flv.js";
7-
import { message } from "ant-design-vue";
8-
import { Component, Vue, Prop, Ref } from "vue-property-decorator";
9+
import flv from 'flv.js';
10+
import { message } from 'ant-design-vue';
11+
import { Component, Vue, Prop } from 'vue-property-decorator';
912
1013
@Component
1114
export default class FlvPlayer extends Vue {
1215
@Prop({ type: String }) src!: string;
1316
14-
//inital data
15-
//初始化视频实例
17+
// inital data
18+
// 初始化视频实例
1619
private player: flv.Player = flv.createPlayer(
1720
{
18-
type: "flv",
19-
url: this.src
21+
type: 'flv',
22+
url: this.src,
2023
},
2124
{
2225
enableStashBuffer: false,
@@ -25,41 +28,43 @@ export default class FlvPlayer extends Vue {
2528
lazyLoadMaxDuration: 0,
2629
lazyLoadRecoverDuration: 0,
2730
deferLoadAfterSourceOpen: false,
28-
fixAudioTimestampGap: false
31+
fixAudioTimestampGap: false,
2932
}
3033
);
31-
//音量开始状态
32-
private muted: boolean = true;
33-
//是否现在播放
34-
private playing: boolean = false;
34+
35+
// 音量开始状态
36+
private muted = true;
37+
38+
// 是否现在播放
39+
private playing = false;
3540
3641
mounted() {
37-
//当前浏览器是否支持
38-
let isSupported: boolean = flv.isSupported();
42+
// 当前浏览器是否支持
43+
const isSupported: boolean = flv.isSupported();
3944
if (!isSupported) {
40-
message.error("当前浏览器不支持播放flv视频!");
45+
message.error('当前浏览器不支持播放flv视频!');
4146
} else {
42-
let videoElem = this.$refs["flvPlayerElem"] as HTMLMediaElement;
47+
const videoElem = this.$refs.flvPlayerElem as HTMLMediaElement;
4348
this.player.attachMediaElement(videoElem);
4449
this.player.load();
4550
this.play();
4651
}
4752
}
4853
49-
//inital methods
50-
//视频播放
54+
// inital methods
55+
// 视频播放
5156
play() {
5257
this.player.play();
5358
this.playing = true;
5459
}
5560
56-
//视频暂停
61+
// 视频暂停
5762
pause() {
5863
this.player.pause();
5964
this.playing = false;
6065
}
6166
62-
//视频销毁
67+
// 视频销毁
6368
destory() {
6469
this.player.destroy();
6570
this.playing = false;
@@ -73,4 +78,4 @@ export default class FlvPlayer extends Vue {
7378
height: 100%;
7479
object-fit: fill;
7580
}
76-
</style>
81+
</style>

0 commit comments

Comments
 (0)