Skip to content

Commit

Permalink
优化block、404等状态的缓存策略,尽可能减少回源请求
Browse files Browse the repository at this point in the history
  • Loading branch information
MarSeventh committed Dec 13, 2024
1 parent 9d5a2cd commit 6950f91
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
48 changes: 24 additions & 24 deletions src/views/AdminDashBoard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,6 @@
<el-tooltip :disabled="disableTooltip" content="全选此页" placement="bottom">
<font-awesome-icon :icon="selectPageIcon" class="header-icon" @click="handleSelectPage"></font-awesome-icon>
</el-tooltip>
<el-tooltip :disabled="disableTooltip" content="默认链接格式" placement="bottom">
<el-dropdown @command="handleDefaultUrlChange" :hide-on-click="false">
<span class="el-dropdown-link">
<font-awesome-icon icon="link" class="header-icon"></font-awesome-icon>
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="originUrl">原始链接</el-dropdown-item>
<el-dropdown-item command="mdUrl">Markdown</el-dropdown-item>
<el-dropdown-item command="htmlUrl">HTML</el-dropdown-item>
<el-dropdown-item command="bbUrl">BBCode</el-dropdown-item>
<el-dropdown-item command="tgId">TG文件ID</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</el-tooltip>
<el-tooltip :disabled="disableTooltip" content="批量处理" placement="bottom">
<el-dropdown @command="handleBatchAction" :hide-on-click="false" :disabled="selectedFiles.length === 0">
<span class="el-dropdown-link">
Expand All @@ -66,6 +50,22 @@
</template>
</el-dropdown>
</el-tooltip>
<el-tooltip :disabled="disableTooltip" content="默认链接格式" placement="bottom">
<el-dropdown @command="handleDefaultUrlChange" :hide-on-click="false">
<span class="el-dropdown-link">
<font-awesome-icon icon="link" class="header-icon"></font-awesome-icon>
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="originUrl">原始链接</el-dropdown-item>
<el-dropdown-item command="mdUrl">Markdown</el-dropdown-item>
<el-dropdown-item command="htmlUrl">HTML</el-dropdown-item>
<el-dropdown-item command="bbUrl">BBCode</el-dropdown-item>
<el-dropdown-item command="tgId">TG文件ID</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</el-tooltip>
<el-tooltip :disabled="disableTooltip" content="用户管理" placement="bottom">
<font-awesome-icon icon="user-cog" class="header-icon" @click="handleGoToAdmin"></font-awesome-icon>
</el-tooltip>
Expand All @@ -83,8 +83,8 @@
<template v-for="(item, index) in paginatedTableData" :key="index">
<el-card class="img-card">
<el-checkbox v-model="item.selected"></el-checkbox>
<video v-if="item.metadata?.FileType?.includes('video') || item.metadata?.FileType?.includes('audio')" :src="'/file/' + item.name" autoplay muted loop class="video-preview" @click="handleVideoClick"></video>
<el-image v-else :preview-teleported="true" :src="'/file/' + item.name" :preview-src-list="item.previewSrcList" fit="cover" lazy class="image-preview"></el-image>
<video v-if="item.metadata?.FileType?.includes('video') || item.metadata?.FileType?.includes('audio')" :src="'/file/' + item.name + '?from=admin'" autoplay muted loop class="video-preview" @click="handleVideoClick"></video>
<el-image v-else :preview-teleported="true" :src="'/file/' + item.name + '?from=admin'" :preview-src-list="item.previewSrcList" fit="cover" lazy class="image-preview"></el-image>
<div class="image-overlay">
<div class="overlay-buttons">
<el-tooltip :disabled="disableTooltip" content="复制链接" placement="top">
Expand Down Expand Up @@ -157,8 +157,8 @@
:width="300"
align="center"
>
<video v-if="detailFile?.metadata?.FileType?.includes('video') || detailFile?.metadata?.FileType?.includes('audio')" :src="'/file/' + detailFile?.name" autoplay muted loop class="video-preview" @click="handleVideoClick"></video>
<el-image v-else :src="'/file/' + detailFile?.name" fit="cover" lazy class="image-preview"></el-image>
<video v-if="detailFile?.metadata?.FileType?.includes('video') || detailFile?.metadata?.FileType?.includes('audio')" :src="'/file/' + detailFile?.name + '?from=admin'" autoplay muted loop class="video-preview" @click="handleVideoClick"></video>
<el-image v-else :src="'/file/' + detailFile?.name + '?from=admin'" fit="cover" lazy class="image-preview"></el-image>
</el-descriptions-item>
<el-descriptions-item label="文件名" class-name="description-item">{{ detailFile?.metadata?.FileName || detailFile?.name }}</el-descriptions-item>
<el-descriptions-item label="文件类型" class-name="description-item">{{ detailFile?.metadata?.FileType || '未知' }}</el-descriptions-item>
Expand Down Expand Up @@ -206,11 +206,11 @@ computed: {
const end = start + this.pageSize;
let data = sortedData.slice(start, end);
// 增加previewSrcList属性,用于预览图片
const fullList = data.filter(file => !file.metadata?.FileType?.includes('video')).map(file => `/file/${file.name}`);
const fullList = data.filter(file => !file.metadata?.FileType?.includes('video')).map(file => `/file/${file.name}?from=admin`);
data.forEach(file => {
if (!file.metadata?.FileType?.includes('video')) {
// 重新排序,索引大于等于当前索引的元素在前,否则在后
file.previewSrcList = fullList.slice(fullList.indexOf(`/file/${file.name}`)).concat(fullList.slice(0, fullList.indexOf(`/file/${file.name}`)));
file.previewSrcList = fullList.slice(fullList.indexOf(`/file/${file.name}?from=admin`)).concat(fullList.slice(0, fullList.indexOf(`/file/${file.name}?from=admin`)));
}
});
return data;
Expand Down Expand Up @@ -281,7 +281,7 @@ methods: {
},
handleDownload(key) {
const link = document.createElement('a');
link.href = `/file/${key}`;
link.href = `/file/${key}?from=admin`;
link.download = key;
link.click();
},
Expand Down Expand Up @@ -558,7 +558,7 @@ methods: {
const fileNameCount = {}; // 用于跟踪文件名出现的次数
const downloadPromises = this.selectedFiles.map(file => {
return fetch(`/file/${file.name}`)
return fetch(`/file/${file.name}?from=admin`)
.then(response => response.blob())
.then(blob => {
// 检查文件名是否已经存在
Expand Down
4 changes: 2 additions & 2 deletions src/views/CustomerConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<el-table-column prop="metadata.FileName" label="文件名"></el-table-column>
<el-table-column prop="name" label="文件预览">
<template v-slot="{ row }">
<el-image v-if="row.metadata?.FileType?.includes('image')" :src="'/file/' + row.name" fit="cover" lazy style="width: 100px; height: 100px;"></el-image>
<video v-else :src="'/file/' + row.name" controls style="width: 100px; height: 100px;"></video>
<el-image v-if="row.metadata?.FileType?.includes('image')" :src="'/file/' + row.name + '?from=admin'" fit="cover" lazy style="width: 100px; height: 100px;"></el-image>
<video v-else :src="'/file/' + row.name + '?from=admin'" controls style="width: 100px; height: 100px;"></video>
</template>
</el-table-column>
<el-table-column
Expand Down

0 comments on commit 6950f91

Please sign in to comment.