mirror of
https://github.com/jumpserver/lina.git
synced 2026-01-13 19:35:24 +00:00
82
src/components/TableFormatters/ShowKeyCopyFormatter.vue
Normal file
82
src/components/TableFormatters/ShowKeyCopyFormatter.vue
Normal file
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<div class="content">
|
||||
<span>{{ currentValue }}</span>
|
||||
<span class="right">
|
||||
<el-tooltip
|
||||
effect="dark"
|
||||
placement="top"
|
||||
:content="this.$t('common.View')"
|
||||
>
|
||||
<i class="el-icon-view" @click="onShow()" />
|
||||
</el-tooltip>
|
||||
<el-tooltip
|
||||
effect="dark"
|
||||
placement="top"
|
||||
:content="this.$t('common.Copy')"
|
||||
>
|
||||
<i class="el-icon-copy-document" @click="onCopy()" />
|
||||
</el-tooltip>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BaseFormatter from './base'
|
||||
|
||||
export default {
|
||||
name: 'ShowKeyCopyFormatter',
|
||||
extends: BaseFormatter,
|
||||
proops: {
|
||||
cellValue: {
|
||||
type: String,
|
||||
default: () => ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
currentValue: this.switchShowValue()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
switchShowValue() {
|
||||
return '******' + this.cellValue.replace(/[\w-]/g, '')
|
||||
},
|
||||
onShow() {
|
||||
const { currentValue, cellValue, switchShowValue } = this
|
||||
this.currentValue = currentValue === cellValue ? switchShowValue() : cellValue
|
||||
},
|
||||
onCopy: _.throttle(function() {
|
||||
const inputDom = document.createElement('input')
|
||||
inputDom.id = 'creatInputDom'
|
||||
inputDom.value = this.cellValue
|
||||
document.body.appendChild(inputDom)
|
||||
inputDom.select()
|
||||
document?.execCommand('copy')
|
||||
this.$message({
|
||||
message: this.$t('common.CopySuccess'),
|
||||
type: 'success',
|
||||
duration: 1400
|
||||
})
|
||||
document.body.removeChild(inputDom)
|
||||
}, 1800)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.content {
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
.right {
|
||||
float: right;
|
||||
font-size: 15px;
|
||||
cursor: pointer;
|
||||
.el-icon-view, .el-icon-copy-document {
|
||||
&:hover {
|
||||
color: #1c84c6;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -7,6 +7,7 @@ import DeleteActionFormatter from './DeleteActionFormatter'
|
||||
import DateFormatter from './DateFormatter'
|
||||
import SystemUserFormatter from './GrantedSystemUsersShowFormatter'
|
||||
import ShowKeyFormatter from '@/components/TableFormatters/ShowKeyFormatter'
|
||||
import ShowKeyCopyFormatter from './ShowKeyCopyFormatter'
|
||||
import DialogDetailFormatter from './DialogDetailFormatter'
|
||||
import EditableInputFormatter from './EditableInputFormatter'
|
||||
import StatusFormatter from './StatusFormatter'
|
||||
@@ -21,6 +22,7 @@ export default {
|
||||
DateFormatter,
|
||||
SystemUserFormatter,
|
||||
ShowKeyFormatter,
|
||||
ShowKeyCopyFormatter,
|
||||
DialogDetailFormatter,
|
||||
ArrayFormatter,
|
||||
EditableInputFormatter,
|
||||
@@ -37,6 +39,7 @@ export {
|
||||
DateFormatter,
|
||||
SystemUserFormatter,
|
||||
ShowKeyFormatter,
|
||||
ShowKeyCopyFormatter,
|
||||
DialogDetailFormatter,
|
||||
ArrayFormatter,
|
||||
EditableInputFormatter,
|
||||
|
||||
@@ -315,6 +315,7 @@
|
||||
"Disable": "Disable",
|
||||
"Download": "Download",
|
||||
"Copy": "Copy",
|
||||
"CopySuccess": "Copy success",
|
||||
"Enable": "Enable",
|
||||
"On/Off": "On/Off",
|
||||
"EnterForSearch": "Press enter to search",
|
||||
|
||||
@@ -327,6 +327,7 @@
|
||||
"Disable": "無効",
|
||||
"Download": "ダウンロード",
|
||||
"Copy": "コピー",
|
||||
"CopySuccess": "コピー成功",
|
||||
"Enable": "有効化",
|
||||
"On/Off": "起動/停止",
|
||||
"EnterForSearch": "Enterキーを押して検索します",
|
||||
|
||||
@@ -328,6 +328,7 @@
|
||||
"Disable": "禁用",
|
||||
"Download": "下载",
|
||||
"Copy": "复制",
|
||||
"CopySuccess": "复制成功",
|
||||
"Enable": "启用",
|
||||
"On/Off": "启/停",
|
||||
"EnterForSearch": "按回车进行搜索",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item icon="el-icon-user" command="profile">{{ $t('common.nav.Profile') }}</el-dropdown-item>
|
||||
<el-dropdown-item v-if="$hasPerm('authentication.view_accesskey')" icon="el-icon-key" command="apiKey">{{ $t('common.nav.APIKey') }}</el-dropdown-item>
|
||||
<el-dropdown-item icon="el-icon-magic-stick" command="tempPassword">{{ $t('common.nav.TempPassword') }}</el-dropdown-item>
|
||||
<el-dropdown-item v-if="$store.getters.publicSettings.AUTH_TEMP_TOKEN" icon="el-icon-magic-stick" command="tempPassword">{{ $t('common.nav.TempPassword') }}</el-dropdown-item>
|
||||
<el-dropdown-item divided command="logout"><svg-icon icon-class="logout" style="margin-right: 4px" />{{ $t('common.nav.Logout') }}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
|
||||
@@ -61,6 +61,7 @@ export default {
|
||||
meta: {
|
||||
title: i18n.t('common.nav.TempPassword'),
|
||||
icon: 'magic',
|
||||
hidden: ({ settings }) => !settings['AUTH_TEMP_TOKEN'],
|
||||
permissions: []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ const CURRENT_ORG_KEY = 'jms_current_org'
|
||||
const CURRENT_ROLE_KEY = 'jms_current_role'
|
||||
|
||||
export function getTokenFromCookie() {
|
||||
return VueCookie.get(TOKEN_KEY)
|
||||
const cookieNamePrefix = VueCookie.get('SESSION_COOKIE_NAME_PREFIX', '')
|
||||
return VueCookie.get(cookieNamePrefix + TOKEN_KEY)
|
||||
}
|
||||
|
||||
export function getCurrentRoleLocal(username) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<script>
|
||||
import { GenericListPage } from '@/layout/components'
|
||||
import { DateFormatter, ShowKeyFormatter } from '@/components/TableFormatters'
|
||||
import { DateFormatter, ShowKeyCopyFormatter } from '@/components/TableFormatters'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -31,7 +31,7 @@ export default {
|
||||
},
|
||||
secret: {
|
||||
label: 'AccessKeySecret',
|
||||
formatter: ShowKeyFormatter
|
||||
formatter: ShowKeyCopyFormatter
|
||||
},
|
||||
date_created: {
|
||||
label: this.$t('common.dateCreated'),
|
||||
|
||||
@@ -90,7 +90,8 @@ export default {
|
||||
lion: 'Lion',
|
||||
xrdp: 'XRDP',
|
||||
core: 'Core',
|
||||
celery: 'Celery'
|
||||
celery: 'Celery',
|
||||
magnus: 'Magnus'
|
||||
}
|
||||
return nameMapper[this.componentMetric.type]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user