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)) const data = encoder.encode(JSON.stringify(attrFilter))
return ['attr_rules', encodeURIComponent(btoa(String.fromCharCode(...data)))] 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> <script>
import BaseList from './BaseList' import BaseList from './BaseList'
import { terminateSession, toggleLockSession } from '@/api/sessions' import { terminateSession, toggleLockSession } from '@/api/sessions'
import { IsSupportPauseSessionType } from '@/utils/jms'
export default { export default {
name: 'OnlineList', name: 'OnlineList',
components: { components: {
@ -39,8 +40,7 @@ export default {
type: 'warning', type: 'warning',
can: ({ row }) => { can: ({ row }) => {
const terminalType = row['terminal']['type'] const terminalType = row['terminal']['type']
const supportedType = ['koko', 'lion', 'magnus', 'chen', 'kael'] const supportedType = IsSupportPauseSessionType(terminalType)
.includes(terminalType)
return supportedType && vm.$hasPerm('terminal.terminate_session') return supportedType && vm.$hasPerm('terminal.terminate_session')
}, },
has: ({ row }) => !row['is_locked'], has: ({ row }) => !row['is_locked'],
@ -63,8 +63,7 @@ export default {
type: 'warning', type: 'warning',
can: ({ row }) => { can: ({ row }) => {
const terminalType = row['terminal']['type'] const terminalType = row['terminal']['type']
const supportedType = ['koko', 'lion', 'magnus', 'chen', 'kael'] const supportedType = IsSupportPauseSessionType(terminalType)
.includes(terminalType)
return supportedType && vm.$hasPerm('terminal.terminate_session') return supportedType && vm.$hasPerm('terminal.terminate_session')
}, },
has: ({ row }) => row['is_locked'], has: ({ row }) => row['is_locked'],

View File

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