fix space validate for create folder bug (#11106)

This commit is contained in:
Devosend 2022-07-22 17:08:12 +08:00 committed by GitHub
parent 3701a24d15
commit 2f2de7f90e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 5 deletions

View File

@ -19,4 +19,8 @@ const trim = (value: string) => {
return !value.startsWith(' ') && !value.endsWith(' ')
}
export const noSpace = (value: string) => {
return value.indexOf(' ') === -1
}
export default trim

View File

@ -19,6 +19,7 @@ import { defineComponent, toRefs, PropType, getCurrentInstance } from 'vue'
import { NForm, NFormItem, NInput } from 'naive-ui'
import { useI18n } from 'vue-i18n'
import Modal from '@/components/modal'
import { noSpace } from '@/utils/trim'
import { useForm } from './use-form'
import { useFolder } from './use-folder'
@ -69,7 +70,7 @@ export default defineComponent({
<NForm rules={this.rules} ref='folderFormRef'>
<NFormItem label={t('resource.file.folder_name')} path='name'>
<NInput
allowInput={this.trim}
allowInput={noSpace}
v-model={[this.folderForm.name, 'value']}
placeholder={t('resource.file.enter_name_tips')}
class='input-directory-name'
@ -77,7 +78,7 @@ export default defineComponent({
</NFormItem>
<NFormItem label={t('resource.file.description')} path='description'>
<NInput
allowInput={this.trim}
allowInput={this.trim}
type='textarea'
v-model={[this.folderForm.description, 'value']}
placeholder={t('resource.file.enter_description_tips')}

View File

@ -15,10 +15,18 @@
* limitations under the License.
*/
import { defineComponent, toRefs, PropType, watch, computed, getCurrentInstance } from 'vue'
import {
defineComponent,
toRefs,
PropType,
watch,
computed,
getCurrentInstance
} from 'vue'
import { NForm, NFormItem, NInput } from 'naive-ui'
import { useI18n } from 'vue-i18n'
import Modal from '@/components/modal'
import { noSpace } from '@/utils/trim'
import { useForm } from './use-form'
import { useModal } from './use-modal'
import type { IUdf } from '../types'
@ -100,7 +108,7 @@ export default defineComponent({
path='name'
>
<NInput
allowInput={this.trim}
allowInput={this.fileEdit ? this.trim : noSpace}
v-model={[this.folderForm.name, 'value']}
placeholder={t('resource.udf.enter_name_tips')}
class='input-directory-name'
@ -108,7 +116,7 @@ export default defineComponent({
</NFormItem>
<NFormItem label={t('resource.udf.description')} path='description'>
<NInput
allowInput={this.trim}
allowInput={this.trim}
type='textarea'
v-model={[this.folderForm.description, 'value']}
placeholder={t('resource.udf.enter_description_tips')}