chore: 动态计算英雄排名表格高度
This commit is contained in:
@@ -554,6 +554,51 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 总战绩标题图像配置 -->
|
||||
<div class="config-section">
|
||||
<h3 class="text-gold">📊 总战绩标题图像配置</h3>
|
||||
<div class="subtitle-image-section">
|
||||
<div class="logo-preview">
|
||||
<div v-if="localDisplayConfig.subtitleImage?.src" class="logo-image-container">
|
||||
<img :src="localDisplayConfig.subtitleImage.src" alt="总战绩标题图像" class="logo-preview-image">
|
||||
</div>
|
||||
<div v-else class="logo-placeholder">
|
||||
<span>未上传图像</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="upload-controls">
|
||||
<input type="file" accept="image/*" @change="(e) => handleSubtitleImageUpload(e)"
|
||||
class="logo-input">
|
||||
<button v-if="localDisplayConfig.subtitleImage.src" @click="clearSubtitleImage()"
|
||||
class="btn-clear">
|
||||
清除图像
|
||||
</button>
|
||||
</div>
|
||||
<div class="size-controls">
|
||||
<div class="size-control">
|
||||
<label class="text-gold">图像宽度:</label>
|
||||
<input type="number" v-model.number="localDisplayConfig.subtitleImage.width" min="1" max="1000"
|
||||
class="width-input" placeholder="输入宽度(像素)">
|
||||
<span class="size-unit">px</span>
|
||||
</div>
|
||||
<div class="size-control">
|
||||
<label class="text-gold">图像高度:</label>
|
||||
<input type="number" v-model.number="localDisplayConfig.subtitleImage.height" min="1" max="1000"
|
||||
class="width-input" placeholder="输入高度(像素)">
|
||||
<span class="size-unit">px</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="config-item">
|
||||
<label class="checkbox-label">
|
||||
<span class="text-gold">替代文本:</span>
|
||||
<input type="text" v-model="localDisplayConfig.subtitleImage.alt"
|
||||
class="text-input" placeholder="输入图像替代文本">
|
||||
</label>
|
||||
</div>
|
||||
<p class="upload-hint">支持JPG、PNG、GIF格式,建议尺寸200x60像素,文件大小不超过2MB</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 皇冠配置 -->
|
||||
<div class="config-section">
|
||||
<h3 class="text-gold">👑 英雄冠军皇冠配置</h3>
|
||||
@@ -996,6 +1041,54 @@ const clearChampionLogo = (type) => {
|
||||
championLogos.value[type] = '';
|
||||
};
|
||||
|
||||
// 处理总战绩标题图像上传
|
||||
const handleSubtitleImageUpload = async (event) => {
|
||||
const file = event.target.files[0];
|
||||
if (!file) return;
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/upload', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
// 确保subtitleImage对象存在
|
||||
if (!localDisplayConfig.value.subtitleImage) {
|
||||
localDisplayConfig.value.subtitleImage = {};
|
||||
}
|
||||
// 清除旧的文件(如果是上传的文件)
|
||||
if (localDisplayConfig.value.subtitleImage.src && localDisplayConfig.value.subtitleImage.src.startsWith('/uploads/')) {
|
||||
const oldFilename = localDisplayConfig.value.subtitleImage.src.split('/').pop();
|
||||
fetch(`/api/upload/${oldFilename}`, { method: 'DELETE' })
|
||||
.catch(error => console.error('删除旧文件失败:', error));
|
||||
}
|
||||
// 设置新的图像路径
|
||||
localDisplayConfig.value.subtitleImage.src = data.filePath;
|
||||
} else {
|
||||
console.error('上传失败:', response.status);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('上传文件时出错:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 清除总战绩标题图像
|
||||
const clearSubtitleImage = () => {
|
||||
if (localDisplayConfig.value.subtitleImage?.src && localDisplayConfig.value.subtitleImage.src.startsWith('/uploads/')) {
|
||||
const filename = localDisplayConfig.value.subtitleImage.src.split('/').pop();
|
||||
fetch(`/api/upload/${filename}`, { method: 'DELETE' })
|
||||
.catch(error => console.error('删除文件失败:', error));
|
||||
}
|
||||
// 重置为默认图像
|
||||
localDisplayConfig.value.subtitleImage = localDisplayConfig.value.subtitleImage || {};
|
||||
localDisplayConfig.value.subtitleImage.src = '/completed_performance.png';
|
||||
};
|
||||
|
||||
// 刷新数据
|
||||
const handleRefreshData = () => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user