style: 优化grid视图下的文件件名称
This commit is contained in:
parent
76f7bc1bea
commit
5b77d57a41
@ -17,8 +17,8 @@
|
|||||||
<!--axios.js-->
|
<!--axios.js-->
|
||||||
<script src="<%= htmlWebpackPlugin.options.path %>/resource/axios@0.21.1.js"></script>
|
<script src="<%= htmlWebpackPlugin.options.path %>/resource/axios@0.21.1.js"></script>
|
||||||
<!--vant.js-->
|
<!--vant.js-->
|
||||||
<link rel="stylesheet" href="<%= htmlWebpackPlugin.options.path %>/resource/vant@2.12.css"/>
|
<link rel="stylesheet" href="<%= htmlWebpackPlugin.options.path %>/resource/vant@2.12.54.css"/>
|
||||||
<script src="<%= htmlWebpackPlugin.options.path %>/resource/vant@2.12.js"></script>
|
<script src="<%= htmlWebpackPlugin.options.path %>/resource/vant@2.12.54.js"></script>
|
||||||
<!--element-ui.js-->
|
<!--element-ui.js-->
|
||||||
<link rel="stylesheet" href="<%= htmlWebpackPlugin.options.path %>/resource/element-ui@2.13.0.css">
|
<link rel="stylesheet" href="<%= htmlWebpackPlugin.options.path %>/resource/element-ui@2.13.0.css">
|
||||||
<script src="<%= htmlWebpackPlugin.options.path %>/resource/element-ui@2.13.0.js"></script>
|
<script src="<%= htmlWebpackPlugin.options.path %>/resource/element-ui@2.13.0.js"></script>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
7
public/resource/vant@2.12.54.js
Normal file
7
public/resource/vant@2.12.54.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<span>
|
<span :style="{position: grid ? 'relative': 'unset'}">
|
||||||
<div v-if="item.isFavorite && !public">
|
<div v-if="item.isFavorite && !public">
|
||||||
<div v-if="pc">
|
<div v-if="pc">
|
||||||
<svg-icon v-if="!grid" class="pc list icon-favorite" icon-class="Favoritestarrate"/>
|
<svg-icon v-if="!grid" class="pc list icon-favorite" icon-class="Favoritestarrate"/>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="item.tags && item.tags.length > 0 && !public">
|
<div v-if="item.tags && item.tags.length > 0 && !public">
|
||||||
<div v-if="pc">
|
<div v-if="pc">
|
||||||
<svg-icon v-if="grid" class="pc grid icon-tag" icon-class="tag2" :style="{left: 14 * index + 'px', color: tag.color}" v-for="(tag,index) in item.tags.slice(0, 3)" :key="tag.tagId"/>
|
<svg-icon v-if="grid" class="pc grid icon-tag" icon-class="tag2" :style="{left: 14 * index + 10 + 'px', color: tag.color}" v-for="(tag,index) in item.tags.slice(0, 3)" :key="tag.tagId"/>
|
||||||
<!-- 列表模式下只能显示一个标签 -->
|
<!-- 列表模式下只能显示一个标签 -->
|
||||||
<svg-icon v-else class="pc list icon-tag" icon-class="tag2" :style="{color: tag.color}" v-for="tag in item.tags.slice(0, 1)" :key="tag.tagId"/>
|
<svg-icon v-else class="pc list icon-tag" icon-class="tag2" :style="{color: tag.color}" v-for="tag in item.tags.slice(0, 1)" :key="tag.tagId"/>
|
||||||
</div>
|
</div>
|
||||||
@ -59,7 +59,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<el-image lazy v-if="grid" :style="{'height':details?'110px':(gridWidth-35) + 'px'}" fit="contain"
|
<el-image lazy v-if="grid" :style="{'height':details?'110px':(gridWidth-35) + 'px'}" fit="contain"
|
||||||
:src="item.fileId ? (audioCoverUrl+item.fileId) : (audioCoverUrl+item.id)">
|
:src="item.fileId ? (audioCoverUrl+item.fileId) : (audioCoverUrl+item.id)">
|
||||||
<div slot="error" class="image-slot">
|
<div slot="error" class="image-slot-error">
|
||||||
<svg-icon icon-class="video"/>
|
<svg-icon icon-class="video"/>
|
||||||
</div>
|
</div>
|
||||||
</el-image>
|
</el-image>
|
||||||
@ -77,7 +77,7 @@
|
|||||||
<div v-if="item.music.name !== null">
|
<div v-if="item.music.name !== null">
|
||||||
<el-image v-if="grid" :style="{'height':details?'110px':(gridWidth-35) + 'px'}" fit="contain"
|
<el-image v-if="grid" :style="{'height':details?'110px':(gridWidth-35) + 'px'}" fit="contain"
|
||||||
:src="item.fileId ? (audioCoverUrl+item.fileId) : (audioCoverUrl+item.id)">
|
:src="item.fileId ? (audioCoverUrl+item.fileId) : (audioCoverUrl+item.id)">
|
||||||
<div slot="error" class="image-slot">
|
<div slot="error" class="image-slot-error">
|
||||||
<svg-icon icon-class="audio"/>
|
<svg-icon icon-class="audio"/>
|
||||||
</div>
|
</div>
|
||||||
</el-image>
|
</el-image>
|
||||||
@ -94,7 +94,7 @@
|
|||||||
<div v-else-if="item.contentType && item.contentType.startsWith('image')">
|
<div v-else-if="item.contentType && item.contentType.startsWith('image')">
|
||||||
<el-image v-if="grid || grid === 'details'" :style="{'height':details?'110px':(gridWidth-35) + 'px'}"
|
<el-image v-if="grid || grid === 'details'" :style="{'height':details?'110px':(gridWidth-35) + 'px'}"
|
||||||
fit="contain" :src="item.fileId ? (imageUrl+item.fileId) : (imageUrl+item.id)">
|
fit="contain" :src="item.fileId ? (imageUrl+item.fileId) : (imageUrl+item.id)">
|
||||||
<div slot="error" class="image-slot">
|
<div slot="error" class="image-slot-error">
|
||||||
<svg-icon icon-class="image"/>
|
<svg-icon icon-class="image"/>
|
||||||
</div>
|
</div>
|
||||||
</el-image>
|
</el-image>
|
||||||
@ -191,6 +191,10 @@ export default {
|
|||||||
line-height: 35px;
|
line-height: 35px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
>>> .image-slot-error {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.icon-favorite {
|
.icon-favorite {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
color: #f5222d;
|
color: #f5222d;
|
||||||
|
|||||||
@ -516,10 +516,8 @@
|
|||||||
ref="checkboxGroup"
|
ref="checkboxGroup"
|
||||||
>
|
>
|
||||||
<van-grid
|
<van-grid
|
||||||
square
|
|
||||||
:center="true"
|
:center="true"
|
||||||
:column-num="gridColumnNum"
|
:column-num="gridColumnNum"
|
||||||
:gutter="10"
|
|
||||||
:border="false"
|
:border="false"
|
||||||
:style="{
|
:style="{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@ -554,10 +552,14 @@
|
|||||||
'路径:' +
|
'路径:' +
|
||||||
item.path
|
item.path
|
||||||
"
|
"
|
||||||
|
:style="{paddingTop: 100/gridColumnNum + '%'}"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="grid-item van-grid-item__content van-grid-item__content--center van-grid-item__content--square"
|
class="grid-item van-grid-item__content van-grid-item__content--center van-grid-item__content--square"
|
||||||
:style="{
|
:style="{
|
||||||
|
right: gridPaddingRight + 'px',
|
||||||
|
bottom: '10px',
|
||||||
|
height: gridItemWidth - 5 + 'px',
|
||||||
background: selectRowData.includes(item) ? '#caeaf991' : '',
|
background: selectRowData.includes(item) ? '#caeaf991' : '',
|
||||||
'background-size': 'cover',
|
'background-size': 'cover',
|
||||||
'background-position': 'center',
|
'background-position': 'center',
|
||||||
@ -578,14 +580,14 @@
|
|||||||
:image-url="imageUrl"
|
:image-url="imageUrl"
|
||||||
:audio-cover-url="audioCoverUrl"
|
:audio-cover-url="audioCoverUrl"
|
||||||
:grid="true"
|
:grid="true"
|
||||||
:grid-width="gridColumnWidth"
|
:grid-width="gridItemWidth"
|
||||||
></icon-file>
|
></icon-file>
|
||||||
</div>
|
</div>
|
||||||
<el-input
|
<el-input
|
||||||
v-if="item.index === editingIndex"
|
v-if="item.index === editingIndex"
|
||||||
v-focus
|
v-focus
|
||||||
v-model="renameFileName"
|
v-model="renameFileName"
|
||||||
class="grid-item-text"
|
class="grid-item-text-input"
|
||||||
placeholder=""
|
placeholder=""
|
||||||
type="textarea"
|
type="textarea"
|
||||||
autosize
|
autosize
|
||||||
@ -599,10 +601,8 @@
|
|||||||
"
|
"
|
||||||
>
|
>
|
||||||
</el-input>
|
</el-input>
|
||||||
<div v-else>
|
<div v-if="item.index !== editingIndex" class="grid-item-text">
|
||||||
<div class="grid-item-text">
|
<span>{{ gridFilename(item) }}</span>
|
||||||
<span>{{ gridFilename(item) }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -1136,7 +1136,8 @@ export default {
|
|||||||
grid: this.defaultGrid,
|
grid: this.defaultGrid,
|
||||||
vmode: this.defaultGrid ? 'grid' : 'list',
|
vmode: this.defaultGrid ? 'grid' : 'list',
|
||||||
gridColumnNum: -1,
|
gridColumnNum: -1,
|
||||||
gridColumnWidth: 120,
|
gridPaddingRight: 0,
|
||||||
|
gridItemWidth: 125,
|
||||||
allChecked: false,
|
allChecked: false,
|
||||||
summaries: '',
|
summaries: '',
|
||||||
shareDialogVisible: false,
|
shareDialogVisible: false,
|
||||||
@ -1201,61 +1202,42 @@ export default {
|
|||||||
gridFilename() {
|
gridFilename() {
|
||||||
// 优化文件名,如果文件名过长,则进行截取
|
// 优化文件名,如果文件名过长,则进行截取
|
||||||
return function(item) {
|
return function(item) {
|
||||||
let filename = item.name
|
let filename = item.name;
|
||||||
|
|
||||||
// 如果是文件夹,直接返回文件夹名
|
// 如果是文件夹,直接返回文件夹名
|
||||||
if (item.isFolder) {
|
if (item.isFolder || !this.grid) {
|
||||||
return filename
|
return filename;
|
||||||
}
|
}
|
||||||
|
const singleLine = item.contentType && item.contentType.indexOf('audio') > -1 || item.contentType.indexOf('video') > -1 || item.contentType.startsWith('image')
|
||||||
|
const gridFilenameLength = singleLine ? 14 : 32
|
||||||
// 分离文件名和后缀
|
// 分离文件名和后缀
|
||||||
let parts = filename.split('.')
|
let parts = filename.split('.');
|
||||||
let suffix = parts.length > 1 ? parts.pop() : ''
|
let suffix = parts.length > 1 ? parts.pop() : '';
|
||||||
let base = parts.join('.')
|
let base = parts.join('.');
|
||||||
|
|
||||||
// 获取文件名的有效长度
|
// 获取文件名的有效长度
|
||||||
let effectiveLength = this.getEffectiveLength(base, suffix)
|
let effectiveLength = this.getEffectiveLength(base, suffix);
|
||||||
|
// 如果有效长度小于或等于规定的长度,则直接返回文件名
|
||||||
// 如果有效长度小于或等于14,则直接返回文件名
|
if (effectiveLength <= gridFilenameLength) {
|
||||||
if (effectiveLength <= 14) {
|
return filename;
|
||||||
return filename
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据是否有后缀来确定需要截取的长度
|
// 根据是否有后缀来确定需要截取的长度
|
||||||
let sliceLength = 14 - (suffix ? suffix.length + 1 + 1 : 0) // 加1是为了“…”
|
let sliceLength = gridFilenameLength - (suffix ? suffix.length + 2 : 1); // +2 是为了“…”和分隔符
|
||||||
|
let prev = '';
|
||||||
let prev = ''
|
let currentLength = 0;
|
||||||
let currentLength = 0
|
|
||||||
|
|
||||||
// 截取字符串,确保不会在中文字符中间断开
|
// 截取字符串,确保不会在中文字符中间断开
|
||||||
for (let char of Array.from(base)) {
|
for (let char of Array.from(base)) {
|
||||||
let charLength = this.getCharLength(char)
|
let charLength = this.getCharLength(char);
|
||||||
|
|
||||||
if (currentLength + charLength > sliceLength) {
|
if (currentLength + charLength > sliceLength) {
|
||||||
break
|
break;
|
||||||
}
|
}
|
||||||
|
currentLength += charLength;
|
||||||
currentLength += charLength
|
prev += char;
|
||||||
prev += char
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据是否有后缀返回相应的格式
|
// 根据是否有后缀返回相应的格式
|
||||||
if (suffix) {
|
if (suffix) {
|
||||||
return prev + '…' + suffix
|
return prev + '…' + '.' + suffix;
|
||||||
}
|
}
|
||||||
|
return prev + '…';
|
||||||
return prev + '…'
|
};
|
||||||
}
|
|
||||||
},
|
|
||||||
getSummaries2() {
|
|
||||||
let totalSize = 0
|
|
||||||
this.fileList.forEach(file => {
|
|
||||||
totalSize += file.size
|
|
||||||
})
|
|
||||||
const sumFileAndFolder = this.getShowSumFileAndFolder(this.fileList)
|
|
||||||
const sizeSum = this.getShowSumSize(totalSize)
|
|
||||||
this.summaries = sumFileAndFolder + sizeSum
|
|
||||||
return totalSize > 0 ? sumFileAndFolder + sizeSum : ''
|
|
||||||
},
|
},
|
||||||
getSummaries3() {
|
getSummaries3() {
|
||||||
let totalSize = 0
|
let totalSize = 0
|
||||||
@ -1548,25 +1530,18 @@ export default {
|
|||||||
containerResize() {
|
containerResize() {
|
||||||
const container = document.querySelector('.dashboard-container')
|
const container = document.querySelector('.dashboard-container')
|
||||||
let clientWidth = container.clientWidth
|
let clientWidth = container.clientWidth
|
||||||
this.clientHeight =
|
this.clientHeight = document.documentElement.clientHeight - this.lessClientHeight
|
||||||
document.documentElement.clientHeight - this.lessClientHeight
|
this.gridItemWidth = 125
|
||||||
if (this.queryFileType === 'image') {
|
if (this.queryFileType === 'image') {
|
||||||
this.gridColumnNum = Math.round((clientWidth - 10) / 165)
|
this.gridItemWidth = 165
|
||||||
|
this.gridColumnNum = Math.trunc((clientWidth - 10) / this.gridItemWidth)
|
||||||
} else {
|
} else {
|
||||||
this.gridColumnNum = Math.round((clientWidth - 10) / 135)
|
this.gridColumnNum = Math.trunc((clientWidth - 10) / this.gridItemWidth)
|
||||||
}
|
|
||||||
this.gridColumnWidth =
|
|
||||||
(clientWidth - 11 * this.gridColumnNum) / this.gridColumnNum - 4.5
|
|
||||||
if (clientWidth < 900) {
|
|
||||||
this.showUpdateDateItem = false
|
|
||||||
} else {
|
|
||||||
this.showUpdateDateItem = true
|
|
||||||
}
|
|
||||||
if (clientWidth < 500) {
|
|
||||||
this.showSizeItem = false
|
|
||||||
} else {
|
|
||||||
this.showSizeItem = true
|
|
||||||
}
|
}
|
||||||
|
const gridWidth = (clientWidth - 10) / this.gridColumnNum
|
||||||
|
this.gridPaddingRight = gridWidth - this.gridItemWidth + 10
|
||||||
|
this.showUpdateDateItem = clientWidth >= 900;
|
||||||
|
this.showSizeItem = clientWidth >= 500;
|
||||||
let gridRowNum = Math.round(
|
let gridRowNum = Math.round(
|
||||||
this.clientHeight / (clientWidth / this.gridColumnNum)
|
this.clientHeight / (clientWidth / this.gridColumnNum)
|
||||||
)
|
)
|
||||||
@ -4557,7 +4532,7 @@ export default {
|
|||||||
margin-left: 5px !important;
|
margin-left: 5px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
> .open-file-dialog {
|
>>> .open-file-dialog {
|
||||||
.el-dialog {
|
.el-dialog {
|
||||||
width: 420px;
|
width: 420px;
|
||||||
}
|
}
|
||||||
@ -4571,13 +4546,13 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
> .v-contextmenu-item {
|
>>> .v-contextmenu-item {
|
||||||
.svg-icon {
|
.svg-icon {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
> .new-text-file-dialog {
|
>>> .new-text-file-dialog {
|
||||||
height: 350px;
|
height: 350px;
|
||||||
top: calc(50% - 175px);
|
top: calc(50% - 175px);
|
||||||
|
|
||||||
@ -4601,11 +4576,11 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
> .van-grid-item__content {
|
>>> .van-grid-item__content {
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
padding: 0;
|
|
||||||
border-radius: 5px !important;
|
border-radius: 5px !important;
|
||||||
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vmode {
|
.vmode {
|
||||||
|
|||||||
@ -293,6 +293,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
>>> .grid-item-text {
|
>>> .grid-item-text {
|
||||||
|
margin-top: 5px;
|
||||||
|
cursor: default;
|
||||||
|
text-align: center;
|
||||||
|
color: #606266;
|
||||||
|
font-size: smaller;
|
||||||
|
//flex: 1;
|
||||||
|
//align-items: center;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
display: flex;
|
||||||
|
word-break: break-word;
|
||||||
|
display: -webkit-box;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
>>> .grid-item-text-input {
|
||||||
cursor: default;
|
cursor: default;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #606266;
|
color: #606266;
|
||||||
@ -330,20 +345,16 @@
|
|||||||
}
|
}
|
||||||
>>> .grid-item {
|
>>> .grid-item {
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
padding: 0 8px;
|
|
||||||
border: solid 1px #ccc0;
|
border: solid 1px #ccc0;
|
||||||
.grid-item-icon{
|
.grid-item-icon{
|
||||||
text-align: center;
|
//text-align: center;
|
||||||
position: absolute;
|
//position: absolute;
|
||||||
top: 5px;
|
//top: 0;
|
||||||
//margin: 9px auto 0;
|
|
||||||
//width: 84px;
|
|
||||||
//height: 84px;
|
|
||||||
}
|
}
|
||||||
.grid-item-icon-image {
|
.grid-item-icon-image {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
top: 0px;
|
top: 0;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
-webkit-backdrop-filter: contrast(0.5);
|
-webkit-backdrop-filter: contrast(0.5);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user