1515 <span >{{ $t('commons.button.preview') + ' - ' + filePath }}</span >
1616 <el-space alignment =" center" :size =" 10" class =" dialog-header-icon" >
1717 <el-tooltip :content =" loadTooltip()" placement =" top" v-if =" fileType !== 'excel'" >
18- <el-icon @click =" toggleFullscreen" ><FullScreen /></el-icon >
18+ <el-icon @click =" toggleFullscreen" class =" cursor-pointer hover:scale-110" >
19+ <FullScreen />
20+ </el-icon >
1921 </el-tooltip >
20- <el-icon @click =" handleClose" size =" 20" ><Close /></el-icon >
22+ <el-icon @click =" handleClose" size =" 20" class = " cursor-pointer hover:scale-110 " ><Close /></el-icon >
2123 </el-space >
2224 </div >
2325 </template >
24- <div v-loading =" loading" :style =" isFullscreen ? 'height: 90vh' : 'height: 80vh'" >
25- <div class =" flex items-center justify-center h-full" >
26- <el-image
27- v-if =" fileType === 'image'"
28- :src =" fileUrl"
29- :style =" isFullscreen ? 'height: 90vh' : 'height: 80vh'"
30- fit =" contain"
31- :preview-src-list =" [fileUrl]"
32- />
33-
34- <video v-else-if =" fileType === 'video'" :src =" fileUrl" controls autoplay class =" size-3/4" ></video >
35-
36- <audio v-else-if =" fileType === 'audio'" :src =" fileUrl" controls ></audio >
37-
38- <vue-office-docx
39- v-else-if =" fileType === 'word'"
40- :src =" fileUrl"
41- :style =" isFullscreen ? 'height: 90vh' : 'height: 80vh'"
42- class =" w-full"
43- @rendered =" renderedHandler"
44- @error =" errorHandler"
45- />
46-
47- <vue-office-excel
48- v-else-if =" fileType === 'excel'"
49- :src =" fileUrl"
50- :style =" isFullscreen ? 'height: 90vh;' : 'height: 80vh'"
51- class =" w-full"
52- @rendered =" renderedHandler"
53- @error =" errorHandler"
54- />
55- </div >
26+ <div
27+ v-loading =" loading"
28+ :style =" isFullscreen ? 'height: 90vh' : 'height: 80vh'"
29+ :class =" fileType === 'image' ? 'overflow-y-auto' : 'flex justify-center items-center'"
30+ >
31+ <template v-if =" fileType === ' image' " >
32+ <div class =" flex h-full" >
33+ <aside class =" w-[200px] overflow-y-auto p-2 sm:block hidden left-aside rounded" >
34+ <template v-for =" (item , index ) in imageFiles " :key =" index " >
35+ <el-tooltip :content =" item.path" placement =" right" >
36+ <div
37+ class =" text-sm truncate mb-1 rounded p-1 left-item"
38+ @click =" changeImg(item.path)"
39+ :class =" item.path === filePath ? 'left-item-default' : ''"
40+ >
41+ {{ item.path }}
42+ </div >
43+ </el-tooltip >
44+ </template >
45+ </aside >
46+ <main class =" flex-1 overflow-hidden" >
47+ <el-tooltip :content =" filePath" placement =" bottom" >
48+ <el-image
49+ loading =" lazy"
50+ :src =" fileUrl"
51+ :alt =" filePath"
52+ fit =" contain"
53+ class =" w-full h-full"
54+ />
55+ </el-tooltip >
56+ </main >
57+ </div >
58+ </template >
59+ <video v-else-if =" fileType === 'video'" :src =" fileUrl" controls autoplay class =" size-3/4" ></video >
60+
61+ <audio v-else-if =" fileType === 'audio'" :src =" fileUrl" controls ></audio >
62+
63+ <vue-office-docx
64+ v-else-if =" fileType === 'word'"
65+ :src =" fileUrl"
66+ :style =" isFullscreen ? 'height: 90vh' : 'height: 80vh'"
67+ class =" w-full"
68+ @rendered =" renderedHandler"
69+ @error =" errorHandler"
70+ />
71+
72+ <vue-office-excel
73+ v-else-if =" fileType === 'excel'"
74+ :src =" fileUrl"
75+ :style =" isFullscreen ? 'height: 90vh;' : 'height: 80vh'"
76+ class =" w-full"
77+ @rendered =" renderedHandler"
78+ @error =" errorHandler"
79+ />
5680 </div >
5781 </el-dialog >
5882</template >
@@ -73,6 +97,7 @@ interface EditProps {
7397 path: string ;
7498 name: string ;
7599 extension: string ;
100+ imageFiles: [];
76101}
77102
78103const open = ref (false );
@@ -81,6 +106,7 @@ const filePath = ref('');
81106const fileName = ref (' ' );
82107const fileType = ref (' ' );
83108const fileUrl = ref (' ' );
109+ const imageFiles = ref ([]);
84110
85111const fileExtension = ref (' ' );
86112const isFullscreen = ref (false );
@@ -107,23 +133,38 @@ const toggleFullscreen = () => {
107133 isFullscreen .value = ! isFullscreen .value ;
108134};
109135
136+ const getDownloadUrl = (path : string ) => {
137+ const baseUrl = ` ${import .meta .env .VITE_API_URL as string }/files/download ` ;
138+ const encodedPath = encodeURIComponent (path );
139+ const timestamp = new Date ().getTime ();
140+ return ` ${baseUrl }?path=${encodedPath }×tamp=${timestamp } ` ;
141+ };
142+
110143const acceptParams = (props : EditProps ) => {
144+ imageFiles .value = [];
111145 fileExtension .value = props .extension ;
112146 fileName .value = props .name ;
113147 filePath .value = props .path ;
114148 fileType .value = props .fileType ;
115149 isFullscreen .value = fileType .value === ' excel' ;
116150
117151 loading .value = true ;
118- fileUrl .value = ` ${import .meta .env .VITE_API_URL as string }/files/download?path=${encodeURIComponent (
119- props .path ,
120- )}×tamp=${new Date ().getTime ()} ` ;
152+ fileUrl .value = getDownloadUrl (props .path );
153+ imageFiles .value = props .imageFiles .map ((item ) => ({
154+ path: item ,
155+ url: getDownloadUrl (item ),
156+ }));
121157 open .value = true ;
122158 loading .value = false ;
123159};
124160
125161const onOpen = () => {};
126162
163+ const changeImg = (path : string ) => {
164+ filePath .value = path ;
165+ fileUrl .value = getDownloadUrl (path );
166+ };
167+
127168defineExpose ({ acceptParams });
128169 </script >
129170
@@ -135,4 +176,16 @@ defineExpose({ acceptParams });
135176.dialog-header-icon {
136177 color : var (--el-color-info );
137178}
179+ .left-aside {
180+ background-color : var (--panel-menu-bg-color );
181+ opacity : 85% ;
182+ }
183+ .left-item {
184+ & :hover {
185+ background : var (--el-menu-item-bg-color-active ) !important ;
186+ }
187+ }
188+ .left-item-default {
189+ background : var (--el-menu-item-bg-color-active ) !important ;
190+ }
138191 </style >
0 commit comments