feat: 系统用户上传ssh协议i18n翻译

This commit is contained in:
“怀磊” 2022-01-18 19:32:12 +08:00 committed by Jiangjie.Bai
parent 048fee7ede
commit cd5534c20a

View File

@ -1,6 +1,10 @@
<template>
<div class="upload-key">
<input type="file" @change="onChange">
<input ref="upLoadFile" type="file" style="display: none" @change="onChange">
<el-button size="mini" @click.native.stop="onUpLoad">
{{ this.$t('common.SelectFile') }}
</el-button>
<span>{{ fileName }}</span>
<div v-if="tip !== ''">{{ tip }}</div>
</div>
</template>
@ -21,12 +25,22 @@ export default {
default: () => 'string'
}
},
data() {
return {
fileName: ''
}
},
methods: {
onUpLoad() {
this.$refs.upLoadFile.click()
},
onChange(e) {
if (e.target.files.length === 0) {
const upLoadFile = e.target.files
if (upLoadFile.length === 0) {
return
}
const vm = this
this.fileName = upLoadFile[0].name || ''
const reader = new FileReader()
reader.onload = function() {
let result = this.result
@ -36,7 +50,7 @@ export default {
vm.$emit('input', result)
}
reader.readAsText(
e.target.files[0]
upLoadFile[0]
)
}
}