mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-26 08:46:28 +08:00
feat: Add default value support for file selection component (#10055)
This commit is contained in:
parent
34b80373c7
commit
fd1e0e72a0
2 changed files with 34 additions and 7 deletions
|
|
@ -111,7 +111,7 @@ import { createFile, getFilesList } from '@/api/modules/files';
|
|||
import { onUpdated, reactive, ref } from 'vue';
|
||||
import i18n from '@/lang';
|
||||
import { MsgSuccess, MsgWarning } from '@/utils/message';
|
||||
import { useSearchable } from '@/views/host/file-management/hooks/searchable';
|
||||
import { useSearchableForSelect } from '@/views/host/file-management/hooks/searchable';
|
||||
|
||||
const data = ref([]);
|
||||
const loading = ref(false);
|
||||
|
|
@ -123,7 +123,7 @@ const open = ref(false);
|
|||
const newFolder = ref();
|
||||
const disBtn = ref(false);
|
||||
|
||||
const { searchableStatus, searchablePath, searchableInputRef, searchableInputBlur } = useSearchable(paths);
|
||||
const { searchableStatus, searchablePath, searchableInputRef, searchableInputBlur } = useSearchableForSelect(paths);
|
||||
const oldUrl = ref<string>('');
|
||||
|
||||
const em = defineEmits(['choose']);
|
||||
|
|
@ -197,11 +197,9 @@ const openDir = async (row: File.File) => {
|
|||
const jump = async (index: number) => {
|
||||
oldUrl.value = req.path;
|
||||
let path = '';
|
||||
if (index != -1) {
|
||||
if (index !== -1) {
|
||||
const jPaths = paths.value.slice(0, index + 1);
|
||||
path = '/' + jPaths.join('/');
|
||||
}
|
||||
if (index !== -1) {
|
||||
const jPaths = paths.value.slice(0, index + 1);
|
||||
path = '/' + jPaths.join('/');
|
||||
}
|
||||
path = path || '/';
|
||||
req.path = path;
|
||||
|
|
|
|||
|
|
@ -24,3 +24,32 @@ export function useSearchable(paths) {
|
|||
searchableInputBlur,
|
||||
};
|
||||
}
|
||||
|
||||
export function useSearchableForSelect(paths) {
|
||||
const searchableStatus = ref(false);
|
||||
const searchablePath = ref('');
|
||||
const searchableInputRef = ref();
|
||||
|
||||
watch(searchableStatus, (val) => {
|
||||
if (val) {
|
||||
if (paths.value.length === 0) {
|
||||
searchablePath.value = '/';
|
||||
} else {
|
||||
searchablePath.value = '/' + paths.value.join('/');
|
||||
}
|
||||
nextTick(() => {
|
||||
searchableInputRef.value?.focus();
|
||||
});
|
||||
}
|
||||
});
|
||||
const searchableInputBlur = () => {
|
||||
searchableStatus.value = false;
|
||||
};
|
||||
|
||||
return {
|
||||
searchableStatus,
|
||||
searchablePath,
|
||||
searchableInputRef,
|
||||
searchableInputBlur,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue