时间
This commit is contained in:
@@ -16,11 +16,21 @@ import {
|
||||
import { fetchStats, incrementGenerationCount, type StatsResponse } from "@/lib/stats";
|
||||
import { TemplateScaleFrame } from "@/templates/template-primitives";
|
||||
|
||||
function getTodayDateValue() {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = `${now.getMonth() + 1}`.padStart(2, "0");
|
||||
const day = `${now.getDate()}`.padStart(2, "0");
|
||||
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
|
||||
|
||||
const defaultFormData: CertificateFormData = {
|
||||
childName: "",
|
||||
familyAddress: "腾讯云LightHouse",
|
||||
parentName: "",
|
||||
birthDate: "",
|
||||
birthDate: getTodayDateValue(),
|
||||
birthAddress: "腾讯云x星洋智慧",
|
||||
};
|
||||
|
||||
@@ -33,9 +43,9 @@ const emptyStats: StatsResponse = {
|
||||
const desktopPreviewWidth = 760;
|
||||
const mobileBreakpoint = 768;
|
||||
const statsUnavailableMessage =
|
||||
"统计服务未连接,当前数量不会持久化。请同时运行 npm run dev 和 npm run dev:server,或直接运行 npm run dev:all。";
|
||||
"统计服务未连接。";
|
||||
const statsIncrementFailedMessage =
|
||||
"图片已下载,但统计服务没有记录这次生成。请同时运行 npm run dev 和 npm run dev:server,或直接运行 npm run dev:all。";
|
||||
"图片已下载。";
|
||||
|
||||
function TemplateThumbnail({
|
||||
template,
|
||||
@@ -137,9 +147,10 @@ function CertificateFormFields({
|
||||
/>
|
||||
) : (
|
||||
<input
|
||||
type={key === "birthDate" ? "date" : "text"}
|
||||
value={formData[key]}
|
||||
onChange={onChange(key)}
|
||||
placeholder={`请输入${certificateFieldLabels[key]}`}
|
||||
placeholder={key === "birthDate" ? undefined : `请输入${certificateFieldLabels[key]}`}
|
||||
/>
|
||||
)}
|
||||
</label>
|
||||
@@ -198,7 +209,7 @@ export function CertificateGenerator() {
|
||||
})
|
||||
.catch(() => {
|
||||
if (!active) return;
|
||||
setStatsMessage(statsUnavailableMessage);
|
||||
// setStatsMessage(statsUnavailableMessage);
|
||||
});
|
||||
|
||||
return () => {
|
||||
@@ -266,7 +277,7 @@ export function CertificateGenerator() {
|
||||
setStats(nextStats);
|
||||
setStatsMessage("");
|
||||
} catch {
|
||||
setStatsMessage(statsIncrementFailedMessage);
|
||||
// setStatsMessage(statsIncrementFailedMessage);
|
||||
}
|
||||
} catch (error) {
|
||||
setErrorMessage(error instanceof Error ? error.message : "导出失败,请稍后重试。");
|
||||
@@ -352,8 +363,8 @@ export function CertificateGenerator() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{errorMessage ? <div className="error-box">{errorMessage}</div> : null}
|
||||
{statsMessage ? <div className="error-box">{statsMessage}</div> : null}
|
||||
{/* {errorMessage ? <div className="error-box">{errorMessage}</div> : null}
|
||||
{statsMessage ? <div className="error-box">{statsMessage}</div> : null} */}
|
||||
|
||||
<div ref={previewMeasureRef} className="preview-frame preview-frame--studio">
|
||||
<TemplateScaleFrame
|
||||
|
||||
Reference in New Issue
Block a user