1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 08:19:15 +08:00

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

This commit is contained in:
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']
FileRole: typeof import('./src/components/file-role/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']
InfiniteScroll: typeof import('element-plus/es')['ElInfiniteScroll']
Loading: typeof import('element-plus/es')['ElLoadingDirective']

View File

@ -160,10 +160,11 @@ const uploadRef = ref<UploadInstance>();
const beforeAvatarUpload = (rawFile) => {
if (type.value === 'app' || type.value === 'website') {
if (!rawFile.name.endsWith('.tar.gz')) {
MsgError(i18n.global.t('database.unSupportType'));
MsgError(i18n.global.t('commons.msg.unSupportType'));
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 true;
@ -176,10 +177,11 @@ const beforeAvatarUpload = (rawFile) => {
!rawFile.name.endsWith('.zip') &&
!rawFile.name.endsWith('.tgz')
) {
MsgError(i18n.global.t('database.unSupportType'));
MsgError(i18n.global.t('commons.msg.unSupportType'));
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 true;

View File

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

View File

@ -97,6 +97,8 @@ export default {
backupSuccess: '备份成功',
restoreSuccess: '备份成功',
notFound: '抱歉您访问的页面不存在',
unSupportType: '不支持当前文件类型',
unSupportSize: '上传文件超过 {0}M请确认',
},
login: {
firstLogin: '首次登录请创建初始管理员用户',
@ -294,8 +296,6 @@ export default {
confChange: '配置修改',
unSupportType: '不支持当前文件类型',
unSupportSize: '上传文件超过 10M请确认',
selectFile: '选择文件',
dropHelper: '将上传文件拖拽到此处或者',
clickHelper: '点击上传',
@ -625,6 +625,7 @@ export default {
host: '主机',
createConn: '新建连接',
group: '分组',
noHost: '暂无主机',
groupChange: '切换分组',
expand: '全部展开',
fold: '全部收缩',

View File

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

View File

@ -32,7 +32,11 @@
<template #search>
<el-select v-model="group" @change="search()" clearable>
<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>
</template>
<template #main>
@ -46,7 +50,12 @@
<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.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">
<template #default="{ row }">
<span v-if="row.addr === '127.0.0.1'">{{ $t('terminal.localhost') }}</span>
@ -91,7 +100,7 @@ const paginationConfig = reactive({
total: 0,
});
const info = ref();
const group = ref();
const group = ref<string>('');
const dialogGroupChangeRef = ref();
const acceptParams = () => {

View File

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