perf: 优化代码

This commit is contained in:
Eric 2023-08-09 19:21:25 +08:00 committed by Bryan
parent f042692dbf
commit cc60f2c1f5
3 changed files with 10 additions and 6 deletions

View File

@ -150,3 +150,8 @@ export function toM2MJsonParams(attrFilter) {
const data = encoder.encode(JSON.stringify(attrFilter))
return ['attr_rules', encodeURIComponent(btoa(String.fromCharCode(...data)))]
}
export function IsSupportPauseSessionType(terminalType) {
const supportedType = ['koko', 'lion', 'magnus', 'chen', 'kael']
return supportedType.includes(terminalType)
}

View File

@ -5,6 +5,7 @@
<script>
import BaseList from './BaseList'
import { terminateSession, toggleLockSession } from '@/api/sessions'
import { IsSupportPauseSessionType } from '@/utils/jms'
export default {
name: 'OnlineList',
components: {
@ -39,8 +40,7 @@ export default {
type: 'warning',
can: ({ row }) => {
const terminalType = row['terminal']['type']
const supportedType = ['koko', 'lion', 'magnus', 'chen', 'kael']
.includes(terminalType)
const supportedType = IsSupportPauseSessionType(terminalType)
return supportedType && vm.$hasPerm('terminal.terminate_session')
},
has: ({ row }) => !row['is_locked'],
@ -63,8 +63,7 @@ export default {
type: 'warning',
can: ({ row }) => {
const terminalType = row['terminal']['type']
const supportedType = ['koko', 'lion', 'magnus', 'chen', 'kael']
.includes(terminalType)
const supportedType = IsSupportPauseSessionType(terminalType)
return supportedType && vm.$hasPerm('terminal.terminate_session')
},
has: ({ row }) => row['is_locked'],

View File

@ -69,6 +69,7 @@
<script>
import IBox from '@/components/IBox'
import { IsSupportPauseSessionType } from '@/utils/jms'
export default {
components: { IBox },
@ -108,8 +109,7 @@ export default {
}).then(res => {
this.session = res || {}
const terminalType = res['terminal']['type']
this.supportedLock = ['koko', 'lion', 'magnus', 'chen', 'kael']
.includes(terminalType)
this.supportedLock = IsSupportPauseSessionType(terminalType)
}).catch(err => {
this.curTimer = setTimeout(() => {
this.init()