feat: ESlint格式化前端代码

This commit is contained in:
fit2cloud-chenyw 2021-03-08 21:10:16 +08:00
parent 0d3e1d093f
commit c34ad9a026
7 changed files with 388 additions and 371 deletions

View File

@ -46,6 +46,7 @@ public class F2CRealm extends AuthorizingRealm {
}
//验证登录权限
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
String token = (String) auth.getCredentials();
@ -63,7 +64,6 @@ public class F2CRealm extends AuthorizingRealm {
}
String pass = null;
try {
/*pass = RsaUtil.decryptByPrivateKey(RsaProperties.privateKey, userBean.getPassword());*/
pass = user.getPassword();
} catch (Exception e) {
e.printStackTrace();

View File

@ -6,18 +6,20 @@ import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTDecodeException;
import com.auth0.jwt.interfaces.DecodedJWT;
import io.dataease.auth.entity.TokenInfo;
import io.dataease.commons.utils.ServletUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
public class JWTUtils {
// token过期时间5分钟 (过期会自动刷新续命 目的是避免一直都是同一个token )
// token过期时间5min (过期会自动刷新续命 目的是避免一直都是同一个token )
private static final long EXPIRE_TIME = 1*60*1000;
// 登录间隔时间 超过这个时间强制重新登录
private static final long Login_Interval = 2*60*1000;
// 登录间隔时间10min 超过这个时间强制重新登录
private static final long Login_Interval = 10*60*1000;
/**
@ -33,7 +35,17 @@ public class JWTUtils {
.withClaim("username", tokenInfo.getUsername())
.withClaim("userId", tokenInfo.getUserId())
.build();
verifier.verify(token);
DecodedJWT jwt = verifier.verify(token);
Long lastLoginTime = jwt.getClaim("lastLoginTime").asLong();
long now = System.currentTimeMillis();
if (now - lastLoginTime > Login_Interval){
// 登录超时
HttpServletResponse response = ServletUtils.response();
response.addHeader("Access-Control-Expose-Headers", "authentication-status");
response.setHeader("authentication-status", "login_expire");
// 前端拦截 登录超时状态 直接logout
return false;
}
return true;
}

View File

@ -108,4 +108,4 @@ export function post(url, data) {
})
}
export default { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree,defaultTree }
export default { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree, defaultTree }

View File

@ -683,10 +683,10 @@ export default {
},
panel: {
datalist: '视图列表',
group:'目录',
panel:'仪表盘',
groupAdd:'新建目录',
panelAdd:'新建仪表盘',
group: '目录',
panel: '仪表盘',
groupAdd: '新建目录',
panelAdd: '新建仪表盘',
delete: '删除',
move_to: '移动到',
rename: '重命名',

View File

@ -52,6 +52,14 @@ const checkAuth = response => {
})
})
}
if (response.headers['authentication-status'] === 'login_expire') {
const message = this.$t('login.expires')
$alert(message, () => {
store.dispatch('user/logout').then(() => {
location.reload()
})
})
}
// token到期后自动续命 刷新token
if (response.headers[RefreshTokenKey]) {
const refreshToken = response.headers[RefreshTokenKey]

View File

@ -4,65 +4,65 @@
<ms-aside-container>
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane name="PanelList">
<span slot="label"><i class="el-icon-document"></i>列表</span>
<PanelList @switchComponent="switchComponent"/>
<span slot="label"><i class="el-icon-document" />列表</span>
<PanelList @switchComponent="switchComponent" />
</el-tab-pane>
<el-tab-pane name="panels_star">
<span slot="label"><i class="el-icon-star-off"></i>收藏</span>
<span slot="label"><i class="el-icon-star-off" />收藏</span>
开发中...
</el-tab-pane>
<el-tab-pane name="panels_share">
<span slot="label"><i class="el-icon-share"></i>分享</span>
<span slot="label"><i class="el-icon-share" />分享</span>
开发中...
</el-tab-pane>
<!-- <el-tab-pane name="example">-->
<!-- <span slot="label"><i class="el-icon-star-on"></i>示例</span>-->
<!-- <group @switchComponent="switchComponent"/>-->
<!-- </el-tab-pane>-->
<!-- <el-tab-pane name="example">-->
<!-- <span slot="label"><i class="el-icon-star-on"></i>示例</span>-->
<!-- <group @switchComponent="switchComponent"/>-->
<!-- </el-tab-pane>-->
</el-tabs>
</ms-aside-container>
<ms-main-container>
<!--<router-view/>-->
<component :is="component" :param="param" @switchComponent="switchComponent"/>
<component :is="component" :param="param" @switchComponent="switchComponent" />
</ms-main-container>
</ms-container>
</template>
<script>
import MsMainContainer from '@/metersphere/common/components/MsMainContainer'
import MsContainer from '@/metersphere/common/components/MsContainer'
import MsAsideContainer from '@/metersphere/common/components/MsAsideContainer'
// import Group from './group/Group'
import PanelList from './list/PanelList'
import PanelView from './list/PanelView'
import MsMainContainer from '@/metersphere/common/components/MsMainContainer'
import MsContainer from '@/metersphere/common/components/MsContainer'
import MsAsideContainer from '@/metersphere/common/components/MsAsideContainer'
// import Group from './group/Group'
import PanelList from './list/PanelList'
import PanelView from './list/PanelView'
export default {
name: 'Panel',
components: {MsMainContainer, MsContainer, MsAsideContainer, PanelList,PanelView},
data() {
return {
component: PanelView,
param: {},
activeName: 'PanelList'
}
export default {
name: 'Panel',
components: { MsMainContainer, MsContainer, MsAsideContainer, PanelList, PanelView },
data() {
return {
component: PanelView,
param: {},
activeName: 'PanelList'
}
},
methods: {
handleClick(tab, event) {
console.log(tab, event)
},
methods: {
handleClick(tab, event) {
console.log(tab, event)
},
switchComponent(c) {
console.log(c)
this.param = c.param
switch (c.name) {
case 'PanelView':
this.component = PanelView
break
}
switchComponent(c) {
console.log(c)
this.param = c.param
switch (c.name) {
case 'PanelView':
this.component = PanelView
break
}
}
}
}
</script>
<style scoped>

View File

@ -97,7 +97,7 @@
<el-dialog :title="dialogTitle" :visible="editGroup" :show-close="false" width="30%">
<el-form ref="groupForm" :model="groupForm" :rules="groupFormRules">
<el-form-item :label="$t('commons.name')" prop="name">
<el-input v-model="groupForm.name"/>
<el-input v-model="groupForm.name" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@ -111,359 +111,356 @@
</template>
<script>
import {loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree,defaultTree} from '@/api/panel/panel'
import { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree, defaultTree } from '@/api/panel/panel'
export default {
name: 'PanelList',
data() {
export default {
name: 'PanelList',
data() {
return {
defaultData: [],
dialogTitle: '',
search: '',
editGroup: false,
editTable: false,
tData: [],
tableData: [],
currGroup: {},
expandedArray: [],
groupForm: {
name: null,
pid: null,
level: 0,
nodeType: null,
children: [],
sort: 'node_type desc,name asc'
},
tableForm: {
name: '',
mode: '',
sort: 'node_type asc,create_time desc,name asc'
},
groupFormRules: {
name: [
{ required: true, message: this.$t('commons.input_content'), trigger: 'blur' }
]
},
tableFormRules: {
name: [
{ required: true, message: this.$t('commons.input_content'), trigger: 'blur' }
],
mode: [
{ required: true, message: this.$t('commons.input_content'), trigger: 'blur' }
]
}
}
},
computed: {
},
watch: {
// search(val){
// this.groupForm.name = val;
// this.tree(this.groupForm);
// }
},
mounted() {
this.defaultTree()
this.tree(this.groupForm)
this.refresh()
this.tableTree()
// this.$router.push('/dataset');
},
methods: {
clickAdd(param) {
// console.log(param);
this.add(param.type)
this.groupForm.pid = param.data.id
this.groupForm.level = param.data.level + 1
},
beforeClickAdd(type, data, node) {
return {
defaultData:[],
dialogTitle: '',
search: '',
editGroup: false,
editTable: false,
tData: [],
tableData: [],
currGroup: {},
expandedArray: [],
groupForm: {
name: null,
pid: null,
level: 0,
nodeType: null,
children: [],
sort: 'node_type desc,name asc'
},
tableForm: {
name: '',
mode: '',
sort: 'node_type asc,create_time desc,name asc'
},
groupFormRules: {
name: [
{required: true, message: this.$t('commons.input_content'), trigger: 'blur'}
]
},
tableFormRules: {
name: [
{required: true, message: this.$t('commons.input_content'), trigger: 'blur'}
],
mode: [
{required: true, message: this.$t('commons.input_content'), trigger: 'blur'}
]
}
'type': type,
'data': data,
'node': node
}
},
computed: {
clickMore(param) {
console.log(param)
switch (param.type) {
case 'rename':
this.add(param.data.nodeType)
this.groupForm = JSON.parse(JSON.stringify(param.data))
break
case 'move':
break
case 'delete':
this.delete(param.data)
break
case 'editTable':
this.editTable = true
this.tableForm = JSON.parse(JSON.stringify(param.data))
this.tableForm.mode = this.tableForm.mode + ''
break
case 'deleteTable':
this.deleteTable(param.data)
break
}
},
watch: {
// search(val){
// this.groupForm.name = val;
// this.tree(this.groupForm);
// }
beforeClickMore(type, data, node) {
return {
'type': type,
'data': data,
'node': node
}
},
mounted() {
this.defaultTree()
this.tree(this.groupForm)
this.refresh()
this.tableTree()
// this.$router.push('/dataset');
add(nodeType) {
switch (nodeType) {
case 'folder':
this.dialogTitle = this.$t('panel.groupAdd')
break
case 'panel':
this.dialogTitle = this.$t('panel.panelAdd')
break
}
this.groupForm.nodeType = nodeType
this.editGroup = true
},
methods: {
clickAdd(param) {
// console.log(param);
this.add(param.type)
this.groupForm.pid = param.data.id
this.groupForm.level = param.data.level + 1
},
beforeClickAdd(type, data, node) {
return {
'type': type,
'data': data,
'node': node
}
},
clickMore(param) {
console.log(param)
switch (param.type) {
case 'rename':
this.add(param.data.nodeType)
this.groupForm = JSON.parse(JSON.stringify(param.data))
break
case 'move':
break
case 'delete':
this.delete(param.data)
break
case 'editTable':
this.editTable = true
this.tableForm = JSON.parse(JSON.stringify(param.data))
this.tableForm.mode = this.tableForm.mode + ''
break
case 'deleteTable':
this.deleteTable(param.data)
break
}
},
beforeClickMore(type, data, node) {
return {
'type': type,
'data': data,
'node': node
}
},
add(nodeType) {
switch (nodeType) {
case 'folder':
this.dialogTitle = this.$t('panel.groupAdd')
break
case 'panel':
this.dialogTitle = this.$t('panel.panelAdd')
break
}
this.groupForm.nodeType = nodeType
this.editGroup = true
},
saveGroup(group) {
// console.log(group);
this.$refs['groupForm'].validate((valid) => {
if (valid) {
addGroup(group).then(res => {
this.close()
this.$message({
message: this.$t('commons.save_success'),
type: 'success',
showClose: true
})
this.tree(this.groupForm)
})
} else {
this.$message({
message: this.$t('commons.input_content'),
type: 'error',
showClose: true
})
return false
}
})
},
saveTable(table) {
// console.log(table)
table.mode = parseInt(table.mode)
this.$refs['tableForm'].validate((valid) => {
if (valid) {
addTable(table).then(response => {
this.closeTable()
this.$message({
message: this.$t('commons.save_success'),
type: 'success',
showClose: true
})
this.tableTree()
// this.$router.push('/dataset/home')
this.$emit('switchComponent', {name: ''})
this.$store.dispatch('dataset/setTable', null)
})
} else {
this.$message({
message: this.$t('commons.input_content'),
type: 'error',
showClose: true
})
return false
}
})
},
delete(data) {
this.$confirm(this.$t('panel.confirm_delete'), this.$t('panel.tips'), {
confirmButtonText: this.$t('panel.confirm'),
cancelButtonText: this.$t('panel.cancel'),
type: 'warning'
}).then(() => {
delGroup(data.id).then(response => {
saveGroup(group) {
// console.log(group);
this.$refs['groupForm'].validate((valid) => {
if (valid) {
addGroup(group).then(res => {
this.close()
this.$message({
message: this.$t('commons.save_success'),
type: 'success',
message: this.$t('panel.delete_success'),
showClose: true
})
this.tree(this.groupForm)
})
}).catch(() => {
})
},
} else {
this.$message({
message: this.$t('commons.input_content'),
type: 'error',
showClose: true
})
return false
}
})
},
deleteTable(data) {
this.$confirm(this.$t('panel.confirm_delete'), this.$t('panel.tips'), {
confirmButtonText: this.$t('panel.confirm'),
cancelButtonText: this.$t('panel.cancel'),
type: 'warning'
}).then(() => {
delTable(data.id).then(response => {
saveTable(table) {
// console.log(table)
table.mode = parseInt(table.mode)
this.$refs['tableForm'].validate((valid) => {
if (valid) {
addTable(table).then(response => {
this.closeTable()
this.$message({
message: this.$t('commons.save_success'),
type: 'success',
message: this.$t('panel.delete_success'),
showClose: true
})
this.tableTree()
// this.$router.push('/dataset/home')
this.$emit('switchComponent', {name: ''})
this.$emit('switchComponent', { name: '' })
this.$store.dispatch('dataset/setTable', null)
})
}).catch(() => {
})
},
close() {
this.editGroup = false
this.groupForm = {
name: null,
pid: null,
level: 0,
nodeType: null,
children: [],
sort: 'node_type desc,name asc'
}
},
closeTable() {
this.editTable = false
this.tableForm = {
name: ''
}
},
tree(group) {
groupTree(group).then(res => {
this.tData = res.data
})
},
defaultTree() {
let requestInfo ={
panelType: 'system'
}
defaultTree(requestInfo).then(res => {
this.defaultData = res.data
})
},
tableTree() {
this.tableData = []
if (this.currGroup.id) {
loadTable({
sort: 'type asc,create_time desc,name asc',
sceneId: this.currGroup.id
}).then(res => {
this.tableData = res.data
})
}
},
nodeClick(data, node) {
// console.log(data);
// console.log(node);
if (data.nodeType === 'panel') {
this.sceneMode = true
this.currGroup = data
this.$store.dispatch('dataset/setSceneData', this.currGroup.id)
}
if (node.expanded) {
this.expandedArray.push(data.id)
} else {
const index = this.expandedArray.indexOf(data.id)
if (index > -1) {
this.expandedArray.splice(index, 1)
}
}
// console.log(this.expandedArray);
},
back() {
this.sceneMode = false
// const route = this.$store.state.permission.currentRoutes
// console.log(route)
// this.$router.push('/dataset/index')
this.$store.dispatch('dataset/setSceneData', null)
this.$emit('switchComponent', {name: ''})
},
clickAddData(param) {
// console.log(param);
switch (param.type) {
case 'db':
this.addDB()
break
case 'sql':
this.$message(param.type)
break
case 'excel':
this.$message(param.type)
break
case 'custom':
this.$message(param.type)
break
}
},
beforeClickAddData(type) {
return {
'type': type
}
},
addDB() {
// this.$router.push({
// name: 'add_db',
// params: {
// scene: this.currGroup
// }
// })
this.$emit('switchComponent', {name: 'AddDB', param: this.currGroup})
},
sceneClick(data, node) {
// console.log(data);
this.$store.dispatch('dataset/setTable', null)
this.$store.dispatch('dataset/setTable', data.id)
// this.$router.push({
// name: 'table',
// params: {
// table: data
// }
// })
this.$emit('switchComponent', {name: 'ViewTable'})
},
refresh() {
const path = this.$route.path
if (path === '/dataset/table') {
this.sceneMode = true
const sceneId = this.$store.state.dataset.sceneData
getScene(sceneId).then(res => {
this.currGroup = res.data
this.$message({
message: this.$t('commons.input_content'),
type: 'error',
showClose: true
})
return false
}
},
panelDefaultClick(data, node) {
console.log(data);
console.log(node);
this.$store.dispatch('panel/setPanelName', data.name)
//view
this.$emit('switchComponent', {name: 'PanelView'})
})
},
delete(data) {
this.$confirm(this.$t('panel.confirm_delete'), this.$t('panel.tips'), {
confirmButtonText: this.$t('panel.confirm'),
cancelButtonText: this.$t('panel.cancel'),
type: 'warning'
}).then(() => {
delGroup(data.id).then(response => {
this.$message({
type: 'success',
message: this.$t('panel.delete_success'),
showClose: true
})
this.tree(this.groupForm)
})
}).catch(() => {
})
},
},
deleteTable(data) {
this.$confirm(this.$t('panel.confirm_delete'), this.$t('panel.tips'), {
confirmButtonText: this.$t('panel.confirm'),
cancelButtonText: this.$t('panel.cancel'),
type: 'warning'
}).then(() => {
delTable(data.id).then(response => {
this.$message({
type: 'success',
message: this.$t('panel.delete_success'),
showClose: true
})
this.tableTree()
// this.$router.push('/dataset/home')
this.$emit('switchComponent', { name: '' })
this.$store.dispatch('dataset/setTable', null)
})
}).catch(() => {
})
},
close() {
this.editGroup = false
this.groupForm = {
name: null,
pid: null,
level: 0,
nodeType: null,
children: [],
sort: 'node_type desc,name asc'
}
},
closeTable() {
this.editTable = false
this.tableForm = {
name: ''
}
},
tree(group) {
groupTree(group).then(res => {
this.tData = res.data
})
},
defaultTree() {
const requestInfo = {
panelType: 'system'
}
defaultTree(requestInfo).then(res => {
this.defaultData = res.data
})
},
tableTree() {
this.tableData = []
if (this.currGroup.id) {
loadTable({
sort: 'type asc,create_time desc,name asc',
sceneId: this.currGroup.id
}).then(res => {
this.tableData = res.data
})
}
},
nodeClick(data, node) {
// console.log(data);
// console.log(node);
if (data.nodeType === 'panel') {
this.sceneMode = true
this.currGroup = data
this.$store.dispatch('dataset/setSceneData', this.currGroup.id)
}
if (node.expanded) {
this.expandedArray.push(data.id)
} else {
const index = this.expandedArray.indexOf(data.id)
if (index > -1) {
this.expandedArray.splice(index, 1)
}
}
// console.log(this.expandedArray);
},
back() {
this.sceneMode = false
// const route = this.$store.state.permission.currentRoutes
// console.log(route)
// this.$router.push('/dataset/index')
this.$store.dispatch('dataset/setSceneData', null)
this.$emit('switchComponent', { name: '' })
},
clickAddData(param) {
// console.log(param);
switch (param.type) {
case 'db':
this.addDB()
break
case 'sql':
this.$message(param.type)
break
case 'excel':
this.$message(param.type)
break
case 'custom':
this.$message(param.type)
break
}
},
beforeClickAddData(type) {
return {
'type': type
}
},
addDB() {
// this.$router.push({
// name: 'add_db',
// params: {
// scene: this.currGroup
// }
// })
this.$emit('switchComponent', { name: 'AddDB', param: this.currGroup })
},
sceneClick(data, node) {
// console.log(data);
this.$store.dispatch('dataset/setTable', null)
this.$store.dispatch('dataset/setTable', data.id)
// this.$router.push({
// name: 'table',
// params: {
// table: data
// }
// })
this.$emit('switchComponent', { name: 'ViewTable' })
},
refresh() {
const path = this.$route.path
if (path === '/dataset/table') {
this.sceneMode = true
const sceneId = this.$store.state.dataset.sceneData
getScene(sceneId).then(res => {
this.currGroup = res.data
})
}
},
panelDefaultClick(data, node) {
console.log(data)
console.log(node)
this.$store.dispatch('panel/setPanelName', data.name)
// view
this.$emit('switchComponent', { name: 'PanelView' })
}
}
}
</script>
<style scoped>