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"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@stylistic/eslint-plugin-js": "^1.5.1",
|
||||
"@vue/cli-plugin-babel": "~4.5.0",
|
||||
"@vue/cli-plugin-router": "~4.5.0",
|
||||
"@vue/cli-plugin-vuex": "~4.5.0",
|
||||
"@vue/cli-service": "~4.5.0",
|
||||
"babel-plugin-import": "^1.13.3",
|
||||
"eslint": "6.7.2",
|
||||
"eslint-plugin-vue": "6.2.2",
|
||||
"less": "^3.13.1",
|
||||
"less-loader": "^5.0.0",
|
||||
"popper.js": "^1.16.1",
|
||||
|
||||
+62
-64
@@ -1,23 +1,23 @@
|
||||
import { webLoginType, ssoLogin, ssoLogout } from '@/sysConfig'
|
||||
import { getMenu, loginIdm } from "@/api/process";
|
||||
import { getTokenToWeLink } from "@/api/phoneWeLink";
|
||||
import isMobile from "@/store/isMobile";
|
||||
import store from "@/store";
|
||||
import { getMenu, loginIdm } from '@/api/process'
|
||||
import { getTokenToWeLink } from '@/api/phoneWeLink'
|
||||
import isMobile from '@/store/isMobile'
|
||||
import store from '@/store'
|
||||
import router from '@/router'
|
||||
import hwh5 from '@/api/hwh5-cloudonline.js'
|
||||
import { Message, MessageBox, Loading } from "element-ui";
|
||||
import { Dialog } from 'vant';
|
||||
import { Message, MessageBox, Loading } from 'element-ui'
|
||||
import { Dialog } from 'vant'
|
||||
|
||||
function getCode () {
|
||||
function getCode() {
|
||||
let url = window.location.href
|
||||
if (url && url !== '') {
|
||||
if (url.split('code=').length > 1) {
|
||||
return url.split('code=')[1]
|
||||
return url.split('code=')[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toIdmLoginPage (url) {
|
||||
function toIdmLoginPage(url) {
|
||||
if (webLoginType === 'idm') {
|
||||
let href = url
|
||||
if (href.indexOf('localhost:9090' > -1)) {
|
||||
@@ -29,7 +29,7 @@ function toIdmLoginPage (url) {
|
||||
}
|
||||
|
||||
// 重新登录
|
||||
function loginAgain () {
|
||||
function loginAgain() {
|
||||
store.dispatch('logout').then(() => {
|
||||
if (webLoginType === 'idm') {
|
||||
if (isMobile()) {
|
||||
@@ -47,7 +47,7 @@ function loginAgain () {
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
function loginOut () {
|
||||
function loginOut() {
|
||||
store.dispatch('logout').then(() => {
|
||||
if (webLoginType === 'idm') {
|
||||
window.location.href = ssoLogout + encodeURIComponent(window.location.origin)
|
||||
@@ -64,20 +64,22 @@ function loginInIdm(code) {
|
||||
let loading = Loading.service({
|
||||
lock: true,
|
||||
text: '登录中...',
|
||||
spinner: 'el-icon-loading',
|
||||
spinner: 'el-icon-loading'
|
||||
})
|
||||
let _formData = new FormData()
|
||||
_formData.append('code', code)
|
||||
// 获取用户信息
|
||||
loginIdm(_formData).then(res => {
|
||||
if (res.ok) {
|
||||
loginNew(res).then(() => {
|
||||
resolve()
|
||||
}).finally(() => {
|
||||
loading.close()
|
||||
})
|
||||
loginNew(res)
|
||||
.then(() => {
|
||||
resolve()
|
||||
})
|
||||
.finally(() => {
|
||||
loading.close()
|
||||
})
|
||||
} else {
|
||||
if(res.respCode && res.respCode === 'r0011'){
|
||||
if (res.respCode && res.respCode === 'r0011') {
|
||||
quit()
|
||||
loading.close()
|
||||
}
|
||||
@@ -87,31 +89,33 @@ function loginInIdm(code) {
|
||||
}
|
||||
|
||||
// welink登录
|
||||
function loginInPhone () {
|
||||
function loginInPhone() {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let loading = Loading.service({
|
||||
lock: true,
|
||||
text: '登录中...',
|
||||
spinner: 'el-icon-loading',
|
||||
spinner: 'el-icon-loading'
|
||||
})
|
||||
hwh5.getAuthCode().then(data => {
|
||||
console.log("获取到了welinkCode", data)
|
||||
console.log('获取到了welinkCode', data)
|
||||
if (data) {
|
||||
let code = data.code
|
||||
getTokenToWeLink({
|
||||
code: code,
|
||||
name: encodeURIComponent("standards"+"-"+"regulations"),
|
||||
type:"",
|
||||
corpCode:"",
|
||||
name: encodeURIComponent('standards' + '-' + 'regulations'),
|
||||
type: '',
|
||||
corpCode: ''
|
||||
}).then(res => {
|
||||
if (res.ok) {
|
||||
loginNew(res).then(() => {
|
||||
resolve()
|
||||
}).finally(() => {
|
||||
loading.close()
|
||||
})
|
||||
loginNew(res)
|
||||
.then(() => {
|
||||
resolve()
|
||||
})
|
||||
.finally(() => {
|
||||
loading.close()
|
||||
})
|
||||
} else {
|
||||
if(res.respCode && res.respCode === 'r0011'){
|
||||
if (res.respCode && res.respCode === 'r0011') {
|
||||
quit()
|
||||
loading.close()
|
||||
}
|
||||
@@ -124,7 +128,7 @@ function loginInPhone () {
|
||||
})
|
||||
}
|
||||
|
||||
function loginNew (res) {
|
||||
function loginNew(res) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (res.data.orgId === null || res.data.orgId === '') {
|
||||
Message.warning('未分配组织机构,请联系管理员分配后重新登录')
|
||||
@@ -138,45 +142,47 @@ function loginNew (res) {
|
||||
userInfo.userId = userInfo.usid
|
||||
store.commit('setToken', userInfo.token)
|
||||
store.commit('setUserInfo', JSON.stringify(userInfo))
|
||||
getMenu({ userId: store.getters.userInfo.userId }).then(menuRes => {
|
||||
if (menuRes.ok) {
|
||||
let hasHomeMenu = false
|
||||
const menuList = menuRes.data
|
||||
menuList.forEach(menu => {
|
||||
if (menu.id === 'asdfadf') {
|
||||
hasHomeMenu = true
|
||||
}
|
||||
})
|
||||
if (hasHomeMenu) {
|
||||
store.dispatch('setMenu', JSON.stringify(menuList)).then(() => {
|
||||
resolve()
|
||||
getMenu({ userId: store.getters.userInfo.userId })
|
||||
.then(menuRes => {
|
||||
if (menuRes.ok) {
|
||||
let hasHomeMenu = false
|
||||
const menuList = menuRes.data
|
||||
menuList.forEach(menu => {
|
||||
if (menu.id === 'asdfadf') {
|
||||
hasHomeMenu = true
|
||||
}
|
||||
})
|
||||
if (hasHomeMenu) {
|
||||
store.dispatch('setMenu', JSON.stringify(menuList)).then(() => {
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
} else {
|
||||
reject(menuRes)
|
||||
}
|
||||
} else {
|
||||
reject(menuRes)
|
||||
}
|
||||
}).catch(e => {
|
||||
reject(e)
|
||||
})
|
||||
})
|
||||
.catch(e => {
|
||||
reject(e)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function quit () {
|
||||
function quit() {
|
||||
Message.warning('系统无权限访问')
|
||||
if(isMobile()) {
|
||||
if (isMobile()) {
|
||||
Dialog.confirm({
|
||||
message: '您没有系统访问权限,请联系管理员进行授权',
|
||||
message: '您没有系统访问权限,请联系管理员进行授权'
|
||||
}).then(() => {
|
||||
store.dispatch('logout').then(() => {
|
||||
close()
|
||||
})
|
||||
});
|
||||
})
|
||||
} else {
|
||||
MessageBox.confirm('您没有系统访问权限,请联系管理员进行授权', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
type: 'warning',
|
||||
showClose: false,
|
||||
showCancelButton: false,
|
||||
showCancelButton: false
|
||||
}).then(() => {
|
||||
store.dispatch('logout').then(() => {
|
||||
window.location.href = ssoLogout + encodeURIComponent(window.location.origin)
|
||||
@@ -185,18 +191,10 @@ function quit () {
|
||||
}
|
||||
}
|
||||
|
||||
function close () {
|
||||
function close() {
|
||||
if (isMobile()) {
|
||||
hwh5.close()
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
toIdmLoginPage,
|
||||
getCode,
|
||||
loginInIdm,
|
||||
loginInPhone,
|
||||
loginAgain,
|
||||
loginOut,
|
||||
close
|
||||
}
|
||||
export { toIdmLoginPage, getCode, loginInIdm, loginInPhone, loginAgain, loginOut, close }
|
||||
|
||||
Reference in New Issue
Block a user