feat: 添加示例作文加载功能

This commit is contained in:
cc 2026-03-21 16:25:10 +08:00
parent c206175c9e
commit d2c005fc73
2 changed files with 24 additions and 0 deletions

BIN
src/assets/demo/zuowen.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

View File

@ -9,6 +9,7 @@ import {
IMAGE_MAX_SIZE_MB, IMAGE_MAX_SIZE_MB,
IMAGE_ALLOWED_TYPES_ESSAY, IMAGE_ALLOWED_TYPES_ESSAY,
} from "@/config/index.js"; } from "@/config/index.js";
import demoZuowen from "@/assets/demo/zuowen.jpg";
const API_KEY = GRS_API_KEY; const API_KEY = GRS_API_KEY;
const API_URL = ESSAY_API_URL; const API_URL = ESSAY_API_URL;
@ -75,6 +76,13 @@ const resetUpload = () => {
if (fileInputRef.value) fileInputRef.value.value = ""; if (fileInputRef.value) fileInputRef.value.value = "";
}; };
const loadDemoImage = async () => {
const response = await fetch(demoZuowen);
const blob = await response.blob();
const file = new File([blob], "zuowen.jpg", { type: "image/jpeg" });
await handleFile(file);
};
const startCorrection = async () => { const startCorrection = async () => {
if (!originalBase64.value || status.value === "processing") return; if (!originalBase64.value || status.value === "processing") return;
status.value = "processing"; status.value = "processing";
@ -217,6 +225,7 @@ const closeLightbox = () => {
</div> </div>
<p class="upload-title">点击或拖拽上传作文图片</p> <p class="upload-title">点击或拖拽上传作文图片</p>
<p class="upload-hint">支持 JPGPNG 格式最大 10MB</p> <p class="upload-hint">支持 JPGPNG 格式最大 10MB</p>
<button class="demo-btn" @click.stop="loadDemoImage">示例作文</button>
</div> </div>
<!-- Preview + Action --> <!-- Preview + Action -->
@ -433,6 +442,21 @@ const closeLightbox = () => {
color: var(--text-secondary); color: var(--text-secondary);
margin: 0; margin: 0;
} }
.demo-btn {
margin-top: 0.75rem;
background: rgba(236, 72, 153, 0.1);
border: 1px solid rgba(236, 72, 153, 0.3);
color: #ec4899;
padding: 0.5rem 1.25rem;
border-radius: 20px;
font-size: 0.875rem;
cursor: pointer;
transition: all 0.2s;
}
.demo-btn:hover {
background: rgba(236, 72, 153, 0.2);
transform: translateY(-1px);
}
/* Preview */ /* Preview */
.preview-section { .preview-section {