更新 index.html 和 manifest.json 中的資源引用版本,並在新計劃頁面中調整海報模板的屬性名稱,將 preview 改為 url,以統一資料結構。

This commit is contained in:
超级老白兔
2025-08-12 15:31:27 +08:00
parent 0baf472473
commit 88a007de7c
9 changed files with 631 additions and 501 deletions

View File

@@ -137,12 +137,47 @@ const MainImgUpload: React.FC<MainImgUploadProps> = ({
// 预览图片
const handlePreview = (url: string) => {
const img = new Image();
// 使用自定义全屏预览,确保不受父级容器限制
const modal = document.createElement("div");
modal.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: rgba(0, 0, 0, 0.9);
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
`;
const img = document.createElement("img");
img.src = url;
const newWindow = window.open();
if (newWindow) {
newWindow.document.write(img.outerHTML);
}
img.style.cssText = `
max-width: 90vw;
max-height: 90vh;
object-fit: contain;
border-radius: 8px;
`;
const closeModal = () => {
document.body.removeChild(modal);
};
modal.addEventListener("click", closeModal);
modal.appendChild(img);
document.body.appendChild(modal);
// 添加键盘事件监听
const handleKeyDown = (e: KeyboardEvent) => {
if (e.key === "Escape") {
closeModal();
document.removeEventListener("keydown", handleKeyDown);
}
};
document.addEventListener("keydown", handleKeyDown);
};
// 格式化文件大小
@@ -244,7 +279,20 @@ const MainImgUpload: React.FC<MainImgUploadProps> = ({
/>
</div>
</div>
<div className={style.mainImgPreview}>
<div
className={style.mainImgPreview}
onClick={e => {
// 阻止事件冒泡,防止触发删除操作
e.stopPropagation();
// 点击图片预览区域时,触发文件选择
const uploadInput = document.querySelector(
'input[type="file"]',
) as HTMLInputElement;
if (uploadInput) {
uploadInput.click();
}
}}
>
<img
src={file.url}
alt={file.name}
@@ -257,7 +305,10 @@ const MainImgUpload: React.FC<MainImgUploadProps> = ({
type="text"
size="small"
icon={<EyeOutlined />}
onClick={() => handlePreview(file.url || "")}
onClick={e => {
e.stopPropagation();
handlePreview(file.url || "");
}}
className={style.previewBtn}
/>
)}
@@ -265,7 +316,10 @@ const MainImgUpload: React.FC<MainImgUploadProps> = ({
type="text"
size="small"
icon={<DeleteOutlined />}
onClick={() => handleRemove()}
onClick={e => {
e.stopPropagation();
handleRemove();
}}
className={style.deleteBtn}
/>
</div>