fix: 文件上传限制增加提示信息

pull/189/head
ssongliu 2023-03-07 11:30:01 +08:00 committed by ssongliu
parent 76a9c7f34b
commit 8f5028463a
7 changed files with 48 additions and 28 deletions

View File

@ -73,7 +73,6 @@ declare module 'vue' {
FileList: typeof import('./src/components/file-list/index.vue')['default'] FileList: typeof import('./src/components/file-list/index.vue')['default']
FileRole: typeof import('./src/components/file-role/index.vue')['default'] FileRole: typeof import('./src/components/file-role/index.vue')['default']
Footer: typeof import('./src/components/app-layout/footer/index.vue')['default'] Footer: typeof import('./src/components/app-layout/footer/index.vue')['default']
Gropu: typeof import('./src/components/gropu/index.vue')['default']
Group: typeof import('./src/components/group/index.vue')['default'] Group: typeof import('./src/components/group/index.vue')['default']
InfiniteScroll: typeof import('element-plus/es')['ElInfiniteScroll'] InfiniteScroll: typeof import('element-plus/es')['ElInfiniteScroll']
Loading: typeof import('element-plus/es')['ElLoadingDirective'] Loading: typeof import('element-plus/es')['ElLoadingDirective']

View File

@ -160,10 +160,11 @@ const uploadRef = ref<UploadInstance>();
const beforeAvatarUpload = (rawFile) => { const beforeAvatarUpload = (rawFile) => {
if (type.value === 'app' || type.value === 'website') { if (type.value === 'app' || type.value === 'website') {
if (!rawFile.name.endsWith('.tar.gz')) { if (!rawFile.name.endsWith('.tar.gz')) {
MsgError(i18n.global.t('database.unSupportType')); MsgError(i18n.global.t('commons.msg.unSupportType'));
return false; return false;
} else if (rawFile.size / 1024 / 1024 > 50) { }
MsgError(i18n.global.t('database.unSupportSize')); if (rawFile.size / 1024 / 1024 > 50) {
MsgError(i18n.global.t('commons.msg.unSupportSize', [50]));
return false; return false;
} }
return true; return true;
@ -176,10 +177,11 @@ const beforeAvatarUpload = (rawFile) => {
!rawFile.name.endsWith('.zip') && !rawFile.name.endsWith('.zip') &&
!rawFile.name.endsWith('.tgz') !rawFile.name.endsWith('.tgz')
) { ) {
MsgError(i18n.global.t('database.unSupportType')); MsgError(i18n.global.t('commons.msg.unSupportType'));
return false; return false;
} else if (rawFile.size / 1024 / 1024 > 10) { }
MsgError(i18n.global.t('database.unSupportSize')); if (rawFile.size / 1024 / 1024 > 10) {
MsgError(i18n.global.t('commons.msg.unSupportSize', [10]));
return false; return false;
} }
return true; return true;

View File

@ -91,6 +91,8 @@ export default {
operate: 'Operate', operate: 'Operate',
inputOrSelect: 'Please select or enter', inputOrSelect: 'Please select or enter',
backupSuccess: 'Backup Success', backupSuccess: 'Backup Success',
unSupportType: 'Current file type is not supported!',
unSupportSize: 'The uploaded file exceeds {0}M, please confirm!',
}, },
login: { login: {
firstLogin: 'First login, please create an initial administrator user!', firstLogin: 'First login, please create an initial administrator user!',
@ -288,8 +290,6 @@ export default {
portHelper: portHelper:
'This port is the exposed port of the container. You need to save the modification separately and restart the container!', 'This port is the exposed port of the container. You need to save the modification separately and restart the container!',
unSupportType: 'Current file type is not supported!',
unSupportSize: 'The uploaded file exceeds 10M, please confirm!',
selectFile: 'Select file', selectFile: 'Select file',
supportUpType: 'Only sql, zip, sql.gz, and (tar.gz gz tgz) files within 10 MB are supported', supportUpType: 'Only sql, zip, sql.gz, and (tar.gz gz tgz) files within 10 MB are supported',
zipFormat: zipFormat:
@ -615,8 +615,9 @@ export default {
connTestOk: 'Connection information available', connTestOk: 'Connection information available',
connTestFailed: 'Connection unavailable, please check connection information!', connTestFailed: 'Connection unavailable, please check connection information!',
host: 'Host', host: 'Host',
createConn: 'Create a connection', createConn: 'New connection',
group: 'Group', group: 'Group',
noHost: 'No host',
groupChange: 'Change group', groupChange: 'Change group',
expand: 'Expand all', expand: 'Expand all',
fold: 'All contract', fold: 'All contract',

View File

@ -97,6 +97,8 @@ export default {
backupSuccess: '', backupSuccess: '',
restoreSuccess: '', restoreSuccess: '',
notFound: '访', notFound: '访',
unSupportType: '',
unSupportSize: ' {0}M',
}, },
login: { login: {
firstLogin: '', firstLogin: '',
@ -294,8 +296,6 @@ export default {
confChange: '', confChange: '',
unSupportType: '',
unSupportSize: ' 10M',
selectFile: '', selectFile: '',
dropHelper: '', dropHelper: '',
clickHelper: '', clickHelper: '',
@ -625,6 +625,7 @@ export default {
host: '', host: '',
createConn: '', createConn: '',
group: '', group: '',
noHost: '',
groupChange: '', groupChange: '',
expand: '', expand: '',
fold: '', fold: '',

View File

@ -9,12 +9,14 @@
<el-form ref="hostInfoRef" label-position="top" :model="dialogData" :rules="rules"> <el-form ref="hostInfoRef" label-position="top" :model="dialogData" :rules="rules">
<el-form-item :label="$t('commons.table.group')" prop="group"> <el-form-item :label="$t('commons.table.group')" prop="group">
<el-select filterable v-model="dialogData.groupID" clearable style="width: 100%"> <el-select filterable v-model="dialogData.groupID" clearable style="width: 100%">
<el-option <div v-for="item in groupList" :key="item.id">
v-for="item in groupList" <el-option
:key="item.id" v-if="item.name === 'default'"
:label="item.name" :label="$t('website.default')"
:value="item.id" :value="item.id"
/> />
<el-option v-else :label="item.name" :value="item.id" />
</div>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-form> </el-form>

View File

@ -32,7 +32,11 @@
<template #search> <template #search>
<el-select v-model="group" @change="search()" clearable> <el-select v-model="group" @change="search()" clearable>
<template #prefix>{{ $t('terminal.group') }}</template> <template #prefix>{{ $t('terminal.group') }}</template>
<el-option v-for="item in groupList" :key="item.name" :value="item.id" :label="item.name" /> <el-option :label="$t('commons.table.all')" value=""></el-option>
<div v-for="item in groupList" :key="item.name">
<el-option v-if="item.name === 'default'" :label="$t('website.default')" :value="item.id" />
<el-option v-else :value="item.id" :label="item.name" />
</div>
</el-select> </el-select>
</template> </template>
<template #main> <template #main>
@ -46,7 +50,12 @@
<el-table-column :label="$t('terminal.ip')" prop="addr" fix /> <el-table-column :label="$t('terminal.ip')" prop="addr" fix />
<el-table-column :label="$t('terminal.user')" show-overflow-tooltip prop="user" /> <el-table-column :label="$t('terminal.user')" show-overflow-tooltip prop="user" />
<el-table-column :label="$t('terminal.port')" prop="port" /> <el-table-column :label="$t('terminal.port')" prop="port" />
<el-table-column :label="$t('commons.table.group')" show-overflow-tooltip prop="groupBelong" /> <el-table-column :label="$t('commons.table.group')" show-overflow-tooltip prop="groupBelong">
<template #default="{ row }">
<span v-if="row.groupBelong === 'default'">{{ $t('website.default') }}</span>
<span v-else>{{ row.groupBelong }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('commons.table.title')" show-overflow-tooltip prop="name"> <el-table-column :label="$t('commons.table.title')" show-overflow-tooltip prop="name">
<template #default="{ row }"> <template #default="{ row }">
<span v-if="row.addr === '127.0.0.1'">{{ $t('terminal.localhost') }}</span> <span v-if="row.addr === '127.0.0.1'">{{ $t('terminal.localhost') }}</span>
@ -91,7 +100,7 @@ const paginationConfig = reactive({
total: 0, total: 0,
}); });
const info = ref(); const info = ref();
const group = ref(); const group = ref<string>('');
const dialogGroupChangeRef = ref(); const dialogGroupChangeRef = ref();
const acceptParams = () => { const acceptParams = () => {

View File

@ -85,17 +85,23 @@
:data="hostTree" :data="hostTree"
:props="defaultProps" :props="defaultProps"
:filter-node-method="filterHost" :filter-node-method="filterHost"
:empty-text="$t('terminal.noHost')"
> >
<template #default="{ node, data }"> <template #default="{ node, data }">
<span class="custom-tree-node"> <span class="custom-tree-node">
<span v-if="node.label.length <= 25"> <span v-if="node.label === 'default'">{{ $t('website.default') }}</span>
<a @click="onClickConn(node, data)">{{ node.label }}</a> <div v-else>
</span> <span v-if="node.label.length <= 25">
<el-tooltip v-else :content="node.label" placement="top-start"> <a @click="onClickConn(node, data)">{{ node.label }}</a>
<span>
<a @click="onClickConn(node, data)">{{ node.label.substring(0, 22) }}...</a>
</span> </span>
</el-tooltip> <el-tooltip v-else :content="node.label" placement="top-start">
<span>
<a @click="onClickConn(node, data)">
{{ node.label.substring(0, 22) }}...
</a>
</span>
</el-tooltip>
</div>
</span> </span>
</template> </template>
</el-tree> </el-tree>