fix: isPreview 2 isFilePreview & getFileNameFormat

This commit is contained in:
puri-ph4tt 2023-11-29 11:16:50 +07:00 committed by Methapon2001
parent 3e570b71aa
commit bc0212b0f1
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
7 changed files with 40 additions and 43 deletions

View file

@ -15,11 +15,8 @@ const props = withDefaults(
action: false,
}
)
const DEPT_NAME = ['ตู้เอกสาร', 'ลิ้นชัก', 'แฟ้ม', 'แฟ้มย่อย'] as const
const { isPreview } = storeToRefs(useFileInfoStore())
const { getFileInfo } = useFileInfoStore()
const { getFileInfo, getFileNameFormat } = useFileInfoStore()
const { currentFolder, currentFile, currentDept, currentPath } = storeToRefs(
useTreeDataStore()
)
@ -108,13 +105,6 @@ function triggerFileEdit(
}
}
function getFileNameFormat(fileName: string): string {
const dotIndex = fileName.lastIndexOf('.')
const fileNameOnly = fileName.substring(0, dotIndex)
return fileNameOnly
}
async function submitFileForm(value: {
mode: 'create' | 'edit'
file: File
@ -278,10 +268,7 @@ async function submitFileForm(value: {
class="inline-block"
>
<div class="box border-radius-inherit">
<q-card
flat
@click="() => (getFileInfo(currentFile[index]), (isPreview = true))"
>
<q-card flat @click="() => getFileInfo(currentFile[index])">
<q-card-section class="column justify-center relative q-px-xl">
<file-icon
size="preview"

View file

@ -5,7 +5,6 @@ import { useFileInfoStore } from '@/stores/file-info-data'
import FileIcon from '@/components/FileIcon.vue'
const { foundFile } = storeToRefs(useSearchDataStore())
const { isPreview } = storeToRefs(useFileInfoStore())
const { getFileInfo } = useFileInfoStore()
</script>
@ -23,7 +22,6 @@ const { getFileInfo } = useFileInfoStore()
@click="
() => {
getFileInfo(foundFile[index])
isPreview = true
}
"
>

View file

@ -8,7 +8,7 @@ import FileIcon from '@/components/FileIcon.vue'
import FileForm from './FileForm.vue'
import FolderForm from './FolderForm.vue'
const { getFormatDate, getSize, getType } = useFileInfoStore()
const { getFormatDate, getSize, getType, getFileInfo } = useFileInfoStore()
const { listDataFile, listDataFolder, currentDept, currentPath } = storeToRefs(
useTreeDataStore()
)
@ -348,7 +348,7 @@ const onRowClick = (evt: Event, row: TreeDataFolder, index: number) => {
style="width: 50%"
@click="
() => {
getFolder(nameRow.row.pathname)
currentDept >= 3 ? getFileInfo(nameRow.row) : getFolder(nameRow.row.pathname);
}
"
>

View file

@ -14,7 +14,7 @@ import FolderForm from './FolderForm.vue'
const DEPT_NAME = ['ตู้เอกสาร', 'ลิ้นชัก', 'แฟ้ม', 'แฟ้มย่อย'] as const
const { isPreview } = storeToRefs(useFileInfoStore())
const { isFilePreview } = storeToRefs(useFileInfoStore())
const { isSearch } = storeToRefs(useSearchDataStore())
const { data, currentDept } = storeToRefs(useTreeDataStore())
const { createFolder, getCabinet, gotoParent } = useTreeDataStore()
@ -89,10 +89,10 @@ onMounted(getCabinet)
</div>
</div>
<div class="col">
<file-download v-if="isPreview === true" />
<file-download v-if="isFilePreview === true" />
<div
class="bg-white rounded-borders shadow-5 relative"
v-if="isPreview === false"
v-if="isFilePreview === false"
>
<search-bar v-if="mode === 'user'" />
<div class="bg-white q-pa-md">

View file

@ -3,11 +3,9 @@ import { storeToRefs } from 'pinia'
import { useTreeDataStore, type TreeDataFolder } from '@/stores/tree-data'
import { useSearchDataStore } from '@/stores/searched-data'
import { useFileInfoStore } from '@/stores/file-info-data'
import { computed } from '@vue/reactivity'
import FolderForm from './FolderForm.vue'
const { isSearch } = storeToRefs(useSearchDataStore())
const { isPreview } = storeToRefs(useFileInfoStore())
const { isFilePreview } = storeToRefs(useFileInfoStore())
const { getFolder } = useTreeDataStore()
const props = withDefaults(
@ -31,7 +29,7 @@ const MAX_NAME_LENGTH = 20
() => {
getFolder(folder.pathname, false)
isSearch = false
isPreview = false
isFilePreview = false
}
"
:header-inset-level="level * 0.25"