feature: 配置eslint
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
module.exports ={
|
||||||
|
// 继承其他规则
|
||||||
|
'extends': ['eslint:recommended', 'plugin:vue/essential'],
|
||||||
|
// 解析选项
|
||||||
|
'parserOptions': {
|
||||||
|
'ecmaVersion': 6, // ES 语法版本
|
||||||
|
'sourceType': 'module', // ES 模块化
|
||||||
|
'ecmaFeatures': { // ES 其他特性
|
||||||
|
'jsx': true // 如果是 React 项目,就需要开启 jsx 语法
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
'@stylistic/js'
|
||||||
|
],
|
||||||
|
// 具体检查规则
|
||||||
|
'rules': {
|
||||||
|
'no-var': 'error', // 不能使用 var 定义变量
|
||||||
|
'eqeqeq': [
|
||||||
|
'warn', // 建议使用 === 和 !==,否则警告
|
||||||
|
'smart' // https://eslint.bootcss.com/docs/rules/eqeqeq#smart 除了少数情况下不会有警告
|
||||||
|
],
|
||||||
|
'prefer-arrow-callback': 'warn', // 建议使用箭头函数
|
||||||
|
'prefer-const': 'error', // 强制使用 const 定义常量
|
||||||
|
'indent': ['error', 2], // 缩进 2 个空格
|
||||||
|
// '@stylistic/js/indent': ['error', 2], // 缩进 2 个空格
|
||||||
|
'quotes': ['error', 'single'] // 强制使用单引号
|
||||||
|
},
|
||||||
|
env: {
|
||||||
|
node: true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,11 +43,14 @@
|
|||||||
"vuex": "^3.4.0"
|
"vuex": "^3.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@stylistic/eslint-plugin-js": "^1.5.1",
|
||||||
"@vue/cli-plugin-babel": "~4.5.0",
|
"@vue/cli-plugin-babel": "~4.5.0",
|
||||||
"@vue/cli-plugin-router": "~4.5.0",
|
"@vue/cli-plugin-router": "~4.5.0",
|
||||||
"@vue/cli-plugin-vuex": "~4.5.0",
|
"@vue/cli-plugin-vuex": "~4.5.0",
|
||||||
"@vue/cli-service": "~4.5.0",
|
"@vue/cli-service": "~4.5.0",
|
||||||
"babel-plugin-import": "^1.13.3",
|
"babel-plugin-import": "^1.13.3",
|
||||||
|
"eslint": "6.7.2",
|
||||||
|
"eslint-plugin-vue": "6.2.2",
|
||||||
"less": "^3.13.1",
|
"less": "^3.13.1",
|
||||||
"less-loader": "^5.0.0",
|
"less-loader": "^5.0.0",
|
||||||
"popper.js": "^1.16.1",
|
"popper.js": "^1.16.1",
|
||||||
|
|||||||
+28
-30
@@ -1,12 +1,12 @@
|
|||||||
import { webLoginType, ssoLogin, ssoLogout } from '@/sysConfig'
|
import { webLoginType, ssoLogin, ssoLogout } from '@/sysConfig'
|
||||||
import { getMenu, loginIdm } from "@/api/process";
|
import { getMenu, loginIdm } from '@/api/process'
|
||||||
import { getTokenToWeLink } from "@/api/phoneWeLink";
|
import { getTokenToWeLink } from '@/api/phoneWeLink'
|
||||||
import isMobile from "@/store/isMobile";
|
import isMobile from '@/store/isMobile'
|
||||||
import store from "@/store";
|
import store from '@/store'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import hwh5 from '@/api/hwh5-cloudonline.js'
|
import hwh5 from '@/api/hwh5-cloudonline.js'
|
||||||
import { Message, MessageBox, Loading } from "element-ui";
|
import { Message, MessageBox, Loading } from 'element-ui'
|
||||||
import { Dialog } from 'vant';
|
import { Dialog } from 'vant'
|
||||||
|
|
||||||
function getCode() {
|
function getCode() {
|
||||||
let url = window.location.href
|
let url = window.location.href
|
||||||
@@ -64,16 +64,18 @@ function loginInIdm(code) {
|
|||||||
let loading = Loading.service({
|
let loading = Loading.service({
|
||||||
lock: true,
|
lock: true,
|
||||||
text: '登录中...',
|
text: '登录中...',
|
||||||
spinner: 'el-icon-loading',
|
spinner: 'el-icon-loading'
|
||||||
})
|
})
|
||||||
let _formData = new FormData()
|
let _formData = new FormData()
|
||||||
_formData.append('code', code)
|
_formData.append('code', code)
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
loginIdm(_formData).then(res => {
|
loginIdm(_formData).then(res => {
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
loginNew(res).then(() => {
|
loginNew(res)
|
||||||
|
.then(() => {
|
||||||
resolve()
|
resolve()
|
||||||
}).finally(() => {
|
})
|
||||||
|
.finally(() => {
|
||||||
loading.close()
|
loading.close()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -92,22 +94,24 @@ function loginInPhone () {
|
|||||||
let loading = Loading.service({
|
let loading = Loading.service({
|
||||||
lock: true,
|
lock: true,
|
||||||
text: '登录中...',
|
text: '登录中...',
|
||||||
spinner: 'el-icon-loading',
|
spinner: 'el-icon-loading'
|
||||||
})
|
})
|
||||||
hwh5.getAuthCode().then(data => {
|
hwh5.getAuthCode().then(data => {
|
||||||
console.log("获取到了welinkCode", data)
|
console.log('获取到了welinkCode', data)
|
||||||
if (data) {
|
if (data) {
|
||||||
let code = data.code
|
let code = data.code
|
||||||
getTokenToWeLink({
|
getTokenToWeLink({
|
||||||
code: code,
|
code: code,
|
||||||
name: encodeURIComponent("standards"+"-"+"regulations"),
|
name: encodeURIComponent('standards' + '-' + 'regulations'),
|
||||||
type:"",
|
type: '',
|
||||||
corpCode:"",
|
corpCode: ''
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
loginNew(res).then(() => {
|
loginNew(res)
|
||||||
|
.then(() => {
|
||||||
resolve()
|
resolve()
|
||||||
}).finally(() => {
|
})
|
||||||
|
.finally(() => {
|
||||||
loading.close()
|
loading.close()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -138,7 +142,8 @@ function loginNew (res) {
|
|||||||
userInfo.userId = userInfo.usid
|
userInfo.userId = userInfo.usid
|
||||||
store.commit('setToken', userInfo.token)
|
store.commit('setToken', userInfo.token)
|
||||||
store.commit('setUserInfo', JSON.stringify(userInfo))
|
store.commit('setUserInfo', JSON.stringify(userInfo))
|
||||||
getMenu({ userId: store.getters.userInfo.userId }).then(menuRes => {
|
getMenu({ userId: store.getters.userInfo.userId })
|
||||||
|
.then(menuRes => {
|
||||||
if (menuRes.ok) {
|
if (menuRes.ok) {
|
||||||
let hasHomeMenu = false
|
let hasHomeMenu = false
|
||||||
const menuList = menuRes.data
|
const menuList = menuRes.data
|
||||||
@@ -155,7 +160,8 @@ function loginNew (res) {
|
|||||||
} else {
|
} else {
|
||||||
reject(menuRes)
|
reject(menuRes)
|
||||||
}
|
}
|
||||||
}).catch(e => {
|
})
|
||||||
|
.catch(e => {
|
||||||
reject(e)
|
reject(e)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -165,18 +171,18 @@ function quit () {
|
|||||||
Message.warning('系统无权限访问')
|
Message.warning('系统无权限访问')
|
||||||
if (isMobile()) {
|
if (isMobile()) {
|
||||||
Dialog.confirm({
|
Dialog.confirm({
|
||||||
message: '您没有系统访问权限,请联系管理员进行授权',
|
message: '您没有系统访问权限,请联系管理员进行授权'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
store.dispatch('logout').then(() => {
|
store.dispatch('logout').then(() => {
|
||||||
close()
|
close()
|
||||||
})
|
})
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
MessageBox.confirm('您没有系统访问权限,请联系管理员进行授权', '提示', {
|
MessageBox.confirm('您没有系统访问权限,请联系管理员进行授权', '提示', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
showClose: false,
|
showClose: false,
|
||||||
showCancelButton: false,
|
showCancelButton: false
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
store.dispatch('logout').then(() => {
|
store.dispatch('logout').then(() => {
|
||||||
window.location.href = ssoLogout + encodeURIComponent(window.location.origin)
|
window.location.href = ssoLogout + encodeURIComponent(window.location.origin)
|
||||||
@@ -191,12 +197,4 @@ function close () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export { toIdmLoginPage, getCode, loginInIdm, loginInPhone, loginAgain, loginOut, close }
|
||||||
toIdmLoginPage,
|
|
||||||
getCode,
|
|
||||||
loginInIdm,
|
|
||||||
loginInPhone,
|
|
||||||
loginAgain,
|
|
||||||
loginOut,
|
|
||||||
close
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user