|
1 | 1 | <template> |
2 | 2 | <div> |
3 | | - <el-row> |
4 | | - <el-col :span="2"> |
5 | | - <div> |
6 | | - <el-button :icon="Back" @click="back" circle :disabled="paths.length == 0" /> |
7 | | - <el-button :icon="Refresh" circle @click="search" /> |
8 | | - </div> |
9 | | - </el-col> |
10 | | - <el-col :span="22"> |
11 | | - <div v-show="!searchableStatus" tabindex="0" @click="searchableStatus = true"> |
12 | | - <div class="path" ref="pathRef"> |
13 | | - <span ref="breadCrumbRef"> |
14 | | - <span class="root"> |
15 | | - <el-link @click.stop="jump('/')"> |
16 | | - <el-icon :size="20"><HomeFilled /></el-icon> |
17 | | - </el-link> |
18 | | - </span> |
19 | | - <span v-for="item in paths" :key="item.url" class="other"> |
20 | | - <span class="split">></span> |
21 | | - <el-link @click.stop="jump(item.url)">{{ item.name }}</el-link> |
22 | | - </span> |
| 3 | + <div class="flex items-center"> |
| 4 | + <div class="flex-shrink-0 flex items-center mr-4"> |
| 5 | + <el-button :icon="Back" @click="back" circle :disabled="paths.length == 0" /> |
| 6 | + <el-button :icon="Refresh" circle @click="search" /> |
| 7 | + </div> |
| 8 | + <div |
| 9 | + v-show="!searchableStatus" |
| 10 | + tabindex="0" |
| 11 | + @click="searchableStatus = true" |
| 12 | + class="address-bar bg-white shadow-md rounded-md px-4 py-2 flex items-center flex-grow" |
| 13 | + > |
| 14 | + <div ref="pathRef" class="w-full"> |
| 15 | + <span ref="breadCrumbRef" class="w-full flex items-center"> |
| 16 | + <span class="root mr-2"> |
| 17 | + <el-link @click.stop="jump('/')"> |
| 18 | + <el-icon :size="20"><HomeFilled /></el-icon> |
| 19 | + </el-link> |
23 | 20 | </span> |
24 | | - </div> |
| 21 | + <span v-for="path in paths" :key="path.url" class="inline-flex items-center"> |
| 22 | + <span class="mr-2">></span> |
| 23 | + <el-link class="path-segment cursor-pointer mr-2 pathname" @click.stop="jump(path.url)"> |
| 24 | + {{ path.name }} |
| 25 | + </el-link> |
| 26 | + </span> |
| 27 | + </span> |
25 | 28 | </div> |
26 | | - <el-input |
27 | | - ref="searchableInputRef" |
28 | | - v-show="searchableStatus" |
29 | | - v-model="searchablePath" |
30 | | - @blur="searchableInputBlur" |
31 | | - @keyup.enter=" |
32 | | - jump(searchablePath); |
33 | | - searchableStatus = false; |
34 | | - " |
35 | | - /> |
36 | | - </el-col> |
37 | | - </el-row> |
| 29 | + </div> |
| 30 | + <el-input |
| 31 | + ref="searchableInputRef" |
| 32 | + v-show="searchableStatus" |
| 33 | + v-model="searchablePath" |
| 34 | + @blur="searchableInputBlur" |
| 35 | + class="px-4 py-2 bg-white border rounded-md shadow-md" |
| 36 | + @keyup.enter=" |
| 37 | + jump(searchablePath); |
| 38 | + searchableStatus = false; |
| 39 | + " |
| 40 | + /> |
| 41 | + </div> |
38 | 42 | <LayoutContent :title="$t('file.file')" v-loading="loading"> |
39 | 43 | <template #toolbar> |
40 | 44 | <el-dropdown @command="handleCreate"> |
@@ -338,7 +342,14 @@ const copyDir = (row: File.File) => { |
338 | 342 | }; |
339 | 343 |
|
340 | 344 | const handlePath = () => { |
341 | | - if (breadCrumbRef.value.offsetWidth > pathWidth.value) { |
| 345 | + const breadcrumbElement = breadCrumbRef.value as any; |
| 346 | + const pathNodes = breadcrumbElement.querySelectorAll('.pathname'); |
| 347 | +
|
| 348 | + let totalpathWidth = 0; |
| 349 | + pathNodes.forEach((node) => { |
| 350 | + totalpathWidth += node.offsetWidth; |
| 351 | + }); |
| 352 | + if (totalpathWidth > pathWidth.value) { |
342 | 353 | paths.value.splice(0, 1); |
343 | 354 | paths.value[0].name = '..'; |
344 | 355 | nextTick(function () { |
@@ -628,8 +639,12 @@ onMounted(() => { |
628 | 639 | getPaths(req.path); |
629 | 640 | } |
630 | 641 | } |
631 | | - pathWidth.value = pathRef.value.offsetWidth * 0.7; |
| 642 | + pathWidth.value = pathRef.value.offsetWidth; |
632 | 643 | search(); |
| 644 | +
|
| 645 | + nextTick(function () { |
| 646 | + handlePath(); |
| 647 | + }); |
633 | 648 | }); |
634 | 649 | </script> |
635 | 650 |
|
|
0 commit comments