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",
|
||||||
|
|||||||
+62
-64
@@ -1,23 +1,23 @@
|
|||||||
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
|
||||||
if (url && url !== '') {
|
if (url && url !== '') {
|
||||||
if (url.split('code=').length > 1) {
|
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') {
|
if (webLoginType === 'idm') {
|
||||||
let href = url
|
let href = url
|
||||||
if (href.indexOf('localhost:9090' > -1)) {
|
if (href.indexOf('localhost:9090' > -1)) {
|
||||||
@@ -29,7 +29,7 @@ function toIdmLoginPage (url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 重新登录
|
// 重新登录
|
||||||
function loginAgain () {
|
function loginAgain() {
|
||||||
store.dispatch('logout').then(() => {
|
store.dispatch('logout').then(() => {
|
||||||
if (webLoginType === 'idm') {
|
if (webLoginType === 'idm') {
|
||||||
if (isMobile()) {
|
if (isMobile()) {
|
||||||
@@ -47,7 +47,7 @@ function loginAgain () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 退出登录
|
// 退出登录
|
||||||
function loginOut () {
|
function loginOut() {
|
||||||
store.dispatch('logout').then(() => {
|
store.dispatch('logout').then(() => {
|
||||||
if (webLoginType === 'idm') {
|
if (webLoginType === 'idm') {
|
||||||
window.location.href = ssoLogout + encodeURIComponent(window.location.origin)
|
window.location.href = ssoLogout + encodeURIComponent(window.location.origin)
|
||||||
@@ -64,20 +64,22 @@ 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)
|
||||||
resolve()
|
.then(() => {
|
||||||
}).finally(() => {
|
resolve()
|
||||||
loading.close()
|
})
|
||||||
})
|
.finally(() => {
|
||||||
|
loading.close()
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
if(res.respCode && res.respCode === 'r0011'){
|
if (res.respCode && res.respCode === 'r0011') {
|
||||||
quit()
|
quit()
|
||||||
loading.close()
|
loading.close()
|
||||||
}
|
}
|
||||||
@@ -87,31 +89,33 @@ function loginInIdm(code) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// welink登录
|
// welink登录
|
||||||
function loginInPhone () {
|
function loginInPhone() {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
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)
|
||||||
resolve()
|
.then(() => {
|
||||||
}).finally(() => {
|
resolve()
|
||||||
loading.close()
|
})
|
||||||
})
|
.finally(() => {
|
||||||
|
loading.close()
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
if(res.respCode && res.respCode === 'r0011'){
|
if (res.respCode && res.respCode === 'r0011') {
|
||||||
quit()
|
quit()
|
||||||
loading.close()
|
loading.close()
|
||||||
}
|
}
|
||||||
@@ -124,7 +128,7 @@ function loginInPhone () {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function loginNew (res) {
|
function loginNew(res) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (res.data.orgId === null || res.data.orgId === '') {
|
if (res.data.orgId === null || res.data.orgId === '') {
|
||||||
Message.warning('未分配组织机构,请联系管理员分配后重新登录')
|
Message.warning('未分配组织机构,请联系管理员分配后重新登录')
|
||||||
@@ -138,45 +142,47 @@ 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 })
|
||||||
if (menuRes.ok) {
|
.then(menuRes => {
|
||||||
let hasHomeMenu = false
|
if (menuRes.ok) {
|
||||||
const menuList = menuRes.data
|
let hasHomeMenu = false
|
||||||
menuList.forEach(menu => {
|
const menuList = menuRes.data
|
||||||
if (menu.id === 'asdfadf') {
|
menuList.forEach(menu => {
|
||||||
hasHomeMenu = true
|
if (menu.id === 'asdfadf') {
|
||||||
}
|
hasHomeMenu = true
|
||||||
})
|
}
|
||||||
if (hasHomeMenu) {
|
|
||||||
store.dispatch('setMenu', JSON.stringify(menuList)).then(() => {
|
|
||||||
resolve()
|
|
||||||
})
|
})
|
||||||
|
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('系统无权限访问')
|
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)
|
||||||
@@ -185,18 +191,10 @@ function quit () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function close () {
|
function close() {
|
||||||
if (isMobile()) {
|
if (isMobile()) {
|
||||||
hwh5.close()
|
hwh5.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export { toIdmLoginPage, getCode, loginInIdm, loginInPhone, loginAgain, loginOut, close }
|
||||||
toIdmLoginPage,
|
|
||||||
getCode,
|
|
||||||
loginInIdm,
|
|
||||||
loginInPhone,
|
|
||||||
loginAgain,
|
|
||||||
loginOut,
|
|
||||||
close
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user