mirror of
https://gitee.com/fit2cloud-feizhiyun/1Panel.git
synced 2024-12-04 12:59:52 +08:00
feat: 修改文件选择组件
This commit is contained in:
parent
405db20980
commit
b002614759
@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/response"
|
||||
"github.com/1Panel-dev/1Panel/backend/buserr"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -57,7 +59,6 @@ func (f FileService) GetFileTree(op request.FileOption) ([]response.FileTree, er
|
||||
}
|
||||
|
||||
func (f FileService) Create(op request.FileCreate) error {
|
||||
|
||||
fo := files.NewFileOp()
|
||||
if fo.Stat(op.Path) {
|
||||
return errors.New("file is exist")
|
||||
@ -154,6 +155,10 @@ func (f FileService) Wget(w request.FileWget) (string, error) {
|
||||
|
||||
func (f FileService) MvFile(m request.FileMove) error {
|
||||
fo := files.NewFileOp()
|
||||
if !fo.Stat(m.NewPath) {
|
||||
return buserr.New(constant.ErrPathNotFound)
|
||||
}
|
||||
|
||||
if m.Type == "cut" {
|
||||
return fo.Cut(m.OldPaths, m.NewPath)
|
||||
}
|
||||
|
@ -70,3 +70,8 @@ var (
|
||||
ErrAccountCannotDelete = "ErrAccountCannotDelete"
|
||||
ErrSSLApply = "ErrSSLApply"
|
||||
)
|
||||
|
||||
//file
|
||||
var (
|
||||
ErrPathNotFound = "ErrPathNotFound"
|
||||
)
|
||||
|
@ -23,10 +23,10 @@ ErrAppRequired: "{{ .detail }} app is required"
|
||||
ErrNotInstall: "App not installed"
|
||||
ErrPortInOtherApp: "{{ .port }} port already in use by {{ .apps }}"
|
||||
|
||||
|
||||
#file
|
||||
ErrFileCanNotRead: "File can not read"
|
||||
ErrFileToLarge: "file is too large"
|
||||
ErrPathNotFound: "Path is not found"
|
||||
|
||||
#website
|
||||
ErrDomainIsExist: "Domain is already exist"
|
||||
|
@ -26,6 +26,7 @@ ErrPortInOtherApp: "{{ .port }} 端口已被 {{ .apps }}占用!"
|
||||
#file
|
||||
ErrFileCanNotRead: "此文件不支持预览"
|
||||
ErrFileToLarge: "文件超过10M,无法打开"
|
||||
ErrPathNotFound: "目录不存在"
|
||||
|
||||
#website
|
||||
ErrDomainIsExist: "域名已存在"
|
||||
|
1
frontend/components.d.ts
vendored
1
frontend/components.d.ts
vendored
@ -59,6 +59,7 @@ declare module 'vue' {
|
||||
ElRow: typeof import('element-plus/es')['ElRow']
|
||||
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
|
||||
ElSelect: typeof import('element-plus/es')['ElSelect']
|
||||
ElSpan: typeof import('element-plus/es')['ElSpan']
|
||||
ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
|
||||
ElSwitch: typeof import('element-plus/es')['ElSwitch']
|
||||
ElTable: typeof import('element-plus/es')['ElTable']
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-drawer :close-on-click-modal="false" v-model="open" size="30%">
|
||||
<el-drawer :close-on-click-modal="false" v-model="open" size="40%">
|
||||
<template #header>
|
||||
<Header :header="$t('commons.msg.operate')" :resource="resourceName" :back="handleClose"></Header>
|
||||
</template>
|
||||
|
@ -19,11 +19,10 @@
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.from === 'path'" prop="path">
|
||||
<el-input
|
||||
disabled
|
||||
:placeholder="$t('commons.example') + '/tmp/docker-compose.yml'"
|
||||
v-model="form.path"
|
||||
>
|
||||
<template #append>
|
||||
<template #prepend>
|
||||
<FileList @choose="loadDir" :dir="false"></FileList>
|
||||
</template>
|
||||
</el-input>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-drawer v-model="newNameVisiable" :destroy-on-close="true" :close-on-click-modal="false" size="30%">
|
||||
<el-drawer v-model="newNameVisiable" :destroy-on-close="true" :close-on-click-modal="false" size="40%">
|
||||
<template #header>
|
||||
<DrawerHeader :header="$t('container.rename')" :back="handleClose" />
|
||||
</template>
|
||||
|
@ -39,7 +39,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item v-else :rules="Rules.requiredSelect" prop="dockerfile">
|
||||
<el-input clearable v-model="form.dockerfile">
|
||||
<template #append>
|
||||
<template #prepend>
|
||||
<FileList @choose="loadBuildDir" :dir="true"></FileList>
|
||||
</template>
|
||||
</el-input>
|
||||
|
@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<el-drawer v-model="loadVisiable" :destroy-on-close="true" :close-on-click-modal="false" size="30%">
|
||||
<el-drawer v-model="loadVisiable" :destroy-on-close="true" :close-on-click-modal="false" size="40%">
|
||||
<template #header>
|
||||
<DrawerHeader :header="$t('container.importImage')" :back="handleClose" />
|
||||
</template>
|
||||
<el-form v-loading="loading" ref="formRef" :model="form" label-position="top">
|
||||
<el-form-item :label="$t('container.path')" :rules="Rules.requiredSelect" prop="path">
|
||||
<el-input disabled v-model="form.path">
|
||||
<template #append>
|
||||
<el-input v-model="form.path">
|
||||
<template #prepend>
|
||||
<FileList @choose="loadLoadDir" :dir="false"></FileList>
|
||||
</template>
|
||||
</el-input>
|
||||
|
@ -18,8 +18,8 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('container.path')" :rules="Rules.requiredSelect" prop="path">
|
||||
<el-input disabled v-model="form.path">
|
||||
<template #append>
|
||||
<el-input v-model="form.path">
|
||||
<template #prepend>
|
||||
<FileList @choose="loadSaveDir" :dir="true"></FileList>
|
||||
</template>
|
||||
</el-input>
|
||||
|
@ -93,8 +93,8 @@
|
||||
:label="$t('cronjob.sourceDir')"
|
||||
prop="sourceDir"
|
||||
>
|
||||
<el-input style="width: 100%" disabled v-model="dialogData.rowData!.sourceDir">
|
||||
<template #append>
|
||||
<el-input style="width: 100%" v-model="dialogData.rowData!.sourceDir">
|
||||
<template #prepend>
|
||||
<FileList @choose="loadDir" :dir="true"></FileList>
|
||||
</template>
|
||||
</el-input>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-drawer v-model="dialogVisiable" :destroy-on-close="true" :close-on-click-modal="false" size="30%">
|
||||
<el-drawer v-model="dialogVisiable" :destroy-on-close="true" :close-on-click-modal="false" size="40%">
|
||||
<template #header>
|
||||
<DrawerHeader :header="$t('database.remoteAccess')" :back="handleClose" />
|
||||
</template>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-drawer v-model="dialogVisiable" :destroy-on-close="true" :close-on-click-modal="false" size="30%">
|
||||
<el-drawer v-model="dialogVisiable" :destroy-on-close="true" :close-on-click-modal="false" size="40%">
|
||||
<template #header>
|
||||
<DrawerHeader :header="$t('database.rootPassword')" :back="handleClose" />
|
||||
</template>
|
||||
|
@ -30,8 +30,8 @@
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('file.compressDst')" prop="dst">
|
||||
<el-input v-model="form.dst" disabled>
|
||||
<template #append><FileList :path="form.dst" @choose="getLinkPath"></FileList></template>
|
||||
<el-input v-model="form.dst">
|
||||
<template #prepend><FileList :path="form.dst" @choose="getLinkPath"></FileList></template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
|
@ -37,7 +37,7 @@
|
||||
</el-form-item>
|
||||
<el-form-item v-if="addForm.isLink" :label="$t('file.linkPath')" prop="linkPath">
|
||||
<el-input v-model="addForm.linkPath">
|
||||
<template #append>
|
||||
<template #prepend>
|
||||
<FileList @choose="getLinkPath"></FileList>
|
||||
</template>
|
||||
</el-input>
|
||||
|
@ -4,28 +4,32 @@
|
||||
:destroy-on-close="true"
|
||||
:close-on-click-modal="false"
|
||||
:before-close="handleClose"
|
||||
size="30%"
|
||||
size="40%"
|
||||
>
|
||||
<template #header>
|
||||
<DrawerHeader :header="$t('file.deCompress')" :back="handleClose" />
|
||||
</template>
|
||||
<el-form
|
||||
ref="fileForm"
|
||||
label-position="left"
|
||||
:model="form"
|
||||
label-width="100px"
|
||||
:rules="rules"
|
||||
v-loading="loading"
|
||||
>
|
||||
<el-form-item :label="$t('file.name')">
|
||||
<el-input v-model="name" disabled></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('file.deCompressDst')" prop="dst">
|
||||
<el-input v-model="form.dst" disabled>
|
||||
<template #append><FileList :path="form.dst" @choose="getLinkPath"></FileList></template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-row>
|
||||
<el-col :span="22" :offset="1">
|
||||
<el-form
|
||||
ref="fileForm"
|
||||
label-position="top"
|
||||
:model="form"
|
||||
label-width="100px"
|
||||
:rules="rules"
|
||||
v-loading="loading"
|
||||
>
|
||||
<el-form-item :label="$t('file.name')">
|
||||
<el-input v-model="name" disabled></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('file.deCompressDst')" prop="dst">
|
||||
<el-input v-model="form.dst">
|
||||
<template #prepend><FileList :path="form.dst" @choose="getLinkPath"></FileList></template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="handleClose">{{ $t('commons.button.cancel') }}</el-button>
|
||||
|
@ -5,7 +5,7 @@
|
||||
:destroy-on-close="true"
|
||||
:close-on-click-modal="false"
|
||||
:before-close="handleClose"
|
||||
size="30%"
|
||||
size="40%"
|
||||
>
|
||||
<template #header>
|
||||
<DrawerHeader :header="$t('file.download')" :back="handleClose" />
|
||||
|
@ -4,25 +4,29 @@
|
||||
:destroy-on-close="true"
|
||||
:close-on-click-modal="false"
|
||||
:before-close="handleClose"
|
||||
size="30%"
|
||||
size="40%"
|
||||
>
|
||||
<template #header>
|
||||
<DrawerHeader :header="title" :back="handleClose" />
|
||||
</template>
|
||||
<el-form
|
||||
ref="fileForm"
|
||||
label-position="left"
|
||||
:model="addForm"
|
||||
label-width="100px"
|
||||
:rules="rules"
|
||||
v-loading="loading"
|
||||
>
|
||||
<el-form-item :label="$t('file.path')" prop="newPath">
|
||||
<el-input v-model="addForm.newPath" disabled>
|
||||
<template #append><FileList @choose="getPath" :dir="true"></FileList></template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-row>
|
||||
<el-col :span="22" :offset="1">
|
||||
<el-form
|
||||
ref="fileForm"
|
||||
label-position="top"
|
||||
:model="addForm"
|
||||
label-width="100px"
|
||||
:rules="rules"
|
||||
v-loading="loading"
|
||||
>
|
||||
<el-form-item :label="$t('file.path')" prop="newPath">
|
||||
<el-input v-model="addForm.newPath">
|
||||
<template #prepend><FileList @choose="getPath" :dir="true"></FileList></template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="handleClose" :disabled="loading">{{ $t('commons.button.cancel') }}</el-button>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-drawer v-model="open" :before-close="handleClose" :title="$t('file.rename')" size="30%">
|
||||
<el-drawer v-model="open" :before-close="handleClose" :title="$t('file.rename')" size="40%">
|
||||
<el-row>
|
||||
<el-col :span="22" :offset="1">
|
||||
<el-form
|
||||
|
@ -17,8 +17,8 @@
|
||||
<el-input v-model="addForm.url" @input="getFileName" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('file.path')" prop="path">
|
||||
<el-input v-model="addForm.path" disabled>
|
||||
<template #append><FileList :path="addForm.path" @choose="getPath"></FileList></template>
|
||||
<el-input v-model="addForm.path">
|
||||
<template #prepend><FileList :path="addForm.path" @choose="getPath"></FileList></template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('file.name')" prop="name">
|
||||
|
@ -17,7 +17,7 @@
|
||||
prop="varsJson['dir']"
|
||||
:rules="Rules.requiredInput"
|
||||
>
|
||||
<el-input disabled v-model="dialogData.rowData!.varsJson['dir']">
|
||||
<el-input v-model="dialogData.rowData!.varsJson['dir']">
|
||||
<template #append>
|
||||
<FileList @choose="loadDir" :dir="true"></FileList>
|
||||
</template>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-drawer :close-on-click-modal="false" v-model="open" size="30%">
|
||||
<el-drawer :close-on-click-modal="false" v-model="open" size="40%">
|
||||
<template #header>
|
||||
<DrawerHeader :header="$t('website.defaulServer')" :back="handleClose"></DrawerHeader>
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue
Block a user